### Question:
RestTemplateUtils { public static boolean isNotFound( @Nonnull HttpClientErrorException e ) { if ( !HttpStatus.NOT_FOUND.equals( e.getStatusCode() ) ) { return false; } final HttpHeaders headers = e.getResponseHeaders(); return (headers != null) && MediaType.APPLICATION_JSON.isCompatibleWith( headers.getContentType() ); } private  RestTemplateUtils(); static boolean isNotFound( @Nonnull HttpClientErrorException e );  }### Answer:
@Test public void isNotFoundFalseStatus() { final HttpHeaders headers = new HttpHeaders(); headers.set( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE ); final HttpClientErrorException exception = new HttpClientErrorException( HttpStatus.UNAUTHORIZED, "Unauthorized", headers, null, StandardCharsets.UTF_8 ); Assert.assertFalse( RestTemplateUtils.isNotFound( exception ) ); }
@Test public void isNotFoundFalseContent() { final HttpHeaders headers = new HttpHeaders(); headers.set( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PDF_VALUE ); final HttpClientErrorException exception = new HttpClientErrorException( HttpStatus.UNAUTHORIZED, "Unauthorized", headers, null, StandardCharsets.UTF_8 ); Assert.assertFalse( RestTemplateUtils.isNotFound( exception ) ); }
@Test public void isNotFoundNoHeaders() { final HttpClientErrorException exception = new HttpClientErrorException( HttpStatus.UNAUTHORIZED, "Unauthorized", null, null, StandardCharsets.UTF_8 ); Assert.assertFalse( RestTemplateUtils.isNotFound( exception ) ); }
@Test public void isNotFoundTrue() { final HttpHeaders headers = new HttpHeaders(); headers.set( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE ); final HttpClientErrorException exception = new HttpClientErrorException( HttpStatus.NOT_FOUND, "Not Found", headers, null, StandardCharsets.UTF_8 ); Assert.assertTrue( RestTemplateUtils.isNotFound( exception ) ); }