EntityAsserts { public static void assertGroupSizeEqualsEventually(final Group group, int expected) { assertGroupSizeEqualsEventually(ImmutableMap.of(), group, expected); }  static void assertAttributeEquals(Entity entity, AttributeSensor<T> attribute, T expected); static void assertConfigEquals(Entity entity, ConfigKey<T> configKey, T expected); static void assertAttributeEqualsEventually(final Entity entity, final AttributeSensor<T> attribute, final T expected); static void assertAttributeEqualsEventually(Map<?,?> flags, final Entity entity, final AttributeSensor<T> attribute, final T expected); static T assertAttributeEventuallyNonNull(final Entity entity, final AttributeSensor<T> attribute); static T assertAttributeEventuallyNonNull(Map<?,?> flags, final Entity entity, final AttributeSensor<T> attribute); static T assertAttributeEventually(final Entity entity, final AttributeSensor<T> attribute, Predicate<? super T> predicate); static T assertAttributeEventually(Map<?,?> flags, final Entity entity, final AttributeSensor<T> attribute, final Predicate<? super T> predicate); static T assertAttribute(final Entity entity, final AttributeSensor<T> attribute, final Predicate<? super T> predicate); static void assertPredicateEventuallyTrue(final T entity, final Predicate<? super T> predicate); static void assertPredicateEventuallyTrue(Map<?,?> flags, final T entity, final Predicate<? super T> predicate); static void assertAttributeEqualsContinually(final Entity entity, final AttributeSensor<T> attribute, final T expected); static void assertAttributeEqualsContinually(Map<?,?> flags, final Entity entity, final AttributeSensor<T> attribute, final T expected); static void assertGroupSizeEqualsEventually(final Group group, int expected); static void assertGroupSizeEqualsEventually(Map<?,?> flags, final Group group, final int expected); static void assertAttributeChangesEventually(final Entity entity, final AttributeSensor<?> attribute); @Beta @SafeVarargs static void assertAttributeContinuallyNotEqualTo(final Entity entity, final AttributeSensor<T> attribute, T... disallowed); @Beta @SafeVarargs static void assertAttributeContinuallyNotEqualTo(final Map<?, ?> flags, final Entity entity, final AttributeSensor<T> attribute, T... disallowed); static void assertEntityHealthy(Entity entity); static void assertEntityHealthyEventually(Entity entity); @Beta static void assertEntityFailed(Entity entity);  }
@Test public void shouldAssertGroupSizeEqualsEventually() throws Exception { stooges = app.createAndManageChild(EntitySpec.create(DynamicGroup.class)); final EntitySpec<TestEntity> stooge = EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, STOOGE); app.createAndManageChild(stooge); app.createAndManageChild(stooge); app.createAndManageChild(stooge); Task<?> assertValue1 = entity.getExecutionContext().submit("assert size", () -> EntityAsserts.assertGroupSizeEqualsEventually(ImmutableMap.of("timeout", "2s"), stooges, 3)); stooges.setEntityFilter(EntityPredicates.configEqualTo(TestEntity.CONF_NAME, STOOGE)); assertValue1.get(); Task<?> assertValue2 = entity.getExecutionContext().submit("assert size 0", () -> EntityAsserts.assertGroupSizeEqualsEventually(stooges, 0)); stooges.setEntityFilter(EntityPredicates.configEqualTo(TestEntity.CONF_NAME, "Marx Brother")); assertValue2.get(); }