Search in sources :

Example 6 with DmnDataTypeTransformer

use of org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer in project camunda-engine-dmn by camunda.

the class DmnDataTypeTransformerTest method stringType.

@Test
public void stringType() {
    DmnDataTypeTransformer typeTransformer = registry.getTransformer("string");
    assertThat(typeTransformer.transform("abc"), is((TypedValue) Variables.stringValue("abc")));
    assertThat(typeTransformer.transform(true), is((TypedValue) Variables.stringValue("true")));
    assertThat(typeTransformer.transform(4), is((TypedValue) Variables.stringValue("4")));
    assertThat(typeTransformer.transform(2L), is((TypedValue) Variables.stringValue("2")));
    assertThat(typeTransformer.transform(4.2), is((TypedValue) Variables.stringValue("4.2")));
}
Also used : DmnDataTypeTransformer(org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 7 with DmnDataTypeTransformer

use of org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer in project camunda-engine-dmn by camunda.

the class DmnDataTypeTransformerTest method integerType.

@Test
public void integerType() {
    DmnDataTypeTransformer typeTransformer = registry.getTransformer("integer");
    assertThat(typeTransformer.transform(4), is((TypedValue) Variables.integerValue(4)));
    assertThat(typeTransformer.transform("4"), is((TypedValue) Variables.integerValue(4)));
    assertThat(typeTransformer.transform(2L), is((TypedValue) Variables.integerValue(2)));
    assertThat(typeTransformer.transform(4.0), is((TypedValue) Variables.integerValue(4)));
    assertThat(typeTransformer.transform(Integer.MIN_VALUE), is((TypedValue) Variables.integerValue(Integer.MIN_VALUE)));
    assertThat(typeTransformer.transform(Integer.MAX_VALUE), is((TypedValue) Variables.integerValue(Integer.MAX_VALUE)));
}
Also used : DmnDataTypeTransformer(org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 8 with DmnDataTypeTransformer

use of org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer in project camunda-engine-dmn by camunda.

the class DmnDataTypeTransformerTest method invalidStringValueForIntegerType.

@Test
public void invalidStringValueForIntegerType() {
    DmnDataTypeTransformer typeTransformer = registry.getTransformer("integer");
    thrown.expect(IllegalArgumentException.class);
    typeTransformer.transform("4.2");
}
Also used : DmnDataTypeTransformer(org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 9 with DmnDataTypeTransformer

use of org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer in project camunda-engine-dmn by camunda.

the class DmnDataTypeTransformerTest method invalidStringForDateType.

@Test
public void invalidStringForDateType() {
    DmnDataTypeTransformer typeTransformer = registry.getTransformer("date");
    thrown.expect(IllegalArgumentException.class);
    typeTransformer.transform("18.09.2015 12:00:00");
}
Also used : DmnDataTypeTransformer(org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 10 with DmnDataTypeTransformer

use of org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer in project camunda-engine-dmn by camunda.

the class DmnDataTypeTransformerTest method invalidDoubleMinValueForLongType.

@Test
public void invalidDoubleMinValueForLongType() {
    DmnDataTypeTransformer typeTransformer = registry.getTransformer("long");
    thrown.expect(IllegalArgumentException.class);
    typeTransformer.transform(Double.MIN_VALUE);
}
Also used : DmnDataTypeTransformer(org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Aggregations

DmnDataTypeTransformer (org.camunda.bpm.dmn.engine.impl.spi.type.DmnDataTypeTransformer)17 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)17 Test (org.junit.Test)17 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)6 Date (java.util.Date)1