public void testSkip_illegalArgument() { try { FluentIterable.from(asList("a", "b", "c")).skip(-1); fail("Skipping negative number of elements should throw IllegalArgumentException."); } catch (IllegalArgumentException expected) { } }
public void testTransformWith_poorlyBehavedTransform() { List<String> input = asList("1", null, "3"); Iterable<Integer> iterable = FluentIterable.from(input).transform(new IntegerValueOfFunction()); Iterator<Integer> resultIterator = iterable.iterator(); resultIterator.next(); try { resultIterator.next(); fail("Transforming null to int should throw NumberFormatException"); } catch (NumberFormatException expected) { } }
public void testFirst_null() { List<String> list = Lists.newArrayList(null, "a", "b"); try { FluentIterable.from(list).first(); fail(); } catch (NullPointerException expected) { } }
public void testLimit_illegalArgument() { try { FluentIterable<String> unused = FluentIterable.from(Lists.newArrayList("a", "b", "c")).limit(-1); fail("Passing negative number to limit(...) method should throw IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testConcatNullPointerException() { List<Integer> list1 = newArrayList(1); List<Integer> list2 = newArrayList(4); try { FluentIterable.concat(list1, null, list2); fail(); } catch (NullPointerException expected) { } }
public void testAppend_nullPointerException() { try { FluentIterable<Integer> unused = FluentIterable.<Integer>from(asList(1, 2)).append((List<Integer>) null); fail("Appending null iterable should throw NPE."); } catch (NullPointerException expected) { } }
public void testLast_null() { List<String> list = Lists.newArrayList("a", "b", null); try { FluentIterable.from(list).last(); fail(); } catch (NullPointerException expected) { } }
public void testUniqueIndex_duplicateKey() { try { ImmutableMap<Integer, String> unused = FluentIterable.from(asList("one", "two", "three", "four")) .uniqueIndex( new Function<String, Integer>() { @Override public Integer apply(String input) { return input.length(); } }); fail(); } catch (IllegalArgumentException expected) { } }
public void testFromArrayAndIteratorRemove() { FluentIterable<TimeUnit> units = FluentIterable.from(TimeUnit.values()); try { Iterables.removeIf(units, Predicates.equalTo(TimeUnit.SECONDS)); fail("Expected an UnsupportedOperationException to be thrown but it wasn't."); } catch (UnsupportedOperationException expected) { } }
public void testUniqueIndex_nullValue() { try { ImmutableMap<Object, Integer> unused = fluent(1, null, 2) .uniqueIndex( new Function<Integer, Object>() { @Override public Object apply(@Nullable Integer input) { return String.valueOf(input); } }); fail(); } catch (NullPointerException expected) { } }
public void testToMap_nullKey() { try { fluent(1, null, 2).toMap(Functions.constant("foo")); fail(); } catch (NullPointerException expected) { } }
public void testUniqueIndex_nullKey() { try { fluent(1, 2, 3).uniqueIndex(Functions.constant(null)); fail(); } catch (NullPointerException expected) { } }
public void testToMap_nullValue() { try { fluent(1, 2, 3).toMap(Functions.constant(null)); fail(); } catch (NullPointerException expected) { } }
public void testIndex_nullKey() { try { ImmutableListMultimap<Object, Integer> unused = fluent(1, 2, 3).index(Functions.constant(null)); fail(); } catch (NullPointerException expected) { } }
public void testIndex_nullValue() { try { ImmutableListMultimap<String, Integer> unused = fluent(1, null, 2).index(Functions.constant("foo")); fail(); } catch (NullPointerException expected) { } }
public void testFirst_null() { List<String> list = Lists.newArrayList(null, "a", "b"); try { FluentIterable.from(list).first(); fail(); } catch (NullPointerException expected) { } }
public void testIndex_nullValue() { try { ImmutableListMultimap<String, Integer> unused = fluent(1, null, 2).index(Functions.constant("foo")); fail(); } catch (NullPointerException expected) { } }
public void testToMap_nullKey() { try { fluent(1, null, 2).toMap(Functions.constant("foo")); fail(); } catch (NullPointerException expected) { } }