WhiteboardAuthorizableNodeName extends AbstractServiceTracker<AuthorizableNodeName> implements AuthorizableNodeName { @NotNull @Override public String generateNodeName(@NotNull String authorizableId) { List<AuthorizableNodeName> services = getServices(); if (services.isEmpty()) { return AuthorizableNodeName.DEFAULT.generateNodeName(authorizableId); } else { return services.iterator().next().generateNodeName(authorizableId); } } WhiteboardAuthorizableNodeName(); @NotNull @Override String generateNodeName(@NotNull String authorizableId);  }
@Test public void testDefault() { assertEquals(AuthorizableNodeName.DEFAULT.generateNodeName(TEST_ID), authorizableNodeName.generateNodeName(TEST_ID)); }
@Test public void testStarted() { authorizableNodeName.start(whiteboard); assertEquals(AuthorizableNodeName.DEFAULT.generateNodeName(TEST_ID), authorizableNodeName.generateNodeName(TEST_ID)); }
@Test public void testRegisteredImplementation() { authorizableNodeName.start(whiteboard); AuthorizableNodeName registered = authorizableId -> "generated"; whiteboard.register(AuthorizableNodeName.class, registered, ImmutableMap.of()); assertEquals(registered.generateNodeName(TEST_ID), authorizableNodeName.generateNodeName(TEST_ID)); }