Ejemplo n.º 1
0
 @Test
 public void notIn() {
   MutableList<String> odds = Lists.fixedSize.of("1", "3");
   Assert.assertFalse(Predicates2.notIn().accept("1", odds));
   Assert.assertTrue(Predicates2.notIn().accept("2", odds));
   Assert.assertNotNull(Predicates2.notIn().toString());
   MutableList<String> list = Lists.fixedSize.of("1", "2");
   MutableList<String> newList = ListIterate.filterWith(list, Predicates2.notIn(), odds);
   Assert.assertEquals(FastList.newListWith("2"), newList);
 }
Ejemplo n.º 2
0
 @Test
 public void attributeNotIn() {
   Function<String, String> function = StringFunctions.toLowerCase();
   MutableList<String> lowerList = Lists.fixedSize.of("a", "b");
   Assert.assertFalse(Predicates2.attributeNotIn(function).accept("A", lowerList));
   Assert.assertTrue(Predicates2.attributeNotIn(function).accept("C", lowerList));
   MutableList<String> upperList = Lists.fixedSize.of("A", "C");
   MutableList<String> newList =
       ListIterate.filterNotWith(upperList, Predicates2.attributeNotIn(function), lowerList);
   Assert.assertEquals(FastList.newListWith("A"), newList);
 }
Ejemplo n.º 3
0
 @Test
 public void procedure2Success() {
   Procedure2<Object, Object> block =
       new CheckedProcedure2<Object, Object>() {
         @Override
         public void safeValue(Object argument1, Object argument2) {
           // nop
         }
       };
   ListIterate.forEachInBoth(mList("test"), mList("test"), block);
 }
Ejemplo n.º 4
0
 @Test(expected = RuntimeException.class)
 public void procedure2RuntimeException() {
   Procedure2<Object, Object> block =
       new CheckedProcedure2<Object, Object>() {
         @Override
         public void safeValue(Object argument1, Object argument2) {
           throw new RuntimeException();
         }
       };
   ListIterate.forEachInBoth(mList("test"), mList("test"), block);
 }
Ejemplo n.º 5
0
 @Test
 public void attributeIn_MultiTypes() {
   MutableList<String> stringInts = Lists.fixedSize.of("1", "2");
   Assert.assertTrue(Predicates2.attributeIn(Functions.getToString()).accept(1, stringInts));
   Assert.assertFalse(Predicates2.attributeIn(Functions.getToString()).accept(3, stringInts));
   Assert.assertFalse(Predicates2.attributeIn(Functions.getToString()).accept(3, stringInts));
   MutableList<Integer> intList = Lists.fixedSize.of(1, 3);
   MutableList<Integer> newList =
       ListIterate.filterWith(
           intList, Predicates2.attributeIn(Functions.getToString()), stringInts);
   Assert.assertEquals(FastList.newListWith(1), newList);
 }
Ejemplo n.º 6
0
 @Test
 public void attributeIn() {
   MutableList<String> upperList = Lists.fixedSize.of("A", "B");
   Assert.assertTrue(
       Predicates2.attributeIn(StringFunctions.toUpperCase()).accept("a", upperList));
   Assert.assertFalse(
       Predicates2.attributeIn(StringFunctions.toUpperCase()).accept("c", upperList));
   MutableList<String> lowerList = Lists.fixedSize.of("a", "c");
   MutableList<String> newList =
       ListIterate.filterWith(
           lowerList, Predicates2.attributeIn(StringFunctions.toUpperCase()), upperList);
   Assert.assertEquals(FastList.newListWith("a"), newList);
 }