use of org.kie.dmn.api.core.ast.ItemDefNode in project drools by kiegroup.
the class DMNCompilerTest method testItemDefAllowedValuesString.
@Test
public void testItemDefAllowedValuesString() {
final DMNRuntime runtime = createRuntime("0003-input-data-string-allowed-values.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0003-input-data-string-allowed-values");
assertThat(dmnModel, notNullValue());
final ItemDefNode itemDef = dmnModel.getItemDefinitionByName("tEmploymentStatus");
assertThat(itemDef.getName(), is("tEmploymentStatus"));
assertThat(itemDef.getId(), is(nullValue()));
final DMNType type = itemDef.getType();
assertThat(type, is(notNullValue()));
assertThat(type.getName(), is("tEmploymentStatus"));
assertThat(type.getId(), is(nullValue()));
assertThat(type, is(instanceOf(SimpleTypeImpl.class)));
final SimpleTypeImpl feelType = (SimpleTypeImpl) type;
final EvaluationContext ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
assertThat(feelType.getFeelType(), is(instanceOf(AliasFEELType.class)));
assertThat(feelType.getFeelType().getName(), is("tEmploymentStatus"));
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.api.core.ast.ItemDefNode in project drools by kiegroup.
the class DMNInputRuntimeTest method testOrdering.
@Test
public void testOrdering() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Order.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6318588b-c32f-4070-848b-bd8017e6b94e", "Drawing 1");
int index = 1;
for (InputDataNode node : dmnModel.getInputs()) {
assertTrue(node.getName().endsWith("" + index++));
}
index = 1;
for (DecisionNode node : dmnModel.getDecisions()) {
assertTrue(node.getName().endsWith("" + index++));
}
index = 1;
for (BusinessKnowledgeModelNode node : dmnModel.getBusinessKnowledgeModels()) {
assertTrue(node.getName().endsWith("" + index++));
}
index = 1;
for (ItemDefNode node : dmnModel.getItemDefinitions()) {
assertTrue(node.getName().endsWith("" + index++));
}
index = 1;
for (DecisionServiceNode node : dmnModel.getDecisionServices()) {
assertTrue(node.getName().endsWith("" + index++));
}
}
use of org.kie.dmn.api.core.ast.ItemDefNode in project drools by kiegroup.
the class DMNCompilerTest method testCompositeItemDefinition.
@Test
public void testCompositeItemDefinition() {
final DMNRuntime runtime = createRuntime("0008-LX-arithmetic.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0008-LX-arithmetic");
assertThat(dmnModel, notNullValue());
final ItemDefNode itemDef = dmnModel.getItemDefinitionByName("tLoan");
assertThat(itemDef.getName(), is("tLoan"));
assertThat(itemDef.getId(), is("tLoan"));
final DMNType type = itemDef.getType();
assertThat(type, is(notNullValue()));
assertThat(type.getName(), is("tLoan"));
assertThat(type.getId(), is("tLoan"));
assertThat(type, is(instanceOf(CompositeTypeImpl.class)));
final CompositeTypeImpl compType = (CompositeTypeImpl) type;
assertThat(compType.getFields().size(), is(3));
final DMNType principal = compType.getFields().get("principal");
assertThat(principal, is(notNullValue()));
assertThat(principal.getName(), is("number"));
assertThat(((SimpleTypeImpl) principal).getFeelType(), is(BuiltInType.NUMBER));
final DMNType rate = compType.getFields().get("rate");
assertThat(rate, is(notNullValue()));
assertThat(rate.getName(), is("number"));
assertThat(((SimpleTypeImpl) rate).getFeelType(), is(BuiltInType.NUMBER));
final DMNType termMonths = compType.getFields().get("termMonths");
assertThat(termMonths, is(notNullValue()));
assertThat(termMonths.getName(), is("number"));
assertThat(((SimpleTypeImpl) termMonths).getFeelType(), is(BuiltInType.NUMBER));
}
use of org.kie.dmn.api.core.ast.ItemDefNode in project drools by kiegroup.
the class DMNCompilerTest method testItemDefAllowedValuesString.
@Test
public void testItemDefAllowedValuesString() {
final DMNRuntime runtime = createRuntime("0003-input-data-string-allowed-values.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0003-input-data-string-allowed-values");
assertThat(dmnModel, notNullValue());
final ItemDefNode itemDef = dmnModel.getItemDefinitionByName("tEmploymentStatus");
assertThat(itemDef.getName(), is("tEmploymentStatus"));
assertThat(itemDef.getId(), is(nullValue()));
final DMNType type = itemDef.getType();
assertThat(type, is(notNullValue()));
assertThat(type.getName(), is("tEmploymentStatus"));
assertThat(type.getId(), is(nullValue()));
assertThat(type, is(instanceOf(SimpleTypeImpl.class)));
final SimpleTypeImpl feelType = (SimpleTypeImpl) type;
final EvaluationContext ctx = new EvaluationContextImpl(ClassLoaderUtil.findDefaultClassLoader(), null);
assertThat(feelType.getFeelType(), is(instanceOf(AliasFEELType.class)));
assertThat(feelType.getFeelType().getName(), is("tEmploymentStatus"));
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.api.core.ast.ItemDefNode in project drools by kiegroup.
the class DMNCompilerTest method testCompositeItemDefinition.
@Test
public void testCompositeItemDefinition() {
final DMNRuntime runtime = createRuntime("0008-LX-arithmetic.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0008-LX-arithmetic");
assertThat(dmnModel, notNullValue());
final ItemDefNode itemDef = dmnModel.getItemDefinitionByName("tLoan");
assertThat(itemDef.getName(), is("tLoan"));
assertThat(itemDef.getId(), is("tLoan"));
final DMNType type = itemDef.getType();
assertThat(type, is(notNullValue()));
assertThat(type.getName(), is("tLoan"));
assertThat(type.getId(), is("tLoan"));
assertThat(type, is(instanceOf(CompositeTypeImpl.class)));
final CompositeTypeImpl compType = (CompositeTypeImpl) type;
assertThat(compType.getFields().size(), is(3));
final DMNType principal = compType.getFields().get("principal");
assertThat(principal, is(notNullValue()));
assertThat(principal.getName(), is("number"));
assertThat(((SimpleTypeImpl) principal).getFeelType(), is(BuiltInType.NUMBER));
final DMNType rate = compType.getFields().get("rate");
assertThat(rate, is(notNullValue()));
assertThat(rate.getName(), is("number"));
assertThat(((SimpleTypeImpl) rate).getFeelType(), is(BuiltInType.NUMBER));
final DMNType termMonths = compType.getFields().get("termMonths");
assertThat(termMonths, is(notNullValue()));
assertThat(termMonths.getName(), is("number"));
assertThat(((SimpleTypeImpl) termMonths).getFeelType(), is(BuiltInType.NUMBER));
}
Aggregations