/**
 * Project ElGamal Algorithm.
 * Copyright Michał Szczygieł.
 * Created at Mar 17, 2014.
 */

package com.m4gik;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.junit.Test;

/**
 * 
 * This class contains JUnit tests for class {@link ElGamal}.
 * 
 * @author Michał Szczygieł <michal.szczygiel@wp.pl>
 * 
 */
public class ElGamalTest {

    private static final String EXAMPLE_TEXT = "The quick brown fox jumps over the lazy dog";

    private static final String SECRET_KEY = "12345678901234567890";

    /**
     * This test method checks if ElGamal algorithm proper sign the document.
     * 
     * @throws Exception
     */
    @Test
    public void isSigned() throws Exception {
        // given
        ElGamal elGamal = new ElGamal(SECRET_KEY);
        // when
        Boolean isSigned = elGamal.sign(EXAMPLE_TEXT);
        // then
        assertThat(isSigned, is(equalTo(true)));
    }

    /**
     * This test method checks if ElGamal algorithm can verify own sign of
     * document.
     * 
     * @throws Exception
     */
    @Test
    public void isVerfied() throws Exception {
        // given
        ElGamal elGamal = new ElGamal(SECRET_KEY);
        // when
        Boolean isVerified = false;

        if (elGamal.sign(SHA1.hash(EXAMPLE_TEXT))) {
            isVerified = elGamal.verify();
        }

        // then
        assertThat(isVerified, is(equalTo(true)));
    }
}

@@ -226,31 +226,106 @@
 org.
-junit.Assert.assertThat
+hamcrest.CoreMatchers.not;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport java.math.BigInteger
 ;%0A%0Ai
@@ -671,24 +671,701 @@
 34567890%22;%0A%0A
+    /**%0A     * This test method automated the process of testing.%0A     * %0A     * @throws Exception%0A     */%0A    @Test%0A    public void automatedTestForElGamalAlgorithm() throws Exception %7B%0A        for (int i = 0; i %3C 100; i++) %7B%0A            // given%0A            ElGamal elGamal = new ElGamal(SECRET_KEY);%0A            // when%0A            BigInteger encryptedMessage = elGamal.sign(SHA1.hash(EXAMPLE_TEXT));%0A            Boolean isVeryfied = elGamal.verify(%0A                    elGamal.sign(SHA1.hash(EXAMPLE_TEXT)), null);%0A            // then%0A            assertThat(encryptedMessage, is(not(equalTo(null))));%0A            assertThat(isVeryfied, is(equalTo(true)));%0A        %7D%0A    %7D%0A%0A
     /**%0A    
@@ -1632,23 +1632,34 @@
    B
-oolean isSigned
+igInteger encryptedMessage
  = e
@@ -1670,16 +1670,26 @@
 al.sign(
+SHA1.hash(
 EXAMPLE_
@@ -1693,16 +1693,17 @@
 LE_TEXT)
+)
 ;%0A      
@@ -1735,29 +1735,41 @@
 hat(
-isSigned
+encryptedMessage
 , is(
+not(
 equalTo(
 true
@@ -1760,33 +1760,35 @@
 not(equalTo(
-true
+null)
 )));%0A
+%0A
     %7D%0A%0A    /
@@ -2089,32 +2089,45 @@
 sVer
-i
+y
 fied = 
-false;%0A%0A
+elGamal.verify(%0A     
         
 if (
@@ -2126,12 +2126,11 @@
     
-if (
+   
 elGa
@@ -2166,65 +2166,16 @@
 XT))
-) %7B%0A            isVerified = elGamal.verify();%0A        %7D%0A
+, null);
 %0A   
@@ -2211,17 +2211,17 @@
 at(isVer
-i
+y
 fied, is

Add automated test for ElGamal algorithm