NpmStreamPayload extends StreamPayload { @Override public void copy(final InputStream input, final OutputStream output) throws IOException { new NpmStreamingObjectMapper(packageId, revId, nonNull(fieldMatchers) ? fieldMatchers : emptyList()) .configure(FLUSH_AFTER_WRITE_VALUE, false) .disable(AUTO_CLOSE_TARGET) .readAndWrite(input, new BufferedOutputStream(output)); } NpmStreamPayload(final InputStreamSupplier supplier); NpmStreamPayload packageId(final String packageId); NpmStreamPayload revId(final String revId); NpmStreamPayload fieldMatchers(final List<NpmFieldMatcher> fieldMatchers); NpmStreamPayload missingBlobInputStreamSupplier(
      final InputStreamFunction<MissingAssetBlobException> missingBlobInputStreamSupplier); @Override InputStream openInputStream(); @Override void copy(final InputStream input, final OutputStream output);  }
@Test public void copy_Uses_NpmStreaming() throws IOException { underTest.copy(input, output); verify(input, atLeastOnce()).read(any(byte[].class), any(int.class), any(int.class)); verify(output, atLeastOnce()).write(any(byte[].class), any(int.class), any(int.class)); verify(underTest).copy(eq(input), eq(output)); }