package com.m4gik;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

/**
 * 
 * This class contains JUnit tests for class {@link Haval}.
 * 
 * @author Michał Szczygieł <michal.szczygiel@wp.pl>
 * 
 */
@RunWith(Parameterized.class)
public class HavalTest {

    @Parameterized.Parameters
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][] {
                { "The quick brown fox jumps over the lazy dog",
                        "713502673d67e5fa557629a71d331945",
                        HavalAttributes.HAVAL_128_BIT,
                        HavalAttributes.HAVAL_3_ROUND },
                { "The quick brown fox jumps over the lazy dog",
                        "6eece560a2e8d6b919e81fe91b0e7156",
                        HavalAttributes.HAVAL_128_BIT,
                        HavalAttributes.HAVAL_4_ROUND } });
    }

    private final String actualHash;

    private final String expectedHash;

    private final String input;

    private final Integer rounds;

    private final Integer size;

    public HavalTest(String input, String expectedHash, Integer size,
            Integer rounds) {
        this.actualHash = "test";// new Haval(input, size,
                                 // rounds).digest().toString();
        this.input = input;
        this.expectedHash = expectedHash;
        this.size = size;
        this.rounds = rounds;
    }

    @Test
    public void testHashIsNotNull() {
        assertThat(actualHash, is(notNullValue()));
    }

    @Test
    public void testHashIsValid() {
        assertThat(actualHash, is(equalTo(expectedHash)));
    }

    @Test
    public void testPositiveScenarioOfAmountRounds() {
        new Haval(size, rounds);
    }

    @Test
    public void testPositiveScenarioOfOutputSize() {
        new Haval(HavalAttributes.HAVAL_128_BIT, rounds);
    }

    @Test(
            expected = IllegalArgumentException.class)
    public void testThrowsIfInputIsNull() {
        new Haval(null, size, rounds);
    }

    @Test(
            expected = IllegalArgumentException.class)
    public void testThrowsIfRoundsIsWrong() {
        new Haval(size, -1);
    }

    @Test(
            expected = IllegalArgumentException.class)
    public void testThrowsIfSizeIsWrong() {
        new Haval(HavalAttributes.HAVAL_128_BIT - 1, rounds);
    }

}

@@ -1442,248 +1442,699 @@
     
-this.actualHash = %22test%22;// new Haval(input, size,%0A                                 // rounds).digest().toString();%0A        this.input = input;%0A        this.expectedHash = expectedHash;%0A        this.size = size;%0A        this.rounds = rounds
+// com.m4gik.test.Haval test = new com.m4gik.test.Haval(size, rounds);%0A        // test.update(input.getBytes());%0A        // this.actualHash = Util.toString(test.digest()).toLowerCase();%0A        this.actualHash = new Haval(input.getBytes(), size, rounds).digest()%0A                .toString();%0A        this.input = input;%0A        this.expectedHash = expectedHash;%0A        this.size = size;%0A        this.rounds = rounds;%0A    %7D%0A%0A    @Test%0A    public void testCheckStaticHashing() %7B%0A        // When%0A        String hash = Haval.hash(input.getBytes(),%0A                HavalAttributes.HAVAL_128_BIT, HavalAttributes.HAVAL_3_ROUND);%0A        // Then%0A        assertThat(hash, is(equalTo(expectedHash)))
 ;%0A  

Create TDD test for static methods.