### Question:
TypeAliasRegistry { public void registerAlias(Class<?> type) { String alias = type.getSimpleName(); Alias aliasAnnotation = type.getAnnotation(Alias.class); if (aliasAnnotation != null) { alias = aliasAnnotation.value(); } registerAlias(alias, type); } TypeAliasRegistry(); @SuppressWarnings("unchecked") // throws class cast exception as well if types cannot be assigned Class<T> resolveAlias(String string); void registerAliases(String packageName); void registerAliases(String packageName, Class<?> superType); void registerAlias(Class<?> type); void registerAlias(String alias, Class<?> value); void registerAlias(String alias, String value); Map<String, Class<?>> getTypeAliases();  }### Answer:
@Test void shouldBeAbleToRegisterSameAliasWithSameTypeAgain() { TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry(); typeAliasRegistry.registerAlias("String", String.class); typeAliasRegistry.registerAlias("string", String.class); }
@Test void shouldNotBeAbleToRegisterSameAliasWithDifferentType() { TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry(); assertThrows(TypeException.class, () -> typeAliasRegistry.registerAlias("string", BigDecimal.class)); }
@Test void shouldBeAbleToRegisterNewTypeIfRegisteredTypeIsNull() { TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry(); typeAliasRegistry.registerAlias("foo", (Class<?>) null); typeAliasRegistry.registerAlias("foo", String.class); }
@Test public void shouldBeAbleToRegisterSameAliasWithSameTypeAgain() { TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry(); typeAliasRegistry.registerAlias("String", String.class); typeAliasRegistry.registerAlias("string", String.class); }
@Test(expected = TypeException.class) public void shouldNotBeAbleToRegisterSameAliasWithDifferentType() { TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry(); typeAliasRegistry.registerAlias("string", BigDecimal.class); }
@Test public void shouldBeAbleToRegisterNewTypeIfRegisteredTypeIsNull() { TypeAliasRegistry typeAliasRegistry = new TypeAliasRegistry(); typeAliasRegistry.registerAlias("foo", (Class<?>) null); typeAliasRegistry.registerAlias("foo", String.class); }