public void testConcatVarargs() { List<Integer> list1 = newArrayList(1); List<Integer> list2 = newArrayList(4); List<Integer> list3 = newArrayList(7, 8); List<Integer> list4 = newArrayList(9); List<Integer> list5 = newArrayList(10); @SuppressWarnings("unchecked") FluentIterable<Integer> result = FluentIterable.concat(list1, list2, list3, list4, list5); assertEquals(asList(1, 4, 7, 8, 9, 10), newArrayList(result)); assertEquals("[1, 4, 7, 8, 9, 10]", result.toString()); }
public void testFilter() { FluentIterable<String> filtered = FluentIterable.from(asList("foo", "bar")).filter(Predicates.equalTo("foo")); List<String> expected = Collections.singletonList("foo"); List<String> actual = Lists.newArrayList(filtered); assertEquals(expected, actual); assertCanIterateAgain(filtered); assertEquals("[foo]", filtered.toString()); }
public void testAppend() { FluentIterable<Integer> result = FluentIterable.<Integer>from(asList(1, 2, 3)).append(Lists.newArrayList(4, 5, 6)); assertEquals(asList(1, 2, 3, 4, 5, 6), Lists.newArrayList(result)); assertEquals("[1, 2, 3, 4, 5, 6]", result.toString()); result = FluentIterable.<Integer>from(asList(1, 2, 3)).append(4, 5, 6); assertEquals(asList(1, 2, 3, 4, 5, 6), Lists.newArrayList(result)); assertEquals("[1, 2, 3, 4, 5, 6]", result.toString()); }
public void testConcatIterable() { List<Integer> list1 = newArrayList(1); List<Integer> list2 = newArrayList(4); @SuppressWarnings("unchecked") List<List<Integer>> input = newArrayList(list1, list2); FluentIterable<Integer> result = FluentIterable.concat(input); assertEquals(asList(1, 4), newArrayList(result)); // Now change the inputs and see result dynamically change as well list1.add(2); List<Integer> list3 = newArrayList(3); input.add(1, list3); assertEquals(asList(1, 2, 3, 4), newArrayList(result)); assertEquals("[1, 2, 3, 4]", result.toString()); }
public void testSkip_simpleList() { Collection<String> list = Lists.newArrayList("a", "b", "c", "d", "e"); assertEquals( Lists.newArrayList("c", "d", "e"), Lists.newArrayList(FluentIterable.from(list).skip(2))); assertEquals("[c, d, e]", FluentIterable.from(list).skip(2).toString()); }
public void testSkip_simple() { Collection<String> set = ImmutableSet.of("a", "b", "c", "d", "e"); assertEquals( Lists.newArrayList("c", "d", "e"), Lists.newArrayList(FluentIterable.from(set).skip(2))); assertEquals("[c, d, e]", FluentIterable.from(set).skip(2).toString()); }
public void testLimit() { Iterable<String> iterable = Lists.newArrayList("foo", "bar", "baz"); FluentIterable<String> limited = FluentIterable.from(iterable).limit(2); assertEquals(ImmutableList.of("foo", "bar"), Lists.newArrayList(limited)); assertCanIterateAgain(limited); assertEquals("[foo, bar]", limited.toString()); }
public void testOfToString() { assertEquals("[yam, bam, jam, ham]", FluentIterable.of("yam", "bam", "jam", "ham").toString()); }
public void test() { InputStream is = getClass().getResourceAsStream("/describe_subnets.xml"); FluentIterable<Subnet> expected = expected(); DescribeSubnetsResponseHandler handler = injector.getInstance(DescribeSubnetsResponseHandler.class); FluentIterable<Subnet> result = factory.create(handler).parse(is); assertEquals(result.toString(), expected.toString()); } public FluentIterable<Subnet> expected() {
public void test() { InputStream is = getClass().getResourceAsStream("/describe_tags.xml"); FluentIterable<Tag> expected = expected(); DescribeTagsResponseHandler handler = injector.getInstance(DescribeTagsResponseHandler.class); FluentIterable<Tag> result = factory.create(handler).parse(is); assertEquals(result.toString(), expected.toString()); } public FluentIterable<Tag> expected() {
public void testListRecordsWhenResponseIs2xx() { UltraDNSWSApi success = requestSendsResponse(listRecords, listRecordsResponse); assertEquals(success.getDirectionalPoolApiForZone("jclouds.org.").listRecordsByDNameAndType("www.jclouds.org.", 1) .toString(), new GetDirectionalDNSRecordsForHostResponseTest().expected().toString()); } }
public void testListAccountLevelGroupsWhenResponseIs2xx() { UltraDNSWSApi success = requestSendsResponse(listAccountLevelGroups, listAccountLevelGroupsResponse); assertEquals(success.getDirectionalGroupApiForAccount("accountid").listAccountLevelGroups().toString(), new GetAccountLevelDirectionalGroupsResponseTest().expected().toString()); }
public void testListGroupNamesByRecordNameAndTypeWhenResponseIs2xx() { UltraDNSWSApi success = requestSendsResponse(listGroupNamesByRecordNameAndType, listGroupNamesByRecordNameAndTypeResponse); assertEquals(success.getDirectionalGroupApiForAccount("accountid").listGroupNamesByDNameAndType("www.jclouds.org.", 1).toString(), new GetAvailableGroupsResponseTest().expected().toString()); }
public void testListByFQDNWhenResponseIs2xx() { DynECTApi success = requestsSendResponses(createSession, createSessionResponse, listByFQDN, listResponse); assertEquals(success.getRecordApiForZone("jclouds.org").listByFQDN("www.foo.com").toString(), new ListRecordsResponseTest().expected().toString()); }
public void testListWhenResponseIs2xx() throws Exception { HttpResponse listResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResourceWithContentType("/describe_tags.xml", "text/xml")).build(); EC2Api apiWhenExist = requestSendsResponse( list, listResponse); assertEquals(apiWhenExist.getTagApi().get().list().toString(), new DescribeTagsResponseTest().expected().toString()); }