CuratorDiscoverySpec implements ZooKeeperDiscoverySpec { @Override public Endpoint decode(byte[] data) { final ServiceInstance<?> decodedInstance = CuratorXNodeValueCodec.INSTANCE.decode(data); final Endpoint endpoint = converter.apply(decodedInstance); if (endpoint == null) { logger.warn("The endpoint converter returned null from {}.", decodedInstance); } return endpoint; } CuratorDiscoverySpec(
            String serviceName, Function<? super ServiceInstance<?>, Endpoint> converter); @Override String path(); @Override Endpoint decode(byte[] data); @Override String toString();  }
@Test void decode() { ZooKeeperDiscoverySpec spec = ZooKeeperDiscoverySpec.curator("foo"); ServiceInstance<?> instance = serviceInstance(false); Endpoint endpoint = spec.decode(CuratorXNodeValueCodec.INSTANCE.encode(instance)); assertThat(endpoint).isNull(); instance = serviceInstance(true); endpoint = spec.decode(CuratorXNodeValueCodec.INSTANCE.encode(instance)); assertThat(endpoint).isEqualTo(Endpoint.of("foo.com", 100)); spec = ZooKeeperDiscoverySpec.builderForCurator("foo").useSsl(true).build(); endpoint = spec.decode(CuratorXNodeValueCodec.INSTANCE.encode(instance)); assertThat(endpoint).isEqualTo(Endpoint.of("foo.com", 200)); final Endpoint bar = Endpoint.of("bar"); spec = ZooKeeperDiscoverySpec.builderForCurator("foo") .converter(serviceInstance -> bar) .build(); endpoint = spec.decode(CuratorXNodeValueCodec.INSTANCE.encode(instance)); assertThat(endpoint).isSameAs(bar); }