package org.monospark.spongematchers.parser.primitive;

import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.monospark.spongematchers.testutil.HamcrestSpongeMatchers.matches;

import java.util.Optional;

import org.junit.Test;
import org.monospark.spongematchers.matcher.SpongeMatcher;
import org.monospark.spongematchers.parser.SpongeMatcherParseException;
import org.monospark.spongematchers.parser.SpongeMatcherParser;

public class BooleanMatcherTest {

    @Test
    public void parseMatcher_True_ReturnsCorrectMatcher() throws SpongeMatcherParseException {
        String input = "true";
        
        verifyMatcher(input, false, true);
    }
    
    @Test
    public void parseMatcher_False_ReturnsCorrectMatcher() throws SpongeMatcherParseException {
        String input = "false";
        
        verifyMatcher(input, true, false);
    }
    
    @Test
    public void parseMatcher_TrueAndFalse_ReturnsCorrectMatcher() throws SpongeMatcherParseException {
        String input1 = "true|false";
        String input2 = " true  | \t false ";
        
        verifyMatcher(input1, true, true);
        verifyMatcher(input2, true, true);
    }
    
    @Test
    public void parseMatcher_FalseAndTrue_ReturnsCorrectMatcher() throws SpongeMatcherParseException {
        String input1 = "false|true";
        String input2 = " false  | \t true ";
        
        verifyMatcher(input1, true, true);
        verifyMatcher(input2, true, true);
    }
    
    private void verifyMatcher(String input, boolean matchFalse, boolean matchTrue) throws SpongeMatcherParseException {
        Optional<SpongeMatcher<Boolean>> matcher = SpongeMatcherParser.BOOLEAN.parseMatcher(input);
        
        assertTrue(matcher.isPresent());
        assertThat(matcher.get(), matchFalse ? matches(false) : not(matches(false)));
        assertThat(matcher.get(), matchTrue ? matches(true) : not(matches(true)));
    }
}

@@ -704,250 +704,104 @@
     
-verifyMatcher(input, false, true);%0A    %7D%0A    %0A    @Test%0A    public void parseMatcher_False_ReturnsCorrectMatcher() throws SpongeMatcherParseException %7B%0A        String input = %22false%22;%0A        %0A        verifyMatcher(input, true, false
+Optional%3CSpongeMatcher%3CBoolean%3E%3E matcher = SpongeMatcherParser.BOOLEAN.parseMatcher(input
 );%0A    
-%7D%0A
     
@@ -809,251 +809,93 @@
     
-@Test%0A    public void parseMatcher_TrueAndFalse_ReturnsCorrectMatcher() throws SpongeMatcherParseException %7B%0A        String input1 = %22true%7Cfalse%22;%0A        String input2 = %22 true  %7C %5Ct false %22;%0A        %0A        verifyMatcher(input1, true, 
+    assertTrue(matcher.isPresent());%0A        assertThat(matcher.get(), matches(
 true)
+)
 ;%0A  
@@ -904,40 +904,53 @@
     
-verifyMatcher(input2, true, true
+assertThat(matcher.get(), not(matches(false))
 );%0A 
@@ -1007,15 +1007,8 @@
 alse
-AndTrue
 _Ret
@@ -1085,17 +1085,16 @@
 ng input
-1
  = %22fals
@@ -1098,13 +1098,8 @@
 alse
-%7Ctrue
 %22;%0A 
@@ -1109,272 +1109,8 @@
     
-String input2 = %22 false  %7C %5Ct true %22;%0A        %0A        verifyMatcher(input1, true, true);%0A        verifyMatcher(input2, true, true);%0A    %7D%0A    %0A    private void verifyMatcher(String input, boolean matchFalse, boolean matchTrue) throws SpongeMatcherParseException %7B
 %0A   
@@ -1299,51 +1299,16 @@
 atch
-False ? matches(false) : not(matches(false)
+es(false
 ));%0A
@@ -1344,36 +1344,8 @@
 t(),
- matchTrue ? matches(true) :
  not

Remove some useless unit tests