Search in sources :

Example 11 with DecisionService

use of org.kie.dmn.model.api.DecisionService in project drools by kiegroup.

the class DMNXMLLoaderTest method testLoadingDecisionServices.

@Test
public void testLoadingDecisionServices() {
    final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Arrays.asList(new DecisionServicesExtensionRegister()));
    final InputStream is = this.getClass().getResourceAsStream("0004-decision-services.dmn");
    final InputStreamReader isr = new InputStreamReader(is);
    final Definitions def = DMNMarshaller.unmarshal(isr);
    assertThat(def.getDecisionService().size(), is(2));
    DecisionService decisionService1 = def.getDecisionService().get(0);
    assertThat(decisionService1.getId(), is("_70386614-9838-420b-a2ae-ff901ada63fb"));
    assertThat(decisionService1.getName(), is("A Only Knowing B and C"));
    assertThat(decisionService1.getDescription(), is("Description of A (BC)"));
    assertThat(decisionService1.getOutputDecision().size(), is(1));
    assertThat(decisionService1.getEncapsulatedDecision().size(), is(0));
    assertThat(decisionService1.getInputDecision().size(), is(2));
    assertThat(decisionService1.getInputData().size(), is(0));
    assertThat(decisionService1.getOutputDecision().get(0).getHref(), is("#_c2b44706-d479-4ceb-bb74-73589d26dd04"));
    DecisionService decisionService2 = def.getDecisionService().get(1);
    assertThat(decisionService2.getId(), is("_4620ef13-248a-419e-bc68-6b601b725a03"));
    assertThat(decisionService2.getName(), is("A only as output knowing D and E"));
    assertThat(decisionService2.getOutputDecision().size(), is(1));
    assertThat(decisionService2.getEncapsulatedDecision().size(), is(2));
    assertThat(decisionService2.getInputDecision().size(), is(0));
    assertThat(decisionService2.getInputData().size(), is(2));
    assertThat(decisionService2.getInputData().get(0).getHref(), is("#_bcea16fb-6c19-4bde-b37d-73407002c064"));
    assertThat(decisionService2.getInputData().get(1).getHref(), is("#_207b9195-a441-47f2-9414-2fad64b463f9"));
}
Also used : DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) InputStreamReader(java.io.InputStreamReader) DecisionServicesExtensionRegister(org.kie.dmn.backend.marshalling.v1_1.xstream.extensions.DecisionServicesExtensionRegister) InputStream(java.io.InputStream) Definitions(org.kie.dmn.model.api.Definitions) DecisionService(org.kie.dmn.model.api.DecisionService) Test(org.junit.Test)

Example 12 with DecisionService

use of org.kie.dmn.model.api.DecisionService in project drools by kiegroup.

the class DecisionServiceConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DecisionService decisionService = (DecisionService) parent;
    for (DMNElementReference ref : decisionService.getOutputDecision()) {
        writeChildrenNode(writer, context, ref, OUTPUT_DECISION);
    }
    for (DMNElementReference ref : decisionService.getEncapsulatedDecision()) {
        writeChildrenNode(writer, context, ref, ENCAPSULATED_DECISION);
    }
    for (DMNElementReference ref : decisionService.getInputDecision()) {
        writeChildrenNode(writer, context, ref, INPUT_DECISION);
    }
    for (DMNElementReference ref : decisionService.getInputData()) {
        writeChildrenNode(writer, context, ref, INPUT_DATA);
    }
}
Also used : DMNElementReference(org.kie.dmn.model.api.DMNElementReference) TDMNElementReference(org.kie.dmn.model.v1_3.TDMNElementReference) TDecisionService(org.kie.dmn.model.v1_3.TDecisionService) DecisionService(org.kie.dmn.model.api.DecisionService)

Aggregations

DecisionService (org.kie.dmn.model.api.DecisionService)12 Definitions (org.kie.dmn.model.api.Definitions)5 DMNElementReference (org.kie.dmn.model.api.DMNElementReference)4 DRGElement (org.kie.dmn.model.api.DRGElement)4 Artifact (org.kie.dmn.model.api.Artifact)3 Association (org.kie.dmn.model.api.Association)3 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)3 BusinessKnowledgeModel (org.kie.dmn.model.api.BusinessKnowledgeModel)3 Decision (org.kie.dmn.model.api.Decision)3 ElementCollection (org.kie.dmn.model.api.ElementCollection)3 Import (org.kie.dmn.model.api.Import)3 InputData (org.kie.dmn.model.api.InputData)3 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)3 KnowledgeSource (org.kie.dmn.model.api.KnowledgeSource)3 OrganizationUnit (org.kie.dmn.model.api.OrganizationUnit)3 PerformanceIndicator (org.kie.dmn.model.api.PerformanceIndicator)3 TextAnnotation (org.kie.dmn.model.api.TextAnnotation)3 InputStream (java.io.InputStream)2 DecisionServices (org.kie.dmn.model.v1_1.extensions.DecisionServices)2 File (java.io.File)1