package com.dhemery.express;

import org.junit.Test;

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

public class ExpressionsSatisfiedThatTests {
    @Test
    public void withBooleanSupplier_returnsTrue_ifSupplierReturnsTrue() {
        boolean result = Expressions.satisfiedThat(() -> true);
        assertThat(result, is(true));
    }

    @Test
    public void withBooleanSupplier_returnsFalse_ifSupplierReturnsFalse() {
        boolean result = Expressions.satisfiedThat(() -> false);
        assertThat(result, is(false));
    }

    @Test
    public void withSubjectPredicate_returnsTrue_ifPredicateAcceptsSubject() {
        boolean result = Expressions.satisfiedThat("", String::isEmpty);
        assertThat(result, is(true));
    }

    @Test
    public void withSubjectPredicate_returnsFalse_ifPredicateRejectsSubject() {
        boolean result = Expressions.satisfiedThat("foo", String::isEmpty);
        assertThat(result, is(false));
    }

    @Test
    public void withSubjectMatcher_returnsTrue_ifMatcherAcceptsSubject() {
        boolean result = Expressions.satisfiedThat("foo", is("foo"));
        assertThat(result, is(true));
    }

    @Test
    public void withSubjectMatcher_returnsFalse_ifMatcherRejectsSubject() {
        boolean result = Expressions.satisfiedThat("foo", is("food"));
        assertThat(result, is(false));
    }

    @Test
    public void withSubjectFunctionMatcher_returnsTrue_ifMatcherAcceptsFunctionOfSubject() {
        boolean result = Expressions.satisfiedThat("foo", String::toUpperCase, is("FOO"));
        assertThat(result, is(true));
    }

    @Test
    public void withSubjectFunctionMatcher_returnsFalse_ifMatcherRejectsFunctionOfSubject() {
        boolean result = Expressions.satisfiedThat("foo", String::toUpperCase, is("foo"));
        assertThat(result, is(false));
    }

    @Test
    public void withSubjectFunctionPredicate_returnsTrue_ifPredicateAcceptsFunctionOfSubject() {
        boolean result = Expressions.satisfiedThat("foo", String::toUpperCase, "FOO"::equals);
        assertThat(result, is(true));
    }

    @Test
    public void withSubjectFunctionPredicate_returnsFalse_ifPredicateRejectsFunctionOfSubject() {
        boolean result = Expressions.satisfiedThat("foo", String::toUpperCase, "foo"::equals);
        assertThat(result, is(false));
    }
}

@@ -100,16 +100,61 @@
 rtThat;%0A
+import static org.hamcrest.Matchers.equalTo;%0A
 import s
@@ -231,16 +231,122 @@
 Tests %7B%0A
+    private static final String SUBJECT = %22foo%22;%0A    private static final String FUNCTION_VALUE = %22bar%22;%0A%0A
     @Tes
@@ -871,27 +871,26 @@
 hat(
-%22%22, String::isEmpty
+SUBJECT, s -%3E true
 );%0A 
@@ -1078,30 +1078,27 @@
 hat(
-%22foo%22, String::isEmpty
+SUBJECT, s -%3E false
 );%0A 
@@ -1282,23 +1282,32 @@
 hat(
-%22foo%22, is(%22foo%22
+SUBJECT, equalTo(SUBJECT
 ));%0A
@@ -1492,23 +1492,37 @@
 hat(
-%22foo%22, is(%22food
+SUBJECT, equalTo(SUBJECT + %22!
 %22));
@@ -1726,44 +1726,60 @@
 hat(
-%22foo%22, String::toUpperCase, is(%22FOO%22
+SUBJECT, s -%3E FUNCTION_VALUE, equalTo(FUNCTION_VALUE
 ));%0A
@@ -1982,43 +1982,65 @@
 hat(
-%22foo%22, String::toUpperCase, is(%22foo
+SUBJECT, s -%3E FUNCTION_VALUE, equalTo(FUNCTION_VALUE + %22!
 %22));
@@ -2248,49 +2248,47 @@
 hat(
-%22foo%22, String::toUpperCase, %22FOO%22::equals
+SUBJECT, s -%3E FUNCTION_VALUE, s -%3E true
 );%0A 
@@ -2494,49 +2494,48 @@
 hat(
-%22foo%22, String::toUpperCase, %22foo%22::equ
+SUBJECT, s -%3E FUNCTION_VALUE, s -%3E f
 als
+e
 );%0A 

Simplify ExpressionsSatisfiedThatTests