dubbo.apache.org/dubbo-go/v3@v3.1.1/registry/event/metadata_service_url_params_customizer_test.go (about)

     1  /*
     2   * Licensed to the Apache Software Foundation (ASF) under one or more
     3   * contributor license agreements.  See the NOTICE file distributed with
     4   * this work for additional information regarding copyright ownership.
     5   * The ASF licenses this file to You under the Apache License, Version 2.0
     6   * (the "License"); you may not use this file except in compliance with
     7   * the License.  You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  
    18  package event
    19  
    20  import (
    21  	"testing"
    22  )
    23  
    24  import (
    25  	gxset "github.com/dubbogo/gost/container/set"
    26  
    27  	"github.com/stretchr/testify/assert"
    28  )
    29  
    30  import (
    31  	"dubbo.apache.org/dubbo-go/v3/common"
    32  	"dubbo.apache.org/dubbo-go/v3/registry"
    33  )
    34  
    35  func TestMetadataServiceURLParamsMetadataCustomizer(t *testing.T) {
    36  
    37  	msup := &metadataServiceURLParamsMetadataCustomizer{exceptKeys: gxset.NewSet()}
    38  	assert.Equal(t, 0, msup.GetPriority())
    39  
    40  	msup.Customize(createInstance())
    41  }
    42  
    43  func createInstance() registry.ServiceInstance {
    44  	ins := &registry.DefaultServiceInstance{}
    45  	return ins
    46  }
    47  
    48  type mockMetadataService struct {
    49  	urls []interface{}
    50  }
    51  
    52  func (m *mockMetadataService) Reference() string {
    53  	panic("implement me")
    54  }
    55  
    56  func (m *mockMetadataService) ServiceName() (string, error) {
    57  	panic("implement me")
    58  }
    59  
    60  func (m *mockMetadataService) ExportURL(*common.URL) (bool, error) {
    61  	panic("implement me")
    62  }
    63  
    64  func (m *mockMetadataService) UnexportURL(*common.URL) error {
    65  	panic("implement me")
    66  }
    67  
    68  func (m *mockMetadataService) SubscribeURL(*common.URL) (bool, error) {
    69  	panic("implement me")
    70  }
    71  
    72  func (m *mockMetadataService) UnsubscribeURL(*common.URL) error {
    73  	panic("implement me")
    74  }
    75  
    76  func (m *mockMetadataService) PublishServiceDefinition(*common.URL) error {
    77  	panic("implement me")
    78  }
    79  
    80  func (m *mockMetadataService) GetExportedURLs(string, string, string, string) ([]interface{}, error) {
    81  	return m.urls, nil
    82  }
    83  
    84  func (m *mockMetadataService) MethodMapper() map[string]string {
    85  	panic("implement me")
    86  }
    87  
    88  func (m *mockMetadataService) GetSubscribedURLs() ([]*common.URL, error) {
    89  	var res []*common.URL
    90  	for _, ui := range m.urls {
    91  		u, _ := common.NewURL(ui.(string))
    92  		res = append(res, u)
    93  	}
    94  	return res, nil
    95  }
    96  
    97  func (m *mockMetadataService) GetServiceDefinition(string, string, string) (string, error) {
    98  	panic("implement me")
    99  }
   100  
   101  func (m *mockMetadataService) GetServiceDefinitionByServiceKey(string) (string, error) {
   102  	panic("implement me")
   103  }
   104  
   105  func (m *mockMetadataService) RefreshMetadata(string, string) (bool, error) {
   106  	panic("implement me")
   107  }
   108  
   109  func (m *mockMetadataService) Version() (string, error) {
   110  	return "1.0.0", nil
   111  }