### Question:
BlobPusher { RegistryEndpointProvider<URL> writer(URL location, Consumer<Long> writtenByteCountListener) { return new Writer(location, writtenByteCountListener); } BlobPusher(
      RegistryEndpointRequestProperties registryEndpointRequestProperties,
      DescriptorDigest blobDigest,
      Blob blob,
      @Nullable String sourceRepository);   }### Answer:
@Test public void testWriter_getContent() throws IOException { LongAdder byteCount = new LongAdder(); BlobHttpContent body = testBlobPusher.writer(mockUrl, byteCount::add).getContent(); Assert.assertNotNull(body); Assert.assertEquals("application/octet-stream", body.getType()); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); body.writeTo(byteArrayOutputStream); Assert.assertEquals( TEST_BLOB_CONTENT, new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8)); Assert.assertEquals(TEST_BLOB_CONTENT.length(), byteCount.sum()); }
@Test public void testWriter_GetAccept() { Assert.assertEquals(0, testBlobPusher.writer(mockUrl, ignored -> {}).getAccept().size()); }
@Test public void testWriter_handleResponse() throws IOException, RegistryException { Mockito.when(mockResponse.getHeader("Location")) .thenReturn(Collections.singletonList("https: GenericUrl requestUrl = new GenericUrl("https: Mockito.when(mockResponse.getRequestUrl()).thenReturn(requestUrl); Assert.assertEquals( new URL("https: testBlobPusher.writer(mockUrl, ignored -> {}).handleResponse(mockResponse)); }
@Test public void testWriter_getApiRoute() throws MalformedURLException { URL fakeUrl = new URL("http: Assert.assertEquals(fakeUrl, testBlobPusher.writer(fakeUrl, ignored -> {}).getApiRoute("")); }
@Test public void testWriter_getHttpMethod() { Assert.assertEquals("PATCH", testBlobPusher.writer(mockUrl, ignored -> {}).getHttpMethod()); }