Java Code Examples for org.springframework.http.HttpStatus#I_AM_A_TEAPOT

The following examples show how to use org.springframework.http.HttpStatus#I_AM_A_TEAPOT . 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: SpringWebfluxServerRequestTagAdapterTest.java    From wingtips with Apache License 2.0 5 votes vote down vote up
@Test
public void getResponseHttpStatus_works_as_expected() {
    // given
    HttpStatus expectedResult = HttpStatus.I_AM_A_TEAPOT;
    doReturn(expectedResult).when(responseMock).getStatusCode();

    // when
    Integer result = adapterSpy.getResponseHttpStatus(responseMock);

    // then
    assertThat(result).isEqualTo(expectedResult.value());
}
 
Example 2
Source File: RestOperationsTest.java    From bowman with Apache License 2.0 5 votes vote down vote up
@Test
public void getResourcesOnOtherHttpClientExceptionThrowsException() {
	HttpClientErrorException exception = new HttpClientErrorException(HttpStatus.I_AM_A_TEAPOT);
	when(restTemplate.getForObject(URI.create("http://example.com"), ObjectNode.class))
		.thenThrow(exception);

	thrown.expect(is(exception));
	
	restOperations.getResources(URI.create("http://example.com"), Entity.class);
}
 
Example 3
Source File: GlobalExceptionHandler.java    From example-restful-project with MIT License 5 votes vote down vote up
/**
 * Handles internal teapot errors provoked by unsupported command.
 *
 * @param exception    exception
 *
 * @return response entity
 */
@ExceptionHandler(TeapotInternalErrorException.class)
public ResponseEntity<String> handleTeapotInternalErrorException(
        TeapotInternalErrorException exception) {
    return new ResponseEntity<String>(
            exception.getMessage(),
            HttpStatus.I_AM_A_TEAPOT);  // I am a teapot!
}
 
Example 4
Source File: HttpStatusAdapterTest.java    From problem-spring-web with MIT License 5 votes vote down vote up
@Test
void shouldMapHttpStatusProperties() {
    final HttpStatusAdapter adapter = new HttpStatusAdapter(HttpStatus.I_AM_A_TEAPOT);

    assertThat(adapter.getStatusCode(), is(418));
    assertThat(adapter.getReasonPhrase(), is(HttpStatus.I_AM_A_TEAPOT.getReasonPhrase()));
}
 
Example 5
Source File: HttpStatusAdapterTest.java    From problem-spring-web with MIT License 5 votes vote down vote up
@Test
void shouldUseHttpStatusEqualsAndHashCode() {
    final HttpStatus status = HttpStatus.I_AM_A_TEAPOT;
    final HttpStatusAdapter adapter = new HttpStatusAdapter(HttpStatus.I_AM_A_TEAPOT);

    assertThat(adapter, is(adapter));
    assertThat(adapter, is(new HttpStatusAdapter(status)));
    assertThat(adapter, not(new HttpStatusAdapter(HttpStatus.BAD_GATEWAY)));
    assertThat(adapter, not(HttpStatus.I_AM_A_TEAPOT));
    assertThat(adapter.hashCode(), is(new HttpStatusAdapter(HttpStatus.I_AM_A_TEAPOT).hashCode()));
}
 
Example 6
Source File: HelloController.java    From springdoc-openapi with Apache License 2.0 4 votes vote down vote up
@GetMapping(value = "/hello/{numTelco}")
@ResponseStatus(HttpStatus.I_AM_A_TEAPOT)
@Tag(name = "tea")
public String index(@PathVariable("numTelco") String numTel, String adresse) {
	return "Greetings from Spring Boot!";
}
 
Example 7
Source File: CustomAdvice.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.I_AM_A_TEAPOT)
@ExceptionHandler(HandledStringException.class)
public String handleStringException(HandledStringException e) {
    return e.getMessage();
}
 
Example 8
Source File: RestExceptionHandler.java    From osiam with MIT License 4 votes vote down vote up
@ExceptionHandler(SchemaUnknownException.class)
@ResponseStatus(HttpStatus.I_AM_A_TEAPOT)
@ResponseBody
public ErrorResponse handleSchemaUnknown(SchemaUnknownException e) {
    return produceErrorResponse(e.getMessage(), HttpStatus.I_AM_A_TEAPOT);
}
 
Example 9
Source File: ResponseStatusRestController.java    From tutorials with MIT License 4 votes vote down vote up
@GetMapping("/teapot")
@ResponseStatus(HttpStatus.I_AM_A_TEAPOT)
public void teaPot() {
}