use of org.kie.dmn.core.impl.SimpleTypeImpl in project drools by kiegroup.
the class DMNCompilerTest method testItemDefAllowedValuesString.
@Test
public void testItemDefAllowedValuesString() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0003-input-data-string-allowed-values.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0003-input-data-string-allowed-values");
assertThat(dmnModel, notNullValue());
ItemDefNode itemDef = dmnModel.getItemDefinitionByName("tEmploymentStatus");
assertThat(itemDef.getName(), is("tEmploymentStatus"));
assertThat(itemDef.getId(), is(nullValue()));
DMNType type = itemDef.getType();
assertThat(type, is(notNullValue()));
assertThat(type.getName(), is("tEmploymentStatus"));
assertThat(type.getId(), is(nullValue()));
assertThat(type, is(instanceOf(SimpleTypeImpl.class)));
SimpleTypeImpl feelType = (SimpleTypeImpl) type;
EvaluationContext ctx = new EvaluationContextImpl(null);
assertThat(feelType.getFeelType(), is(BuiltInType.STRING));
assertThat(feelType.getAllowedValuesFEEL().size(), is(4));
assertThat(feelType.getAllowedValuesFEEL().get(0).apply(ctx, "UNEMPLOYED"), is(true));
assertThat(feelType.getAllowedValuesFEEL().get(1).apply(ctx, "EMPLOYED"), is(true));
assertThat(feelType.getAllowedValuesFEEL().get(2).apply(ctx, "SELF-EMPLOYED"), is(true));
assertThat(feelType.getAllowedValuesFEEL().get(3).apply(ctx, "STUDENT"), is(true));
}
use of org.kie.dmn.core.impl.SimpleTypeImpl in project drools by kiegroup.
the class DMNTypeTest method testAllowedValuesForASimpleTypeCollection.
@Test
public void testAllowedValuesForASimpleTypeCollection() {
// DROOLS-2357
final String testNS = "testDROOLS2357";
FEEL feel = FEEL.newInstance();
DMNType tDecision1 = typeRegistry.registerType(new SimpleTypeImpl(testNS, "tListOfVowels", null, true, feel.evaluateUnaryTests("\"a\",\"e\",\"i\",\"o\",\"u\""), FEEL_STRING, BuiltInType.STRING));
assertTrue(tDecision1.isAssignableValue("a"));
assertTrue(tDecision1.isAssignableValue(Arrays.asList("a")));
assertFalse(tDecision1.isAssignableValue("z"));
assertTrue(tDecision1.isAssignableValue(Arrays.asList("a", "e")));
assertFalse(tDecision1.isAssignableValue(Arrays.asList("a", "e", "zzz")));
}
Aggregations