use of org.apache.dubbo.metadata.definition.model.MethodDefinition in project incubator-dubbo-ops by apache.
the class ConsulMetaDataCollectorTest method testGetProviderMetaData.
@Test
public void testGetProviderMetaData() {
MetadataIdentifier identifier = buildIdentifier(true);
Map<String, String> params = new HashMap<>();
params.put("key1", "value1");
params.put("key2", "true");
FullServiceDefinition definition = ServiceDefinitionBuilder.buildFullDefinition(ServiceA.class, params);
String metadata = gson.toJson(definition);
consulMetaDataCollector.getClient().setKVValue(identifier.getUniqueKey(KeyTypeEnum.UNIQUE_KEY), metadata);
String providerMetaData = consulMetaDataCollector.getProviderMetaData(identifier);
Assert.assertEquals(metadata, providerMetaData);
FullServiceDefinition retDef = gson.fromJson(providerMetaData, FullServiceDefinition.class);
Assert.assertEquals(ServiceA.class.getCanonicalName(), retDef.getCanonicalName());
Assert.assertEquals(ClassUtils.getCodeSource(ServiceA.class), retDef.getCodeSource());
Assert.assertEquals(params, retDef.getParameters());
// method def assertions
Assert.assertNotNull(retDef.getMethods());
Assert.assertEquals(3, retDef.getMethods().size());
List<String> methodNames = retDef.getMethods().stream().map(MethodDefinition::getName).sorted().collect(Collectors.toList());
Assert.assertEquals("method1", methodNames.get(0));
Assert.assertEquals("method2", methodNames.get(1));
Assert.assertEquals("method3", methodNames.get(2));
}
Aggregations