Search in sources :

Example 66 with Predicate

use of java.util.function.Predicate in project assertj-core by joel-costigliola.

the class LongPredicateAssert_accepts_Test method should_pass_when_predicate_accepts_all_values.

@Test
public void should_pass_when_predicate_accepts_all_values() {
    LongPredicate predicate = val -> val <= 2;
    assertThat(predicate).accepts(1L, 2L);
}
Also used : LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PredicateDescription(org.assertj.core.presentation.PredicateDescription) FailureMessages.actualIsNull(org.assertj.core.util.FailureMessages.actualIsNull) Test(org.junit.Test) LongPredicate(java.util.function.LongPredicate) ShouldAccept.shouldAccept(org.assertj.core.error.ShouldAccept.shouldAccept) LongPredicateAssert(org.assertj.core.api.LongPredicateAssert) Lists.newArrayList(org.assertj.core.util.Lists.newArrayList) ElementsShouldMatch.elementsShouldMatch(org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch) Mockito.verify(org.mockito.Mockito.verify) LongPredicate(java.util.function.LongPredicate) LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Test(org.junit.Test)

Example 67 with Predicate

use of java.util.function.Predicate in project assertj-core by joel-costigliola.

the class LongPredicateAssert_accepts_Test method should_fail_when_predicate_does_not_accept_value_with_string_description.

@Test
public void should_fail_when_predicate_does_not_accept_value_with_string_description() {
    LongPredicate predicate = val -> val <= 2;
    Predicate<Long> wrapPredicate = predicate::test;
    long expectedValue = 3;
    thrown.expectAssertionError("[test] " + shouldAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
    assertThat(predicate).as("test").accepts(expectedValue);
}
Also used : LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PredicateDescription(org.assertj.core.presentation.PredicateDescription) FailureMessages.actualIsNull(org.assertj.core.util.FailureMessages.actualIsNull) Test(org.junit.Test) LongPredicate(java.util.function.LongPredicate) ShouldAccept.shouldAccept(org.assertj.core.error.ShouldAccept.shouldAccept) LongPredicateAssert(org.assertj.core.api.LongPredicateAssert) Lists.newArrayList(org.assertj.core.util.Lists.newArrayList) ElementsShouldMatch.elementsShouldMatch(org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch) Mockito.verify(org.mockito.Mockito.verify) LongPredicate(java.util.function.LongPredicate) LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Test(org.junit.Test)

Example 68 with Predicate

use of java.util.function.Predicate in project assertj-core by joel-costigliola.

the class LongPredicateAssert_accepts_Test method should_fail_when_predicate_does_not_accept_value.

@Test
public void should_fail_when_predicate_does_not_accept_value() {
    LongPredicate predicate = val -> val <= 2;
    Predicate<Long> wrapPredicate = predicate::test;
    long expectedValue = 3;
    thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
    assertThat(predicate).accepts(expectedValue);
}
Also used : LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PredicateDescription(org.assertj.core.presentation.PredicateDescription) FailureMessages.actualIsNull(org.assertj.core.util.FailureMessages.actualIsNull) Test(org.junit.Test) LongPredicate(java.util.function.LongPredicate) ShouldAccept.shouldAccept(org.assertj.core.error.ShouldAccept.shouldAccept) LongPredicateAssert(org.assertj.core.api.LongPredicateAssert) Lists.newArrayList(org.assertj.core.util.Lists.newArrayList) ElementsShouldMatch.elementsShouldMatch(org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch) Mockito.verify(org.mockito.Mockito.verify) LongPredicate(java.util.function.LongPredicate) LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Test(org.junit.Test)

Example 69 with Predicate

use of java.util.function.Predicate in project assertj-core by joel-costigliola.

the class LongPredicateAssert_accepts_Test method should_fail_when_predicate_does_not_accept_values.

@Test
public void should_fail_when_predicate_does_not_accept_values() {
    LongPredicate predicate = val -> val <= 2;
    long[] matchValues = new long[] { 1L, 2L, 3L };
    thrown.expectAssertionError(elementsShouldMatch(matchValues, 3L, PredicateDescription.GIVEN).create());
    assertThat(predicate).accepts(matchValues);
}
Also used : LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PredicateDescription(org.assertj.core.presentation.PredicateDescription) FailureMessages.actualIsNull(org.assertj.core.util.FailureMessages.actualIsNull) Test(org.junit.Test) LongPredicate(java.util.function.LongPredicate) ShouldAccept.shouldAccept(org.assertj.core.error.ShouldAccept.shouldAccept) LongPredicateAssert(org.assertj.core.api.LongPredicateAssert) Lists.newArrayList(org.assertj.core.util.Lists.newArrayList) ElementsShouldMatch.elementsShouldMatch(org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch) Mockito.verify(org.mockito.Mockito.verify) LongPredicate(java.util.function.LongPredicate) LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Test(org.junit.Test)

Example 70 with Predicate

use of java.util.function.Predicate in project assertj-core by joel-costigliola.

the class LongPredicateAssert_rejects_Test method should_fail_when_predicate_accepts_value.

@Test
public void should_fail_when_predicate_accepts_value() {
    LongPredicate predicate = val -> val <= 2;
    Predicate<Long> wrapPredicate = predicate::test;
    long expectedValue = 2;
    thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
    assertThat(predicate).rejects(expectedValue);
}
Also used : LongStream(java.util.stream.LongStream) LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) NoElementsShouldMatch.noElementsShouldMatch(org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch) Predicate(java.util.function.Predicate) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) PredicateDescription(org.assertj.core.presentation.PredicateDescription) ShouldNotAccept.shouldNotAccept(org.assertj.core.error.ShouldNotAccept.shouldNotAccept) FailureMessages.actualIsNull(org.assertj.core.util.FailureMessages.actualIsNull) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) LongPredicate(java.util.function.LongPredicate) LongPredicateAssert(org.assertj.core.api.LongPredicateAssert) Lists.newArrayList(org.assertj.core.util.Lists.newArrayList) TextDescription(org.assertj.core.description.TextDescription) LongPredicate(java.util.function.LongPredicate) LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Test(org.junit.Test)

Aggregations

Predicate (java.util.function.Predicate)589 List (java.util.List)266 ArrayList (java.util.ArrayList)170 Collectors (java.util.stream.Collectors)167 Map (java.util.Map)164 Set (java.util.Set)137 Test (org.junit.Test)133 IOException (java.io.IOException)122 Collections (java.util.Collections)118 Arrays (java.util.Arrays)110 HashMap (java.util.HashMap)105 Collection (java.util.Collection)93 Optional (java.util.Optional)87 HashSet (java.util.HashSet)85 Stream (java.util.stream.Stream)69 Function (java.util.function.Function)61 File (java.io.File)60 Iterator (java.util.Iterator)55 Logger (org.slf4j.Logger)53 LoggerFactory (org.slf4j.LoggerFactory)52