Search in sources :

Example 1 with OptionalLong

use of com.annimon.stream.OptionalLong in project Lightweight-Stream-API by aNNiMON.

the class FindSingleTest method testFindSingleAfterFilteringToOneElementStream.

@Test
public void testFindSingleAfterFilteringToOneElementStream() {
    OptionalLong result = LongStream.of(5, 10, -15).filter(Functions.remainderLong(2)).findSingle();
    assertThat(result, hasValue(10L));
}
Also used : OptionalLong(com.annimon.stream.OptionalLong) Test(org.junit.Test)

Example 2 with OptionalLong

use of com.annimon.stream.OptionalLong in project Lightweight-Stream-API by aNNiMON.

the class OptionalLongMatcherTest method testHasValue.

@Test
public void testHasValue() {
    OptionalLong optional = OptionalLong.of(42);
    assertThat(optional, hasValue(42));
    assertThat(optional, not(hasValue(13)));
    assertThat(hasValue(42L), description(is("OptionalLong value is <42L>")));
}
Also used : OptionalLong(com.annimon.stream.OptionalLong) Test(org.junit.Test)

Example 3 with OptionalLong

use of com.annimon.stream.OptionalLong in project Lightweight-Stream-API by aNNiMON.

the class OptionalLongMatcherTest method testHasValueThat.

@Test
public void testHasValueThat() {
    OptionalLong optional = OptionalLong.of(42L);
    assertThat(optional, hasValueThat(is(not(17L))));
    assertThat(hasValueThat(is(42L)), description(is("OptionalLong value is <42L>")));
}
Also used : OptionalLong(com.annimon.stream.OptionalLong) Test(org.junit.Test)

Example 4 with OptionalLong

use of com.annimon.stream.OptionalLong in project Lightweight-Stream-API by aNNiMON.

the class OptionalLongMatcherTest method testIsEmpty.

@Test
public void testIsEmpty() {
    OptionalLong optional = OptionalLong.empty();
    assertThat(optional, isEmpty());
    assertThat(optional, not(isPresent()));
    assertThat(isEmpty(), description(is("OptionalLong value should be empty")));
}
Also used : OptionalLong(com.annimon.stream.OptionalLong) Test(org.junit.Test)

Example 5 with OptionalLong

use of com.annimon.stream.OptionalLong in project Lightweight-Stream-API by aNNiMON.

the class FindSingleTest method testFindSingleAfterFilteringToEmptyStream.

@Test
public void testFindSingleAfterFilteringToEmptyStream() {
    OptionalLong result = LongStream.of(5, 7, 9).filter(Functions.remainderLong(2)).findSingle();
    assertThat(result, isEmpty());
}
Also used : OptionalLong(com.annimon.stream.OptionalLong) Test(org.junit.Test)

Aggregations

OptionalLong (com.annimon.stream.OptionalLong)8 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)2 CallParticipant (org.thoughtcrime.securesms.events.CallParticipant)2 MappingModel (org.thoughtcrime.securesms.util.adapter.mapping.MappingModel)2