use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.
the class DMNRuntimeTest method test_countCSATradeRatings.
@Test
public void test_countCSATradeRatings() {
// DROOLS-1563
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("countCSATradeRatings.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_1a7d184c-2e38-4462-ae28-15591ef6d534", "countCSATradeRatings");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext ctx = runtime.newContext();
List<Map<?, ?>> ratings = new ArrayList<>();
ratings.add(prototype(entry("Agency", "FITCH"), entry("Value", "val1")));
ratings.add(prototype(entry("Agency", "MOODY"), entry("Value", "val2")));
ctx.set("CSA Trade Ratings", ratings);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, ctx);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext result = dmnResult.getContext();
assertThat(result.get("Trade Ratings"), is(new BigDecimal(2)));
DMNContext ctx2 = runtime.newContext();
ctx2.set("CSA Trade Ratings", null);
DMNResult dmnResult2 = runtime.evaluateAll(dmnModel, ctx2);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult2.getMessages()), dmnResult2.hasErrors(), is(false));
DMNContext result2 = dmnResult2.getContext();
assertThat(result2.get("Trade Ratings"), nullValue());
DMNResult dmnResult3 = runtime.evaluateAll(dmnModel, runtime.newContext());
assertThat(DMNRuntimeUtil.formatMessages(dmnResult3.getMessages()), dmnResult3.hasErrors(), is(true));
assertThat(dmnResult3.getMessages().stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND)), is(true));
}
use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.
the class ImportDMNResolverUtilTest method testNSnoModelNameDefaultWithAlias.
@Test
public void testNSnoModelNameDefaultWithAlias() {
Import i = makeImport("ns1", "m1", null);
List<QName> available = Arrays.asList(new QName("ns1", "m1"), new QName("ns2", "m2"), new QName("ns3", "m3"));
Either<String, QName> result = ImportDMNResolverUtil.resolveImportDMN(i, available, Function.identity());
assertTrue(result.isRight());
assertEquals(new QName("ns1", "m1"), result.getOrElse(null));
}
use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.
the class ImportDMNResolverUtilTest method testLocateInNS.
@Test
public void testLocateInNS() {
Import i = makeImport("nsA", null, "m1");
List<QName> available = Arrays.asList(new QName("nsA", "m1"), new QName("nsA", "m2"), new QName("nsB", "m3"));
Either<String, QName> result = ImportDMNResolverUtil.resolveImportDMN(i, available, Function.identity());
assertTrue(result.isRight());
assertEquals(new QName("nsA", "m1"), result.getOrElse(null));
}
use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.
the class ImportDMNResolverUtilTest method testLocateInNSAliased.
@Test
public void testLocateInNSAliased() {
Import i = makeImport("nsA", "aliased", "m1");
List<QName> available = Arrays.asList(new QName("nsA", "m1"), new QName("nsA", "m2"), new QName("nsB", "m3"));
Either<String, QName> result = ImportDMNResolverUtil.resolveImportDMN(i, available, Function.identity());
assertTrue(result.isRight());
assertEquals(new QName("nsA", "m1"), result.getOrElse(null));
}
use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.
the class ImportDMNResolverUtilTest method testLocateInNSAliasedBadScenario.
@Test
public void testLocateInNSAliasedBadScenario() {
Import i = makeImport("nsA", "aliased", "mA");
List<QName> available = Arrays.asList(new QName("nsA", "mA"), new QName("nsA", "mA"), new QName("nsB", "m3"));
Either<String, QName> result = ImportDMNResolverUtil.resolveImportDMN(i, available, Function.identity());
assertTrue(result.isLeft());
}
Aggregations