brooklyn.test.EntityTestUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-test-support Show documentation
Show all versions of brooklyn-test-support Show documentation
Test support dependencies and classes
package brooklyn.test;
import static org.testng.Assert.assertEquals;
import java.util.Map;
import brooklyn.config.ConfigKey;
import brooklyn.entity.Entity;
import brooklyn.event.AttributeSensor;
import com.google.common.collect.Maps;
public class EntityTestUtils {
// TODO Delete methods from TestUtils, to just have them here (or switch so TestUtils delegates here,
// and deprecate methods in TestUtils until deleted).
public static void assertAttributeEquals(Entity entity, AttributeSensor attribute, T expected) {
assertEquals(entity.getAttribute(attribute), expected);
}
public static void assertConfigEquals(Entity entity, ConfigKey configKey, T expected) {
assertEquals(entity.getConfig(configKey), expected);
}
public static void assertAttributeEqualsEventually(final Entity entity, final AttributeSensor attribute, final T expected) {
assertAttributeEqualsEventually(Maps.newLinkedHashMap(), entity, attribute, expected);
}
public static void assertAttributeEqualsEventually(Map,?> flags, final Entity entity, final AttributeSensor attribute, final T expected) {
TestUtils.executeUntilSucceeds(flags, new Runnable() {
public void run() {
assertAttributeEquals(entity, attribute, expected);
}});
}
public static void assertAttributeEqualsContinually(final Entity entity, final AttributeSensor attribute, final T expected) {
assertAttributeEqualsContinually(Maps.newLinkedHashMap(), entity, attribute, expected);
}
public static void assertAttributeEqualsContinually(Map,?> flags, final Entity entity, final AttributeSensor attribute, final T expected) {
TestUtils.assertSucceedsContinually(new Runnable() {
public void run() {
assertAttributeEquals(entity, attribute, expected);
}});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy