use of io.scalecube.services.ServiceRegistration in project scalecube by scalecube.
the class ScalecubeServiceDiscoveryTest method testMetadataCodec.
@ParameterizedTest
@MethodSource("metadataCodecSource")
public void testMetadataCodec(MetadataCodec metadataCodec) {
ServiceEndpoint serviceEndpoint = ServiceEndpoint.builder().id(UUID.randomUUID().toString()).tags(Collections.singletonMap("K", "V")).contentTypes(Collections.singleton("json")).appendServiceRegistrations(Collections.singletonList(new ServiceRegistration("namespace", Collections.singletonMap("KK", "VV"), Collections.singletonList(new ServiceMethodDefinition("action0", Collections.singletonMap("KKK0", "VVV"), true))))).appendServiceRegistrations(Collections.singletonList(new ServiceRegistration("namespace", Collections.singletonMap("KK", "VV"), Collections.singletonList(new ServiceMethodDefinition("action1", Collections.singletonMap("KKK1", "VVV"), true))))).appendServiceRegistrations(Collections.singletonList(new ServiceRegistration("namespace", Collections.singletonMap("KK", "VV"), Collections.singletonList(new ServiceMethodDefinition("action2", Collections.singletonMap("KKK2", "VVV"), true))))).build();
ByteBuffer buffer = metadataCodec.serialize(serviceEndpoint);
ServiceEndpoint serviceEndpoint1 = (ServiceEndpoint) metadataCodec.deserialize(buffer);
Assertions.assertEquals(serviceEndpoint.id(), serviceEndpoint1.id());
Assertions.assertEquals(1, serviceEndpoint1.tags().size());
Assertions.assertEquals(1, serviceEndpoint1.contentTypes().size());
List<ServiceRegistration> serviceRegistrations = new ArrayList<>(serviceEndpoint1.serviceRegistrations());
Assertions.assertEquals(3, serviceRegistrations.size());
for (ServiceRegistration serviceRegistration : serviceRegistrations) {
Assertions.assertEquals(1, serviceRegistration.methods().size());
Assertions.assertEquals(1, serviceRegistration.tags().size());
}
}
Aggregations