@Override
    public List<ServiceDefinition> getServices(String name) {
        final Lookup lookup = cache.computeIfAbsent(name, this::createLookup);
        final Record[] records = lookup.run();

        List<ServiceDefinition> services;
        if (Objects.nonNull(records) && lookup.getResult() == Lookup.SUCCESSFUL) {
            services = Arrays.stream(records)
                    .filter(SRVRecord.class::isInstance)
                    .map(SRVRecord.class::cast)
                    .sorted(COMPARATOR)
                    .map(srvRecord -> asService(name, srvRecord))
                    .collect(Collectors.toList());
        } else {
            services = Collections.emptyList();
        }

        return services;
    }
@Test
    void testServiceDiscovery() throws IOException {
        DnsConfiguration configuration = new DnsConfiguration();
        try (DnsServiceDiscovery discovery = new DnsServiceDiscovery(configuration)) {

            configuration.setDomain("jabber.com");
            configuration.setProto("_tcp");

            List<ServiceDefinition> services = discovery.getServices("_xmpp-server");
            assertNotNull(services);
            assertFalse(services.isEmpty());

            for (ServiceDefinition service : services) {
                assertFalse(service.getMetadata().isEmpty());
                assertNotNull(service.getMetadata().get("priority"));
                assertNotNull(service.getMetadata().get("weight"));
            }
        }
    }