Search in sources :

Example 11 with LongPredicate

use of java.util.function.LongPredicate 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 12 with LongPredicate

use of java.util.function.LongPredicate 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)

Example 13 with LongPredicate

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

the class LongPredicateAssert_rejects_Test method should_fail_when_predicate_accepts_some_value.

@Test
public void should_fail_when_predicate_accepts_some_value() {
    LongPredicate predicate = num -> num <= 2;
    long[] matchValues = new long[] { 1L, 2L, 3L };
    List<Long> matchValuesList = LongStream.of(matchValues).boxed().collect(Collectors.toList());
    thrown.expectAssertionError(noElementsShouldMatch(matchValuesList, 1L, PredicateDescription.GIVEN).create());
    assertThat(predicate).rejects(matchValues);
}
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)

Example 14 with LongPredicate

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

the class LongPredicateAssert_rejects_Test method should_fail_when_predicate_accepts_value_with_description.

@Test
public void should_fail_when_predicate_accepts_value_with_description() {
    LongPredicate predicate = val -> val <= 2;
    Predicate<Long> wrapPredicate = predicate::test;
    long expectedValue = 2;
    thrown.expectAssertionError("[test] " + shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
    assertThat(predicate).as(new TextDescription("test")).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) TextDescription(org.assertj.core.description.TextDescription) LongPredicate(java.util.function.LongPredicate) LongPredicateAssertBaseTest(org.assertj.core.api.LongPredicateAssertBaseTest) Test(org.junit.Test)

Example 15 with LongPredicate

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

the class LongPredicateAssert_rejects_Test method should_pass_when_predicate_accepts_no_value.

@Test
public void should_pass_when_predicate_accepts_no_value() {
    LongPredicate predicate = num -> num <= 2;
    assertThat(predicate).rejects(3L, 4L, 5L);
}
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

LongPredicate (java.util.function.LongPredicate)21 Predicate (java.util.function.Predicate)14 Test (org.junit.Test)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 LongPredicateAssert (org.assertj.core.api.LongPredicateAssert)10 LongPredicateAssertBaseTest (org.assertj.core.api.LongPredicateAssertBaseTest)10 PredicateDescription (org.assertj.core.presentation.PredicateDescription)10 FailureMessages.actualIsNull (org.assertj.core.util.FailureMessages.actualIsNull)10 Lists.newArrayList (org.assertj.core.util.Lists.newArrayList)10 Mockito.verify (org.mockito.Mockito.verify)10 List (java.util.List)9 File (java.io.File)4 URI (java.net.URI)4 URISyntaxException (java.net.URISyntaxException)4 OptionalDouble (java.util.OptionalDouble)4 OptionalLong (java.util.OptionalLong)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 DoublePredicate (java.util.function.DoublePredicate)4 IntPredicate (java.util.function.IntPredicate)4 Collectors (java.util.stream.Collectors)4