private static <T> String toKeyPath(Iterable<PathAwareVisitor.PathElement<T>> currentPath) { return PATH_ELEMENTS_JOINER.join(from(currentPath).transform(PathElementToComponentAsString.INSTANCE).skip(1)); }
public void testSkip_skipNoneList() { Collection<String> list = Lists.newArrayList("a", "b"); assertEquals( Lists.newArrayList("a", "b"), Lists.newArrayList(FluentIterable.from(list).skip(0))); }
@Override protected Iterator<Integer> newTargetIterator() { Collection<Integer> collection = Sets.newLinkedHashSet(); Collections.addAll(collection, 1, 2, 3); return FluentIterable.from(collection).skip(1).iterator(); } }.test();
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 testSkip_pastEndList() { Collection<String> list = Lists.newArrayList("a", "b"); assertEquals(Collections.emptyList(), Lists.newArrayList(FluentIterable.from(list).skip(20))); }
public void testSkip_skipNone() { Collection<String> set = ImmutableSet.of("a", "b"); assertEquals( Lists.newArrayList("a", "b"), Lists.newArrayList(FluentIterable.from(set).skip(0))); }
@Override protected Iterator<Integer> newTargetIterator() { return FluentIterable.from(Lists.newArrayList(1, 2, 3)).skip(1).iterator(); } }.test();
public void testSkip_structurallyModifiedSkipAllList() throws Exception { List<String> list = Lists.newArrayList("a", "b", "c"); FluentIterable<String> tail = FluentIterable.from(list).skip(2); list.subList(0, 2).clear(); assertThat(tail).isEmpty(); }
public void testSkip_pastEnd() { Collection<String> set = ImmutableSet.of("a", "b"); assertEquals(Collections.emptyList(), Lists.newArrayList(FluentIterable.from(set).skip(20))); }
public void testSkip_structurallyModifiedSkipSome() throws Exception { Collection<String> set = Sets.newLinkedHashSet(); Collections.addAll(set, "a", "b", "c"); FluentIterable<String> tail = FluentIterable.from(set).skip(1); set.remove("b"); set.addAll(Lists.newArrayList("X", "Y", "Z")); assertThat(tail).containsExactly("c", "X", "Y", "Z").inOrder(); }
public void testSkip_structurallyModifiedSkipAll() throws Exception { Collection<String> set = Sets.newLinkedHashSet(); Collections.addAll(set, "a", "b", "c"); FluentIterable<String> tail = FluentIterable.from(set).skip(2); set.remove("a"); set.remove("b"); assertFalse(tail.iterator().hasNext()); }
public void testSkip_structurallyModifiedSkipSomeList() throws Exception { List<String> list = Lists.newArrayList("a", "b", "c"); FluentIterable<String> tail = FluentIterable.from(list).skip(1); list.subList(1, 3).clear(); list.addAll(0, Lists.newArrayList("X", "Y", "Z")); assertThat(tail).containsExactly("Y", "Z", "a").inOrder(); }
public void testSkip_nonStructurallyModifiedList() throws Exception { List<String> list = Lists.newArrayList("a", "b", "c"); FluentIterable<String> tail = FluentIterable.from(list).skip(1); Iterator<String> tailIterator = tail.iterator(); list.set(2, "c2"); assertEquals("b", tailIterator.next()); assertEquals("c2", tailIterator.next()); assertFalse(tailIterator.hasNext()); }
public void testSkip_skipNone() { Collection<String> set = ImmutableSet.of("a", "b"); assertEquals(Lists.newArrayList("a", "b"), Lists.newArrayList(FluentIterable.from(set).skip(0))); }
@Override protected Iterator<Integer> newTargetIterator() { Collection<Integer> collection = Sets.newLinkedHashSet(); Collections.addAll(collection, 1, 2, 3); return FluentIterable.from(collection).skip(1).iterator(); } }.test();
public void testSkip_skipNoneList() { Collection<String> list = Lists.newArrayList("a", "b"); assertEquals(Lists.newArrayList("a", "b"), Lists.newArrayList(FluentIterable.from(list).skip(0))); }
public void testSkip_structurallyModifiedSkipAllList() throws Exception { List<String> list = Lists.newArrayList("a", "b", "c"); FluentIterable<String> tail = FluentIterable.from(list).skip(2); list.subList(0, 2).clear(); assertThat(tail).isEmpty(); }