package org.xander.queryAnswer;

import org.junit.Before;
import org.junit.Test;

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

public class QueryAnswerTest {
    String[] data = {"cat", "dog", "parrot"};
    private QueryAnswer queryAnswer;

    @Before
    public void setUp(){
        queryAnswer = new QueryAnswer(data);
    }

    @Test
    public void answerIfPresent() {
        String actualAnswer = queryAnswer.checkValuePresent("cat");
        assertEquals("yes", actualAnswer);
    }

    @Test
    public void answerIfNotPresent() {
        String actualAnswer = queryAnswer.checkValuePresent("elephant");
        assertEquals("no", actualAnswer);
    }

    @Test(expected = IllegalStateException.class)
    public void noAnswersPresent() {
        QueryAnswer queryAnswer = new QueryAnswer(new String[]{});
    }

    @Test(expected = IllegalArgumentException.class)
    public void questionNotCorrect() {
        QueryAnswer queryAnswer = new QueryAnswer(new String[]{"2"});
        queryAnswer.checkValuePresent(null);
    }

    @Test
    public void zeroLengthArgument() {
        QueryAnswer queryAnswer = new QueryAnswer(new String[]{"2"});
        assertEquals("no", queryAnswer.checkValuePresent(""));

    }

    @Test
    public void onePlaceHolder() {
        assertEquals("yes", queryAnswer.checkValuePresent("c*t"));
    }

    @Test
    public void onePlaceHolderLastPosition() {
        assertEquals("yes", queryAnswer.checkValuePresent("ca*"));
    }

    @Test
    public void twoPlaceHoldersLastPosition() {
        assertEquals("yes", queryAnswer.checkValuePresent("c**"));
    }

    @Test
    public void twoPlaceHoldersFirstPosition() {
        assertEquals("yes", queryAnswer.checkValuePresent("**t"));
    }

    @Test
    public void onePlaceHolderFirstPosition() {
        assertEquals("yes", queryAnswer.checkValuePresent("*at"));
    }

    @Test
    public void threePlaceHolders() {
        assertEquals("yes", queryAnswer.checkValuePresent("***"));
    }

    @Test
    public void fivePlaceHoldersNotPresent() {
        assertEquals("yes", queryAnswer.checkValuePresent("******"));
    }

    @Test
    public void fourPlaceHoldersNotPresent() {
        assertEquals("no", queryAnswer.checkValuePresent("****"));
    }

    @Test
    public void wrongWordNotPresent() {
        assertEquals("no", queryAnswer.checkValuePresent("catn"));
    }
}

@@ -116,159 +116,15 @@
 sert
-Array
 Equals;
-%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotEquals;%0Aimport static org.junit.Assert.assertNotNull;
 %0A%0Apu
@@ -758,34 +758,8 @@
     
- QueryAnswer queryAnswer =
  new
@@ -1191,32 +1191,423 @@
 t(%22%22));%0A%0A    %7D%0A%0A
+    @Test%0A    public void zeroLengthArgumentPresent() %7B%0A        QueryAnswer queryAnswer = new QueryAnswer(new String%5B%5D%7B%22%22%7D);%0A        assertEquals(%22yes%22, queryAnswer.checkValuePresent(%22%22));%0A    %7D%0A%0A    @Test%0A    public void emptySpaceArgument() %7B%0A        QueryAnswer queryAnswer = new QueryAnswer(new String%5B%5D%7B%22   %22%7D);%0A        assertEquals(%22yes%22, queryAnswer.checkValuePresent(%22   %22));%0A    %7D%0A%0A
     @Test%0A    pu

test modified