### Question:
DoubleClickCrypto { public byte[] encrypt(byte[] plainData) { checkArgument(plainData.length >= OVERHEAD_SIZE, "Invalid plainData, %s bytes", plainData.length); byte[] workBytes = plainData.clone(); ByteBuffer workBuffer = ByteBuffer.wrap(workBytes); boolean success = false; try { int signature = hmacSignature(workBytes); workBuffer.putInt(workBytes.length - SIGNATURE_SIZE, signature); xorPayloadToHmacPad(workBytes); if (logger.isDebugEnabled()) { logger.debug(dump("Encrypted", plainData, workBytes)); } success = true; return workBytes; } finally { if (!success && logger.isDebugEnabled()) { logger.debug(dump("Encrypted (failed)", plainData, workBytes)); } } } DoubleClickCrypto(Keys keys); byte[] decrypt(byte[] cipherData); byte[] encrypt(byte[] plainData); byte[] createInitVector(@Nullable Date timestamp, long serverId); byte[] createInitVector(long timestamp, long serverId); Date getTimestamp(byte[] data); long getServerId(byte[] data); @Override String toString(); static final String KEY_ALGORITHM; static final int INITV_BASE; static final int INITV_SIZE; static final int INITV_TIMESTAMP_OFFSET; static final int INITV_SERVERID_OFFSET; static final int PAYLOAD_BASE; static final int SIGNATURE_SIZE; static final int OVERHEAD_SIZE; }### Answer:
@Test(expected = IllegalArgumentException.class) public void testEncryptBytes_empty() { baseCrypto.encrypt(new byte[0]); }
@Test public void testEncryptBytes_noData() { assertThat(baseCrypto.encrypt(new byte[DoubleClickCrypto.OVERHEAD_SIZE])) .hasLength(DoubleClickCrypto.OVERHEAD_SIZE); }