### Question:
ClassUtils { static Class<?> forName(String name) { return Stream.of( tryResolveTypeFor(name), tryResolvePrimitiveTypeFor(name)) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow(() -> new IllegalArgumentException( String.format("Could not resolve type for name: %s", name))); } private  ClassUtils();   }### Answer:
@Test void shouldResolvePrimitiveTypeProperly() { String name = "int"; Class<?> type = ClassUtils.forName(name); assertThat(type).isEqualTo(int.class); }
@Test void shouldResolveObjectTypeProperly() { String name = "java.lang.String"; Class<?> type = ClassUtils.forName(name); assertThat(type).isEqualTo(String.class); }
@Test void shouldThrowExceptionForUnknownType() { String unknownTypeName = "UNKNOWN_TYPE_NAME"; String expectedMessage = String.format("Could not resolve type for name: %s", unknownTypeName); assertThatThrownBy(() -> ClassUtils.forName(unknownTypeName)) .isInstanceOf(IllegalArgumentException.class) .hasMessage(expectedMessage); }