Refine search
@Override public boolean equals(@Nullable Object obj) { if (obj instanceof NotPredicate) { NotPredicate<?> that = (NotPredicate<?>) obj; return predicate.equals(that.predicate); } return false; }
@Override public void forEach(Consumer<? super E> action) { checkNotNull(action); unfiltered.forEach( (E e) -> { if (predicate.test(e)) { action.accept(e); } }); }
@Test(dependsOnMethods = { "testApplyTag", "testApplyTagWithValue" }) protected void testList() { assertTrue(retry(new Predicate<Iterable<Tag>>() { public boolean apply(Iterable<Tag> input) { return api().list().filter(new Predicate<Tag>() { @Override public boolean apply(Tag in) { return in.getResourceId().equals(resource.id); } }).toSet().equals(input); } }, 600, 200, 200, MILLISECONDS).apply(ImmutableSet.of(tag, tag2))); }
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone") void testCreateSnapshotInRegion() { Snapshot snapshot = client.createSnapshotInRegion(defaultRegion, volumeId); Predicate<Snapshot> snapshotted = retry(new SnapshotCompleted(client), 600, 10, SECONDS); assert snapshotted.apply(snapshot); Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegion(defaultRegion, snapshotIds(snapshot.getId()))); assertEquals(result.getProgress(), 100); this.snapshot = result; }
@Test public void testStopAndStartServer() throws Exception { assertTrue(serverStatusChecker.apply(Server.State.RUNNING)); serverApi.stop(serverId); assertTrue(serverStatusChecker.apply(Server.State.STOPPED)); serverApi.start(serverId); assertTrue(serverStatusChecker.apply(Server.State.RUNNING)); }
@Test public void testTemplateIsReady() { assertTrue(isReady().apply( Template.builder().id("a").ready(true).build() )); assertFalse(isReady().apply( Template.builder().id("b").ready(false).build() )); }
@Test public void testListImages() { Iterable<org.jclouds.cloudstack.domain.Template> templates = adapter.listImages(); assertFalse(Iterables.isEmpty(templates)); for (org.jclouds.cloudstack.domain.Template template : templates) { assert TemplatePredicates.isReady().apply(template) : template; } }
@Test void testRetryAlwaysFalseMillis() { // maxWait=3; period=1; maxPeriod defaults to 1*10 // will call at 0, 1, 1+(1*1.5), 3 RepeatedAttemptsPredicate rawPredicate = new RepeatedAttemptsPredicate(Integer.MAX_VALUE); Predicate<String> predicate = retry(rawPredicate, 3, 1, SECONDS); stopwatch.start(); assertFalse(predicate.apply("")); long duration = stopwatch.elapsed(MILLISECONDS); assertOrdered(3000 - EARLY_RETURN_GRACE, duration, 3000 + SLOW_BUILD_SERVER_GRACE); assertCallTimes(rawPredicate.callTimes, 0, 1000, 1000 + 1500, 3000); }
@Test public void testTypeEqualsWhenNotEqual() { assertFalse(typeEqualTo(Type.SECONDARY).apply(zone)); } }
@Override public E last() { SortedSet<E> sortedUnfiltered = (SortedSet<E>) unfiltered; while (true) { E element = sortedUnfiltered.last(); if (predicate.apply(element)) { return element; } sortedUnfiltered = sortedUnfiltered.headSet(element); } } }
protected void assertEventuallyImageStateEquals(ServerImage image, final ServerImageState state) { assertTrue(retry(new Predicate<ServerImage>() { public boolean apply(ServerImage input) { return Iterables.getOnlyElement(api.getImageServices().getImagesById(input.getId())) .getState() == state; } }, 600, 1, SECONDS).apply(image)); } }
@Test public void testFilterWhenNotFound() { assertTrue(retry(new Predicate<Iterable<Subnet>>() { public boolean apply(Iterable<Subnet> input) { return api().filter(new SubnetFilterBuilder().subnetId("subnet-pants").build()) .toSet().equals(input); } }, 600, 200, 200, MILLISECONDS).apply(ImmutableSet.<Subnet> of())); }
@Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone") void testCreateSnapshotInRegion() { Snapshot snapshot = client.createSnapshotInRegion(defaultRegion, volumeId); Predicate<Snapshot> snapshotted = retry(new SnapshotCompleted(client), 600, 10, SECONDS); assert snapshotted.apply(snapshot); Snapshot result = Iterables.getOnlyElement(client.describeSnapshotsInRegion(snapshot.getRegion(), snapshotIds(snapshot.getId()))); assertEquals(result.getProgress(), 100); this.snapshot = result; }
@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)); }
@Test public void testMatchApiKey() { assertTrue(apiKeyEquals("random-text").apply( User.builder().id("random-id").apiKey("random-text").build() )); assertFalse(apiKeyEquals("something-different").apply( User.builder().id("random-id").apiKey("random-text").build() )); }
@Test public void testListImages() { Iterable<org.jclouds.cloudstack.domain.Template> templates = adapter.listImages(); assertFalse(Iterables.isEmpty(templates)); for (org.jclouds.cloudstack.domain.Template template : templates) { assert TemplatePredicates.isReady().apply(template) : template; } }