Exemplo n.º 1
0
  @Test
  public void partitionWith() {
    ImmutableBag<String> strings = this.newBag();
    PartitionImmutableBag<String> partition =
        strings.partitionWith(Predicates2.<String>greaterThan(), "0");
    Assert.assertEquals(strings, partition.getSelected());
    Verify.assertIterableEmpty(partition.getRejected());

    Verify.assertIterableSize(
        strings.size() - 1,
        strings.partitionWith(Predicates2.<String>greaterThan(), "1").getSelected());
  }
Exemplo n.º 2
0
  @Test
  public void rejectWithToTarget() {
    ImmutableBag<String> strings = this.newBag();
    Assert.assertEquals(strings, strings.reject(Predicates.lessThan("0")));

    Verify.assertEmpty(
        strings.rejectWith(Predicates2.<String>greaterThan(), "0", FastList.<String>newList()));
  }
 @Test
 public void noneSatisfyWithOver100() {
   ArrayList<Integer> list = new ArrayList<Integer>(Interval.oneTo(101));
   Assert.assertFalse(
       ArrayListIterate.noneSatisfyWith(list, Predicates2.instanceOf(), Integer.class));
   Predicate2<Integer, Integer> greaterThanPredicate = Predicates2.greaterThan();
   Assert.assertTrue(ArrayListIterate.noneSatisfyWith(list, greaterThanPredicate, 150));
 }
 @Test
 public void allSatisfyWith() {
   ArrayList<Integer> list = this.getIntegerList();
   Assert.assertTrue(
       ArrayListIterate.allSatisfyWith(list, Predicates2.instanceOf(), Integer.class));
   Predicate2<Integer, Integer> greaterThanPredicate = Predicates2.greaterThan();
   Assert.assertFalse(ArrayListIterate.allSatisfyWith(list, greaterThanPredicate, 2));
 }
Exemplo n.º 5
0
  @Test
  public void selectWithToTarget() {
    ImmutableBag<String> strings = this.newBag();

    Assert.assertEquals(
        strings,
        strings
            .selectWith(Predicates2.<String>greaterThan(), "0", FastList.<String>newList())
            .toBag());
  }
 @Override
 @Test
 public void detectWith() {
   Assert.assertNull(this.newBag().detectWith(Predicates2.<String>greaterThan(), "3"));
 }
Exemplo n.º 7
0
  @Test
  public void selectWith() {
    ImmutableBag<String> strings = this.newBag();

    Assert.assertEquals(strings, strings.selectWith(Predicates2.<String>greaterThan(), "0"));
  }