### Question:
BlobPusher { RegistryEndpointProvider<Optional<URL>> initializer() { return new Initializer(); } BlobPusher(
      RegistryEndpointRequestProperties registryEndpointRequestProperties,
      DescriptorDigest blobDigest,
      Blob blob,
      @Nullable String sourceRepository);   }### Answer:
@Test public void testInitializer_getContent() { Assert.assertNull(testBlobPusher.initializer().getContent()); }
@Test public void testGetAccept() { Assert.assertEquals(0, testBlobPusher.initializer().getAccept().size()); }
@Test public void testInitializer_handleResponse_created() throws IOException, RegistryException { Mockito.when(mockResponse.getStatusCode()).thenReturn(201); Assert.assertFalse(testBlobPusher.initializer().handleResponse(mockResponse).isPresent()); }
@Test public void testInitializer_handleResponse_accepted() throws IOException, RegistryException { Mockito.when(mockResponse.getStatusCode()).thenReturn(202); Mockito.when(mockResponse.getHeader("Location")) .thenReturn(Collections.singletonList("location")); GenericUrl requestUrl = new GenericUrl("https: Mockito.when(mockResponse.getRequestUrl()).thenReturn(requestUrl); Assert.assertEquals( new URL("https: testBlobPusher.initializer().handleResponse(mockResponse).get()); }
@Test public void testInitializer_handleResponse_accepted_multipleLocations() throws IOException, RegistryException { Mockito.when(mockResponse.getStatusCode()).thenReturn(202); Mockito.when(mockResponse.getHeader("Location")) .thenReturn(Arrays.asList("location1", "location2")); try { testBlobPusher.initializer().handleResponse(mockResponse); Assert.fail("Multiple 'Location' headers should be a registry error"); } catch (RegistryErrorException ex) { MatcherAssert.assertThat( ex.getMessage(), CoreMatchers.containsString("Expected 1 'Location' header, but found 2")); } }
@Test public void testInitializer_handleResponse_unrecognized() throws IOException, RegistryException { Mockito.when(mockResponse.getStatusCode()).thenReturn(-1); try { testBlobPusher.initializer().handleResponse(mockResponse); Assert.fail("Multiple 'Location' headers should be a registry error"); } catch (RegistryErrorException ex) { MatcherAssert.assertThat( ex.getMessage(), CoreMatchers.containsString("Received unrecognized status code -1")); } }
@Test public void testInitializer_getApiRoute_nullSource() throws MalformedURLException { Assert.assertEquals( new URL("http: testBlobPusher.initializer().getApiRoute("http: }
@Test public void testInitializer_getApiRoute_sameSource() throws MalformedURLException { testBlobPusher = new BlobPusher( new RegistryEndpointRequestProperties("someServerUrl", "someImageName"), fakeDescriptorDigest, TEST_BLOB, "sourceImageName"); Assert.assertEquals( new URL( "http: + fakeDescriptorDigest + "&from=sourceImageName"), testBlobPusher.initializer().getApiRoute("http: }
@Test public void testInitializer_getHttpMethod() { Assert.assertEquals("POST", testBlobPusher.initializer().getHttpMethod()); }