@Test public void put() { BaseByteArrayWriter byteArrayWriter = new BaseByteArrayWriter(dataWriter, posWriter, lenWriter, true, lastPosWriter, lastPosReader); byteArrayWriter.put(0, new byte[]{1, 2, 3}); verifyZeroInteractions(lastPosWriter, lastPosReader); verify(posWriter).put(0, 0); verify(lenWriter).put(0, 3); verify(dataWriter).put(0, (byte) 1); verify(dataWriter).put(1, (byte) 2); verify(dataWriter).put(2, (byte) 3); assertEquals(3L, (long) Whitebox.getInternalState(byteArrayWriter, "curPos")); byteArrayWriter.put(1, null); verify(posWriter).put(1, 3); verify(lenWriter).put(1, 0); verifyNoMoreInteractions(dataWriter); assertEquals(3L, (long) Whitebox.getInternalState(byteArrayWriter, "curPos")); when(lastPosReader.isReadable()).thenReturn(true); when(lastPosReader.get(0)).thenReturn(3L); byteArrayWriter = new BaseByteArrayWriter(dataWriter, posWriter, lenWriter, false, lastPosWriter, lastPosReader); assertEquals(3L, (long) Whitebox.getInternalState(byteArrayWriter, "curPos")); }
@Override public void put(long pos, byte[] val) { int len = val == null ? 0 : val.length; posWriter.put(pos, curPos); lenWriter.put(pos, len); for (int i = 0; i < len; i++) { dataWriter.put(curPos + i, val[i]); } curPos += len; }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void put(long pos, byte[] val) { int len = val == null ? 0 : val.length; posWriter.put(pos, curPos); lenWriter.put(pos, len); for (int i = 0; i < len; i++) { dataWriter.put(curPos + i, val[i]); } curPos += len; } }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void put(long pos, byte[] val) { int len = val == null ? 0 : val.length; posWriter.put(pos, curPos); lenWriter.put(pos, len); for (int i = 0; i < len; i++) { dataWriter.put(curPos + i, val[i]); } curPos += len; } BaseByteArrayWriter(ByteWriter dataWriter, LongWriter posWriter, IntWriter lenWriter, boolean isOverwrite, @Nullable LongWriter lastPosWriter, @Nullable LongReader lastPosReader); }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void put(long pos, byte[] val) { int len = val == null ? 0 : val.length; posWriter.put(pos, curPos); lenWriter.put(pos, len); for (int i = 0; i < len; i++) { dataWriter.put(curPos + i, val[i]); } curPos += len; } BaseByteArrayWriter(ByteWriter dataWriter, LongWriter posWriter, IntWriter lenWriter, boolean isOverwrite, @Nullable LongWriter lastPosWriter, @Nullable LongReader lastPosReader); @Override void put(long pos, byte[] val); @Override OutputStream putStream(final long pos); @Override void resetContentPosition(); @Override void release(); }
BaseByteArrayWriter implements ByteArrayWriter { @Override public void put(long pos, byte[] val) { int len = val == null ? 0 : val.length; posWriter.put(pos, curPos); lenWriter.put(pos, len); for (int i = 0; i < len; i++) { dataWriter.put(curPos + i, val[i]); } curPos += len; } BaseByteArrayWriter(ByteWriter dataWriter, LongWriter posWriter, IntWriter lenWriter, boolean isOverwrite, @Nullable LongWriter lastPosWriter, @Nullable LongReader lastPosReader); @Override void put(long pos, byte[] val); @Override OutputStream putStream(final long pos); @Override void resetContentPosition(); @Override void release();  }