Java Code Examples for org.springframework.core.ResolvableType#toString()

The following examples show how to use org.springframework.core.ResolvableType#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolvableMethod.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Filter on methods returning the given type.
 * @param returnType the return type
 */
public Builder<T> returning(ResolvableType returnType) {
	String expected = returnType.toString();
	String message = "returnType=" + expected;
	addFilter(message, m -> expected.equals(ResolvableType.forMethodReturnType(m).toString()));
	return this;
}
 
Example 2
Source File: ResolvableMethod.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Filter on methods returning the given type.
 * @param returnType the return type
 */
public Builder<T> returning(ResolvableType returnType) {
	String expected = returnType.toString();
	String message = "returnType=" + expected;
	addFilter(message, m -> expected.equals(ResolvableType.forMethodReturnType(m).toString()));
	return this;
}
 
Example 3
Source File: ResolvableMethod.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Filter on methods returning the given type.
 * @param returnType the return type
 */
public Builder<T> returning(ResolvableType returnType) {
	String expected = returnType.toString();
	String message = "returnType=" + expected;
	addFilter(message, m -> expected.equals(ResolvableType.forMethodReturnType(m).toString()));
	return this;
}
 
Example 4
Source File: ResolvableMethod.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Filter on methods returning the given type.
 * @param returnType the return type
 */
public Builder<T> returning(ResolvableType returnType) {
	String expected = returnType.toString();
	String message = "returnType=" + expected;
	addFilter(message, m -> expected.equals(ResolvableType.forMethodReturnType(m).toString()));
	return this;
}
 
Example 5
Source File: UnsupportedMediaTypeException.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static String initReason(@Nullable MediaType contentType, @Nullable ResolvableType bodyType) {
	return "Content type '" + (contentType != null ? contentType : "") + "' not supported" +
			(bodyType != null ? " for bodyType=" + bodyType.toString() : "");
}
 
Example 6
Source File: UnsupportedMediaTypeStatusException.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private static String initReason(@Nullable MediaType contentType, @Nullable ResolvableType bodyType) {
	return "Content type '" + (contentType != null ? contentType : "") + "' not supported" +
			(bodyType != null ? " for bodyType=" + bodyType.toString() : "");
}
 
Example 7
Source File: UnsupportedMediaTypeException.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static String initReason(@Nullable MediaType contentType, @Nullable ResolvableType bodyType) {
	return "Content type '" + (contentType != null ? contentType : "") + "' not supported" +
			(bodyType != null ? " for bodyType=" + bodyType.toString() : "");
}
 
Example 8
Source File: UnsupportedMediaTypeStatusException.java    From java-technology-stack with MIT License 4 votes vote down vote up
private static String initReason(@Nullable MediaType contentType, @Nullable ResolvableType bodyType) {
	return "Content type '" + (contentType != null ? contentType : "") + "' not supported" +
			(bodyType != null ? " for bodyType=" + bodyType.toString() : "");
}
 
Example 9
Source File: OneOffSpringWebFluxFrameworkExceptionHandlerListenerTest.java    From backstopper with Apache License 2.0 4 votes vote down vote up
@DataProvider(value = {
    "true",
    "false"
})
@Test
public void handleFluxExceptions_handles_UnsupportedMediaTypeStatusException_as_expected(
    boolean includeDetails
) {
    // given
    MediaType actualMediaType = MediaType.TEXT_PLAIN;
    List<MediaType> supportedMediaTypes = Arrays.asList(
        MediaType.APPLICATION_JSON,
        MediaType.IMAGE_JPEG
    );
    ResolvableType javaBodyType = ResolvableType.forClass(Integer.class);
    UnsupportedMediaTypeStatusException ex =
        (includeDetails)
        ? new UnsupportedMediaTypeStatusException(actualMediaType, supportedMediaTypes, javaBodyType)
        : new UnsupportedMediaTypeStatusException("Some reason");

    List<Pair<String, String>> expectedExtraDetailsForLogging = new ArrayList<>();
    ApiExceptionHandlerUtils.DEFAULT_IMPL.addBaseExceptionMessageToExtraDetailsForLogging(
        ex, expectedExtraDetailsForLogging
    );

    String expectedSupportedMediaTypesValueStr =
        (includeDetails)
        ? supportedMediaTypes.stream().map(Object::toString).collect(Collectors.joining(","))
        : "";
    String expectedJavaBodyTypeValueStr =
        (includeDetails)
        ? javaBodyType.toString()
        : "null";

    expectedExtraDetailsForLogging.add(Pair.of("supported_media_types", expectedSupportedMediaTypesValueStr));
    expectedExtraDetailsForLogging.add(Pair.of("java_body_type", expectedJavaBodyTypeValueStr));

    // when
    ApiExceptionHandlerListenerResult result = listener.handleSpringMvcOrWebfluxSpecificFrameworkExceptions(ex);

    // then
    validateResponse(
        result,
        true,
        singleton(testProjectApiErrors.getUnsupportedMediaTypeApiError()),
        expectedExtraDetailsForLogging
    );
}