package com.ironz.binaryprefs.encryption;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

public class XorKeyEncryptionImplTest {

    private final XorKeyEncryptionImpl xorKeyEncryption = new XorKeyEncryptionImpl("111111111111111011".getBytes());

    @Test
    public void decrypt() throws Exception {
        String origin = "origin";
        String decrypt = xorKeyEncryption.decrypt(origin);
        assertNotEquals(origin, decrypt);

        String encrypt = xorKeyEncryption.encrypt(decrypt);
        assertEquals(origin, encrypt);
    }

    @Test
    public void encrypt() throws Exception {
        String origin = "origin";
        String encrypted = xorKeyEncryption.encrypt(origin);
        assertNotEquals(origin, encrypted);

        String decrypt = xorKeyEncryption.decrypt(encrypted);
        assertEquals(origin, decrypt);
    }

}
@@ -36,16 +36,77 @@
 ption;%0A%0A
+import com.ironz.binaryprefs.exception.EncryptionException;%0A%0A
 import o
@@ -344,26 +344,24 @@
 pl(%22
-111111111111111011
+LZN8KKF7KH816D0U
 %22.ge
@@ -407,33 +407,16 @@
 ecrypt()
- throws Exception
  %7B%0A     
@@ -691,25 +691,8 @@
 pt()
- throws Exception
  %7B%0A 
@@ -938,9 +938,1518 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void incorrectDecryptWithAnotherEncryption() %7B%0A        String origin = %22origin%22;%0A        String encrypted = xorKeyEncryption.encrypt(origin);%0A%0A        XorKeyEncryptionImpl anotherEncryption = new XorKeyEncryptionImpl(%221111111111111110%22.getBytes());%0A        String decryptByAnother = anotherEncryption.decrypt(encrypted);%0A%0A        assertNotEquals(origin, decryptByAnother);%0A    %7D%0A%0A    @Test%0A    public void givenXorOddSizeThenNoEncryptionException() %7B%0A        String withOddSize = %2211111111111111111%22;%0A        new XorKeyEncryptionImpl(withOddSize.getBytes());%0A    %7D%0A%0A    @Test(expected = EncryptionException.class)%0A    public void givenXorEvenSizeAndMirroredThenEncryptionException() %7B%0A        String evenWithMirror = %220101010101010101%22;%0A        new XorKeyEncryptionImpl(evenWithMirror.getBytes());%0A    %7D%0A%0A    @Test%0A    public void givenXorEvenSizeAndNotMirroredThenNoEncryptionException() %7B%0A        String evenWithMirror = %221111111111111110%22;%0A        new XorKeyEncryptionImpl(evenWithMirror.getBytes());%0A    %7D%0A%0A    @Test(expected = EncryptionException.class)%0A    public void givenXorSizeLessThenSixteenThenEncryptionException() %7B%0A        String withSizeLessThenSixteen = %22%22;%0A        new XorKeyEncryptionImpl(withSizeLessThenSixteen.getBytes());%0A    %7D%0A%0A    @Test%0A    public void givenXorSizeGreaterThenFifthTeenThenNoEncryptionException() %7B%0A        String withSizeGreaterThenFifthTeen = %2211111111111111111%22;%0A        new XorKeyEncryptionImpl(withSizeGreaterThenFifthTeen.getBytes());%0A    %7D%0A
 %7D

add tests for XorKeyEncryptionImpl