use of org.kie.dmn.model.api.InputData in project drools by kiegroup.
the class InputDataConverter method assignChildElement.
@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
super.assignChildElement(parent, nodeName, child);
InputData id = (InputData) parent;
if (VARIABLE.equals(nodeName)) {
id.setVariable((InformationItem) child);
} else {
super.assignChildElement(parent, nodeName, child);
}
}
use of org.kie.dmn.model.api.InputData in project drools by kiegroup.
the class InputDataConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
InputData id = (InputData) parent;
if (id.getVariable() != null) {
writeChildrenNode(writer, context, id.getVariable(), VARIABLE);
}
}
use of org.kie.dmn.model.api.InputData in project drools by kiegroup.
the class DMNXMLLoaderTest method testLoadingDefinitions.
@Test
public void testLoadingDefinitions() {
final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newDefaultMarshaller();
final InputStream is = this.getClass().getResourceAsStream("0001-input-data-string.dmn");
final InputStreamReader isr = new InputStreamReader(is);
final Definitions def = DMNMarshaller.unmarshal(isr);
assertThat(def, not(nullValue()));
assertThat(def.getName(), is("0001-input-data-string"));
assertThat(def.getId(), is("_0001-input-data-string"));
assertThat(def.getNamespace(), is("https://github.com/agilepro/dmn-tck"));
assertThat(def.getDrgElement().size(), is(2));
assertThat(def.getDrgElement().get(0), is(instanceOf(Decision.class)));
Decision dec = (Decision) def.getDrgElement().get(0);
assertThat(dec.getName(), is("Greeting Message"));
assertThat(dec.getId(), is("d_GreetingMessage"));
assertThat(dec.getVariable().getName(), is("Greeting Message"));
assertThat(dec.getVariable().getTypeRef().getPrefix(), is("feel"));
assertThat(dec.getVariable().getTypeRef().getLocalPart(), is("string"));
assertThat(dec.getVariable().getTypeRef().getNamespaceURI(), is(XMLConstants.NULL_NS_URI));
assertThat(dec.getInformationRequirement().size(), is(1));
assertThat(dec.getInformationRequirement().get(0).getRequiredInput().getHref(), is("#i_FullName"));
assertThat(dec.getExpression(), is(instanceOf(LiteralExpression.class)));
LiteralExpression le = (LiteralExpression) dec.getExpression();
assertThat(le.getText(), is("\"Hello \" + Full Name"));
InputData idata = (InputData) def.getDrgElement().get(1);
assertThat(idata.getId(), is("i_FullName"));
assertThat(idata.getName(), is("Full Name"));
assertThat(idata.getVariable().getName(), is("Full Name"));
assertThat(idata.getVariable().getTypeRef().getPrefix(), is("feel"));
assertThat(idata.getVariable().getTypeRef().getLocalPart(), is("string"));
assertThat(idata.getVariable().getTypeRef().getNamespaceURI(), is(XMLConstants.NULL_NS_URI));
}
use of org.kie.dmn.model.api.InputData in project drools by kiegroup.
the class InputDataConverter method assignChildElement.
@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
super.assignChildElement(parent, nodeName, child);
InputData id = (InputData) parent;
if (VARIABLE.equals(nodeName)) {
id.setVariable((InformationItem) child);
} else {
super.assignChildElement(parent, nodeName, child);
}
}
use of org.kie.dmn.model.api.InputData in project drools by kiegroup.
the class DMNExtensionRegisterTest method testUsingKModuleProperty_WrongClasses.
@Test
public void testUsingKModuleProperty_WrongClasses() {
final KieServices ks = KieServices.Factory.get();
final KieFileSystem kfs = ks.newKieFileSystem();
final KieModuleModel kmm = ks.newKieModuleModel();
kmm.setConfigurationProperty("org.kie.dmn.profiles.FirstNameLastNameProfile", "foo");
kfs.writeKModuleXML(kmm.toXML());
kfs.write(ks.getResources().newClassPathResource("0001-input-data-string-with-extensions.dmn", this.getClass()));
final KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
final Results results = kieBuilder.getResults();
LOG.info("buildAll() completed.");
results.getMessages(Level.WARNING).forEach(e -> LOG.warn("{}", e));
assertTrue(results.getMessages(Level.WARNING).size() > 0);
final KieContainer kieContainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
final DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0001-input-data-string");
assertThat(dmnModel, notNullValue());
assertThat(formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
assertEquals(3, dmnModel.getDefinitions().getDrgElement().size());
final InputData inputData1 = (InputData) dmnModel.getDefinitions().getDrgElement().get(1);
assertEquals("First Name", inputData1.getName());
final DMNElement.ExtensionElements id1elements = inputData1.getExtensionElements();
assertNotNull(id1elements);
assertEquals(0, id1elements.getAny().size());
final InputData inputData2 = (InputData) dmnModel.getDefinitions().getDrgElement().get(2);
assertEquals("Last Name", inputData2.getName());
final DMNElement.ExtensionElements id2elements = inputData2.getExtensionElements();
assertNotNull(id2elements);
assertEquals(0, id2elements.getAny().size());
}
Aggregations