### Question:
TypeAliasResolver { public TypeAlias getAliasFor(Type type) { TypeAlias alias = typeAliases.getAliasesMappedByType().get(type); if (alias == null) { String message = String.format("Could not find type alias for given type: %s", type); throw new IllegalArgumentException(message); } return alias; } TypeAliasResolver(); boolean hasAliasFor(Type type); boolean hasAliasFor(String name); TypeAlias getAliasFor(Type type); TypeAlias getAliasFor(String name);  }### Answer:
@Test void shouldResolveTypeAliasForGivenName() { String name = "String"; TypeAlias alias = resolver.getAliasFor(name); assertThat(alias.getAlias()).isEqualTo("String"); assertThat(alias.getType()).isEqualTo(String.class); }
@Test void shouldResolveTypeAliasForGivenType() { Class<?> type = String.class; TypeAlias alias = resolver.getAliasFor(type); assertThat(alias.getAlias()).isEqualTo("String"); assertThat(alias.getType()).isEqualTo(String.class); }
@Test void shouldThrowExceptionForUnknownName() { String unknownName = "UNKNOWN_NAME"; String expectedMessage = String.format("Could not find type alias for given name: %s", unknownName); assertThatThrownBy(() -> resolver.getAliasFor(unknownName)) .isInstanceOf(IllegalArgumentException.class) .hasMessage(expectedMessage); }
@Test void shouldThrowExceptionForUnknownType() { Class<?> unknownType = TypeAlias.class; String expectedMessage = String.format("Could not find type alias for given type: %s", unknownType); assertThatThrownBy(() -> resolver.getAliasFor(unknownType)) .isInstanceOf(IllegalArgumentException.class) .hasMessage(expectedMessage); }