### Question:
BlobChecker implements RegistryEndpointProvider<Optional<BlobDescriptor>> { @Override public Optional<BlobDescriptor> handleHttpResponseException(ResponseException responseException) throws ResponseException { if (responseException.getStatusCode() != HttpStatusCodes.STATUS_CODE_NOT_FOUND) { throw responseException; } if (responseException.getContent() == null) { return Optional.empty(); } ErrorCodes errorCode = ErrorResponseUtil.getErrorCode(responseException); if (errorCode == ErrorCodes.BLOB_UNKNOWN) { return Optional.empty(); } throw responseException; } BlobChecker(
      RegistryEndpointRequestProperties registryEndpointRequestProperties,
      DescriptorDigest blobDigest); @Override Optional<BlobDescriptor> handleResponse(Response response); @Override Optional<BlobDescriptor> handleHttpResponseException(ResponseException responseException); @Override URL getApiRoute(String apiRouteBase); @Nullable @Override BlobHttpContent getContent(); @Override List<String> getAccept(); @Override String getHttpMethod(); @Override String getActionDescription();  }### Answer:
@Test public void testHandleHttpResponseException() throws IOException { ResponseException mockResponseException = Mockito.mock(ResponseException.class); Mockito.when(mockResponseException.getStatusCode()) .thenReturn(HttpStatusCodes.STATUS_CODE_NOT_FOUND); ErrorResponseTemplate emptyErrorResponseTemplate = new ErrorResponseTemplate() .addError(new ErrorEntryTemplate(ErrorCodes.BLOB_UNKNOWN.name(), "some message")); Mockito.when(mockResponseException.getContent()) .thenReturn(JsonTemplateMapper.toUtf8String(emptyErrorResponseTemplate)); Assert.assertFalse( testBlobChecker.handleHttpResponseException(mockResponseException).isPresent()); }
@Test public void testHandleHttpResponseException_invalidStatusCode() { ResponseException mockResponseException = Mockito.mock(ResponseException.class); Mockito.when(mockResponseException.getStatusCode()).thenReturn(-1); try { testBlobChecker.handleHttpResponseException(mockResponseException); Assert.fail("Non-404 status codes should not be handled"); } catch (ResponseException ex) { Assert.assertEquals(mockResponseException, ex); } }