AliasRegistryImpl extends ComponentSupport implements AliasRegistry { @Override public void registerAlias(final String name, final String alias) { checkNotNull(name); checkNotNull(alias); log.debug("Registering alias: {} -> {}", name, alias); if (log.isDebugEnabled()) { if (containsAlias(name)) { log.debug("Replacing alias: {}", name); } } aliases.put(name, alias); events.publish(new AliasRegisteredEvent(name, alias)); } @Inject  AliasRegistryImpl(final EventManager events); @Override void registerAlias(final String name, final String alias); @Override void removeAlias(final String name); @Override String getAlias(final String name); @Override boolean containsAlias(final String name); @Override Map<String, String> getAliases();  }
@Test public void testRegisterAliasInvalid() throws Exception { try { underTest.registerAlias(null, null); fail(); } catch (NullPointerException e) { } try { underTest.registerAlias("foo", null); fail(); } catch (NullPointerException e) { } try { underTest.registerAlias(null, "foo"); fail(); } catch (NullPointerException e) { } }
@Test public void testRegisterAlias() throws Exception { assertFalse(underTest.containsAlias("foo")); underTest.registerAlias("foo", "bar"); assertTrue(underTest.containsAlias("foo")); String alias = underTest.getAlias("foo"); assertEquals("bar", alias); }