Search in sources :

Example 1 with EagerFailingCallback

use of org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback in project pentaho-platform by pentaho.

the class ActionHarnessTest method testSetValueWithFormatter.

@Test
public void testSetValueWithFormatter() throws Exception {
    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness(action1);
    PropertyNameFormatter f = new PropertyNameFormatter() {

        public String format(String name) {
            return "message";
        }
    };
    harness1.setValue("THISWILLGETCLOBBERED", "test message action1", new EagerFailingCallback(), f);
    Assert.assertEquals("test message action1", harness1.getValue("message"));
}
Also used : PropertyNameFormatter(org.pentaho.platform.util.beans.PropertyNameFormatter) ActionHarness(org.pentaho.platform.util.beans.ActionHarness) EagerFailingCallback(org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback) Test(org.junit.Test)

Example 2 with EagerFailingCallback

use of org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback in project pentaho-platform by pentaho.

the class ActionHarnessTest method testSetValueFailedConvertWitNonNullValue.

@Test(expected = Exception.class)
public void testSetValueFailedConvertWitNonNullValue() throws Exception {
    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness(action1);
    harness1.setValue("count", new CustomParamType(), new EagerFailingCallback());
}
Also used : ActionHarness(org.pentaho.platform.util.beans.ActionHarness) EagerFailingCallback(org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback) Test(org.junit.Test)

Example 3 with EagerFailingCallback

use of org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback in project pentaho-platform by pentaho.

the class ActionHarnessTest method testSetNullIsSkippedWithNotError.

@Test
public void testSetNullIsSkippedWithNotError() throws Exception {
    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness(action1);
    // commons bBeanutils will throw exception if you try to type convert a null value. Pentaho BeanUtil
    // will skip the set operation altogether if you try to set a null value on a bean. This test ensures
    // that no exception is thrown in this case. The correct behavior is a message will be logged indicating
    // that the null value could not be set. I don't consider this a "real" type conversion problem like
    // a text string failing conversion to a Long type.. this type of conversion will still fail.
    harness1.setValue("count", null, new EagerFailingCallback());
    // If no exception thrown, then the test is essentially passed. We'll double check that
    // count was not set as well.
    Assert.assertNull("count property should remain null since null set value ops should be skipped", action1.getCount());
}
Also used : ActionHarness(org.pentaho.platform.util.beans.ActionHarness) EagerFailingCallback(org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback) Test(org.junit.Test)

Example 4 with EagerFailingCallback

use of org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback in project pentaho-platform by pentaho.

the class ActionHarnessTest method testSetValueNonExistentProperty.

@Test(expected = IllegalAccessException.class)
public void testSetValueNonExistentProperty() throws Exception {
    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness(action1);
    harness1.setValue("THISPROPERTYDOESNOTEXIST", "", new EagerFailingCallback());
    Assert.assertEquals("test message action1", harness1.getValue("message"));
}
Also used : ActionHarness(org.pentaho.platform.util.beans.ActionHarness) EagerFailingCallback(org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback) Test(org.junit.Test)

Example 5 with EagerFailingCallback

use of org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback in project pentaho-platform by pentaho.

the class ActionHarnessTest method testSetValueWithFormatterNonExistentProperty.

@Test(expected = IllegalAccessException.class)
public void testSetValueWithFormatterNonExistentProperty() throws Exception {
    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness(action1);
    PropertyNameFormatter f = new PropertyNameFormatter() {

        public String format(String name) {
            return "THISPROPERTYDOESNOTEXIST";
        }
    };
    harness1.setValue("THISWILLGETCLOBBERED", "test message action1", new EagerFailingCallback(), f);
}
Also used : PropertyNameFormatter(org.pentaho.platform.util.beans.PropertyNameFormatter) ActionHarness(org.pentaho.platform.util.beans.ActionHarness) EagerFailingCallback(org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 ActionHarness (org.pentaho.platform.util.beans.ActionHarness)5 EagerFailingCallback (org.pentaho.platform.util.beans.BeanUtil.EagerFailingCallback)5 PropertyNameFormatter (org.pentaho.platform.util.beans.PropertyNameFormatter)2