All Downloads are FREE. Search and download functionalities are using the official Maven repository.

brooklyn.test.EntityTestUtils Maven / Gradle / Ivy

There is a newer version: 0.7.0-M1
Show newest version
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