DataHasher { public final DataHasher addData(byte[] data, int offset, int length) { if (outputHash != null) { throw new IllegalStateException("Output hash has already been calculated"); } messageDigest.update(data, offset, length); return this; } DataHasher(HashAlgorithm algorithm);  DataHasher(HashAlgorithm algorithm, boolean checkExpiration);  DataHasher(); final DataHasher addData(byte[] data, int offset, int length); final DataHasher addData(byte[] data); final DataHasher addData(InputStream inStream); final DataHasher addData(File file); final DataHasher addData(DataHash dataHash); final DataHasher addData(InputStream inStream, int bufferSize); final DataHasher addData(File file, int bufferSize); final DataHash getHash(); final DataHasher reset();  }
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "File can not be null") public void testAddDataInvalidFileException() { DataHasher hasher = new DataHasher(HashAlgorithm.SHA2_256); hasher.addData((File) null); }
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Input stream can not be null") public void testAddDataInvalidInputStreamException() { DataHasher hasher = new DataHasher(HashAlgorithm.SHA2_256); hasher.addData((InputStream) null); }
@Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "Date can not be null") public void testAddInvalidData_ThrowsIllegalArgumentException() { DataHasher hasher = new DataHasher(HashAlgorithm.SHA2_256); hasher.addData((byte[]) null); }