use of org.apache.dubbo.metadata.report.identifier.MetadataIdentifier 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));
}
use of org.apache.dubbo.metadata.report.identifier.MetadataIdentifier in project incubator-dubbo-ops by apache.
the class ConsulMetaDataCollectorTest method buildIdentifier.
private MetadataIdentifier buildIdentifier(boolean isProducer) {
MetadataIdentifier identifier = new MetadataIdentifier();
identifier.setApplication(String.format("metadata-%s-test", isProducer ? "provider" : "consumer"));
identifier.setGroup("group");
identifier.setServiceInterface(ServiceA.class.getName());
identifier.setSide(isProducer ? PROVIDER_SIDE : CONSUMER_SIDE);
identifier.setVersion("1.0.0");
return identifier;
}
Aggregations