MD5Digester { private ByteBuffer convertToP4dServerEndingsIfRequired(@Nonnull byte[] sourceBytes, final int start, final int length, @Nullable ClientLineEnding clientLineEnding) { ByteBuffer convertedByteBuffer; if (isRequireConvertClientOrLocalLineEndingToServerFormat(clientLineEnding)) { convertedByteBuffer = ByteBuffer.allocate(length); byte p4dServerLineEnding = ClientLineEnding.FST_L_LF_BYTES[0]; byte[] clientLineEndBytes = ClientLineEnding.getLineEndBytes(clientLineEnding); for (int i = start; i < length; i++) { if (doesSourceBytesUseSameClientLineEnding(sourceBytes, i, length, clientLineEndBytes)) { convertedByteBuffer.put(p4dServerLineEnding); i += clientLineEndBytes.length - 1; } else { convertedByteBuffer.put(sourceBytes[i]); } } convertedByteBuffer.flip(); } else { convertedByteBuffer = ByteBuffer.wrap(sourceBytes, start, length); } return convertedByteBuffer; } MD5Digester();  MD5Digester(@Nonnull int bufferSize); byte[] digestAsBytes(); @Nullable String digestFileAs32ByteHex(@Nonnull File file); void reset(); void update(byte[] bytes, int off, int len); String digestAs32ByteHex(); @Nullable String digestFileAs32ByteHex(@Nonnull File file, @Nullable Charset charset); @Nullable String digestFileAs32ByteHex(@Nonnull File file, @Nullable Charset charset,
	                                    boolean doesNeedConvertLineEndings); @Nullable String digestFileAs32ByteHex(@Nonnull File file, @Nullable Charset charset,
	                                    boolean isRequireLineEndingConvert, @Nullable ClientLineEnding clientLineEnding); void update(String str); void update(byte[] bytes); @Deprecated void update(ByteBuffer byteBuf);  }
@DisplayName("test convertToP4dServerEndingsIfRequired() - 2. source bytes use same client line endings") @Test public void testConvertToP4dServerEndingsIfRequired() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { byte[] sourceBytes = new byte[] { 2, 5, 7, '\n', '\r', '\n', 12, 13 }; int start = 3; int length = 8; ClientLineEnding clientLineEnding = ClientLineEnding.FST_L_CRLF; ByteBuffer actual = invokePrivate_convertToP4dServerEndingsIfRequired(sourceBytes, start, length, clientLineEnding); ByteBuffer expected = ByteBuffer.wrap(new byte[] { '\n', '\n', 12, 13 }, 0, 4); assertThat(actual, is(expected)); }
@Ignore("Nicks MD5Digester update") @Test public void testConvertToP4dServerEndingsIfRequired() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { byte[] sourceBytes = new byte[]{2, 5, 7, '\n', '\r', '\n', 12, 13}; int start = 3; int length = 8; ClientLineEnding clientLineEnding = ClientLineEnding.FST_L_CRLF; ByteBuffer actual = invokePrivate_convertToP4dServerEndingsIfRequired(sourceBytes, start, length, clientLineEnding); ByteBuffer expected = ByteBuffer.wrap(new byte[]{'\n', '\n', 12, 13}, 0, 4); assertThat(actual, is(expected)); }