package com.decentralizeddatabase.reno.crytpo;

// TODO
public final class CryptoBlockTest {

}

@@ -39,58 +39,2465 @@
 .cry
-tpo;%0A%0A// TODO%0Apublic final class CryptoBlockTest %7B%0A
+pto;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.rules.ExpectedException;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0A%0Aimport javax.crypto.Cipher;%0Aimport javax.crypto.spec.SecretKeySpec;%0Aimport java.security.InvalidKeyException;%0Aimport java.security.Key;%0A%0Apublic final class CryptoBlockTest %7B%0A%0A    private Cipher cipher;%0A    private CryptoBlock cryptoBlock;%0A%0A    private static final String KEY = %220123456789123456%22;%0A    private static final byte%5B%5D BLOCK = %22Block%22.getBytes();%0A    %0A    private byte%5B%5D encryptHelper(final byte%5B%5D block, final String key) throws Exception %7B%0A        final Key aesKey = new SecretKeySpec(key.getBytes(), %22AES%22);%0A        cipher.init(Cipher.ENCRYPT_MODE, aesKey);%0A        final byte%5B%5D encrypted = cipher.doFinal(block);%0A        return encrypted;%0A    %7D%0A%0A    private byte%5B%5D decryptHelper(final byte%5B%5D block, final String key) throws Exception %7B%0A        final Key aesKey = new SecretKeySpec(key.getBytes(), %22AES%22);%0A        cipher.init(Cipher.DECRYPT_MODE, aesKey);%0A        final byte%5B%5D decrypted = cipher.doFinal(block);%0A        return decrypted;%0A    %7D%0A%0A    @Before%0A    public void setup() throws Exception %7B%0A%09cipher = Cipher.getInstance(%22AES%22);%0A%09cryptoBlock = new CryptoBlock();%0A    %7D%0A%0A    @Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A%0A    @Test%0A    public void testEncryptWithValidKey() throws Exception %7B%0A%09final byte%5B%5D expected = encryptHelper(BLOCK, KEY);%09%0A%09final byte%5B%5D actual = cryptoBlock.encrypt(BLOCK, KEY);%0A%0A%09final int length = expected.length;%0A%09for (int idx = 0; idx %3C length; idx++) %7B%0A%09    Assert.assertEquals(expected%5Bidx%5D, actual%5Bidx%5D);%0A%09%7D%0A    %7D%0A%0A    @Test%0A    public void testEncryptWithInvalidKey() throws Exception %7B%0A%09thrown.expect(InvalidKeyException.class);%0A%09cryptoBlock.encrypt(BLOCK, %22invalid%22);%0A%09%0A%09Assert.fail(%22No InvalidKeyException thrown%22);%0A    %7D%0A%0A    @Test%0A    public void testDecryptWithValidKey() throws Exception %7B%0A%09final byte%5B%5D encryptedBlock = encryptHelper(BLOCK, KEY);%0A%0A%09final byte%5B%5D expected = decryptHelper(encryptedBlock, KEY);%0A%09final byte%5B%5D actual = cryptoBlock.decrypt(encryptedBlock, KEY);%0A%0A%09final int length = expected.length;%0A%09for (int idx = 0; idx %3C length; idx++) %7B%0A%09    Assert.assertEquals(expected%5Bidx%5D, actual%5Bidx%5D);%0A%09%7D%0A    %7D%0A%0A    @Test%0A    public void testDecryptWithInvalidKey() throws Exception %7B%0A%09thrown.expect(InvalidKeyException.class);%0A%09cryptoBlock.decrypt(BLOCK, %22invalid%22);%0A%09%0A%09Assert.fail(%22No InvalidKeyException thrown%22);%0A    %7D
 %0A%7D%0A

Add CryptoBlock tests