public int matchedSize() { return from(requests).filter(matched()).size(); }
private void validateMetrics(List<MeasureComputerWrapper> wrappers) { from(wrappers).transformAndConcat(ToInputMetrics.INSTANCE).filter(new ValidateInputMetric()).size(); from(wrappers).transformAndConcat(ToOutputMetrics.INSTANCE).filter(new ValidateOutputMetric()).size(); from(wrappers).filter(new ValidateUniqueOutputMetric()).size(); }
public void testSize2NonCollection() { Iterable<Integer> iterable = new Iterable<Integer>() { @Override public Iterator<Integer> iterator() { return asList(0, 1).iterator(); } }; assertEquals(2, FluentIterable.from(iterable).size()); }
public void testSize_collectionDoesntIterate() { List<Integer> nums = asList(1, 2, 3, 4, 5); List<Integer> collection = new ArrayList<Integer>(nums) { @Override public Iterator<Integer> iterator() { throw new AssertionFailedError("Don't iterate me!"); } }; assertEquals(5, FluentIterable.from(collection).size()); }
public void testSize1Collection() { assertEquals(1, FluentIterable.from(asList("a")).size()); }
private ResponseHandler getResponseHandler(final FluentIterable<ResponseHandler> handlers) { if (handlers.size() == 1) { return handlers.get(0); } return and(handlers); }
public void testSize0() { assertEquals(0, FluentIterable.<String>of().size()); }
@Override public boolean apply(ImmutableList<? extends Annotation> annotations) { if(annotations == null) { return false; } return FluentIterable.from(annotations) .transform(MoreAnnotations.EXTRACT_ANNOTATION_TYPE) .filter(Predicates.in(Arrays.asList(annotationTypes))) .size() == annotationTypes.length; } });
@Override public @Nonnull Channel getElementAt(int index) { if (index < 0 || index >= channels.size()) { throw new IndexOutOfBoundsException("No channel for index " + index); } return channels.get(index); }
public Method findMethod(List<Method> interceptorMethods, Class<? extends Annotation> step, Class<?> interceptorClass) { FluentIterable<Method> possibleMethods = FluentIterable.from(interceptorMethods).filter(hasStepAnnotation(step)); if (possibleMethods.size() > 1 && possibleMethods.allMatch(not(notSameClass(interceptorClass)))) { throw new IllegalStateException(String.format("%s - You should not have more than one @%s annotated method", interceptorClass.getCanonicalName(), step.getSimpleName())); } return possibleMethods.first().orNull(); }
@Test(dependsOnMethods = "testCreateEmail") public void testListAccounts() throws Exception { FluentIterable<EmailAccount> accounts = emailAccountApi.listDomain(testDomain); assertTrue(accounts.size() >= 1); }
@AfterClass(groups = { "integration", "live" }) public void tearDown() { int before = domainApi.list().size(); domainApi.delete(testDomain); assertTrue(domainCounter.apply(before - 1)); super.tearDown(); }
@AfterClass(groups = { "integration", "live" }) protected void tearDown() { int before = archiveApi.list().size(); archiveApi.delete(archiveUser); assertTrue(archiveCounter.apply(before - 1)); super.tearDown(); }
@Test public void testCreateArchive() throws Exception { try { archiveApi.delete(archiveUser); } catch(Exception ex) { } int before = archiveApi.list().size(); archiveApi.createWithCredentialsAndSize(archiveUser, "password", 10); assertTrue(archiveCounter.apply(before + 1)); }
public void run() { FluentIterable<URI> result = api.getQueueApiForRegion(region).list(); assertNotNull(result); assert result.size() >= 1 : result; assertTrue(result.contains(finalQ), finalQ + " not in " + result); } });
@Override protected void drawElement(int index, int xPosition, int yPosition, int rowHeight, @Nonnull BufferBuilder renderer) { if (index < 0 || index >= channels.size()) { return; } Channel c = getElementAt(index); int col = ColorUtil.getRGB(Color.white); parent.drawString(parent.getFontRenderer(), c.getName(), xPosition + margin, yPosition + margin / 2, col); if (!c.isPublic()) { IconEIO.map.render(IconEIO.LOCK_LOCKED, xPosition + width - 18, yPosition - 3, 16, 15, 0, true); } }
protected void listQueuesInRegion(String region) throws InterruptedException { FluentIterable<URI> allResults = api.getQueueApiForRegion(region).list(); assertNotNull(allResults); if (allResults.size() >= 1) { URI queue = getLast(allResults); assertQueueInList(region, queue); } }
protected void createDomain(String domain) { final DomainApi domainApi = api.getDomainApi(); int before = domainApi.list().size(); domainApi.create(domain); Predicate<Integer> result = retry(new Predicate<Integer>() { public boolean apply(Integer value) { return domainApi.list().size() == value.intValue(); } }, 30, 1, SECONDS); assertTrue(result.apply(before + 1)); }
protected void createDomain(String domain) { final DomainApi domainApi = api.getDomainApi(); int before = domainApi.list().size(); domainApi.create(domain); Predicate<Integer> result = retry(new Predicate<Integer>() { public boolean apply(Integer value) { return domainApi.list().size() == value.intValue(); } }, 30, 1, SECONDS); assertTrue(result.apply(before + 1)); }
@Test(dependsOnMethods = "testList") public void testDeleteTags() { // shouldn't delete with the incorrect values api().conditionallyDeleteFromResources(ImmutableMap.of(tag.getKey(), "FOO", tag2.getKey(), "FOO"), ImmutableSet.of(tag.getResourceId(), tag2.getResourceId())); assertEquals(tagsForResource().size(), 2); api().deleteFromResources(ImmutableSet.of(tag.getKey(), tag2.getKey()), ImmutableSet.of(tag.getResourceId(), tag2.getResourceId())); assertEquals(tagsForResource().size(), 0); Logger.getAnonymousLogger().info("tags deleted: " + tag + ", " + tag2); }