DMREndpointService extends EndpointService<DMRNodeLocation, DMRSession> { static String getServerIdentifier(String hostName, String serverName, String nodeName, String uuid) { if (uuid != null) { return uuid; } else { StringBuilder fullId = new StringBuilder(); if (hostName != null && !hostName.isEmpty()) { if (fullId.length() > 0) { fullId.append('.'); } fullId.append(hostName); } if (serverName != null && !serverName.isEmpty()) { if (fullId.length() > 0) { fullId.append('.'); } fullId.append(serverName); } if (nodeName != null && !nodeName.isEmpty() && !nodeName.equals(serverName)) { if (fullId.length() > 0) { fullId.append('.'); } fullId.append(nodeName); } return fullId.toString(); } } DMREndpointService(String feedId, MonitoredEndpoint<EndpointConfiguration> endpoint,
            ResourceTypeManager<DMRNodeLocation> resourceTypeManager,
            ModelControllerClientFactory modelControllerClientFactory, ProtocolDiagnostics diagnostics); static String lookupServerIdentifier(ModelControllerClient client); @Override DMRSession openSession(); static final String ENABLE_STATISTICS_KEY; }
@Test public void testServerId() { String id = DMREndpointService.getServerIdentifier("one", "two", "three", null); assertEquals("one.two.three", id); id = DMREndpointService.getServerIdentifier(null, "two", "three", null); assertEquals("two.three", id); id = DMREndpointService.getServerIdentifier(null, null, "three", null); assertEquals("three", id); id = DMREndpointService.getServerIdentifier(null, null, null, null); assertEquals("", id); id = DMREndpointService.getServerIdentifier("", "two", "three", null); assertEquals("two.three", id); id = DMREndpointService.getServerIdentifier("", "", "three", null); assertEquals("three", id); id = DMREndpointService.getServerIdentifier("", "", "", null); assertEquals("", id); id = DMREndpointService.getServerIdentifier("one", "two", "two", null); assertEquals("one.two", id); id = DMREndpointService.getServerIdentifier("", "two", "two", null); assertEquals("two", id); id = DMREndpointService.getServerIdentifier(null, "two", "two", null); assertEquals("two", id); String uuid = UUID.randomUUID().toString(); id = DMREndpointService.getServerIdentifier("a", "b", "c", uuid); assertEquals(uuid, id); }