Search in sources :

Example 96 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DecisionComponentFilterTest method testQueryFilteredByDrgElementAndTermNoResult.

@Test
public void testQueryFilteredByDrgElementAndTermNoResult() {
    final DecisionComponentsItem item1 = item("Can Drive?", new Decision());
    final DecisionComponentsItem item2 = item("Is Allowed?", new Decision());
    final DecisionComponentsItem item3 = item("Age", new InputData());
    final DecisionComponentsItem item4 = item("Name", new InputData());
    final Stream<DecisionComponentsItem> stream = Stream.of(item1, item2, item3, item4);
    filter.setTerm("?");
    filter.setDrgElement("InputData");
    final Stream<DecisionComponentsItem> query = filter.query(stream);
    final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList());
    final List<DecisionComponentsItem> expectedResult = emptyList();
    assertEquals(expectedResult, actualResult);
}
Also used : InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 97 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DecisionComponentFilterTest method testQueryFilteredByDrgElementAndTermMultipleResults.

@Test
public void testQueryFilteredByDrgElementAndTermMultipleResults() {
    final DecisionComponentsItem item1 = item("Can Drive?", new Decision());
    final DecisionComponentsItem item2 = item("Is Allowed?", new Decision());
    final DecisionComponentsItem item3 = item("Age", new InputData());
    final DecisionComponentsItem item4 = item("Name", new InputData());
    final Stream<DecisionComponentsItem> stream = Stream.of(item1, item2, item3, item4);
    filter.setTerm("e");
    filter.setDrgElement("InputData");
    final Stream<DecisionComponentsItem> query = filter.query(stream);
    final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList());
    final List<DecisionComponentsItem> expectedResult = asList(item3, item4);
    assertEquals(expectedResult, actualResult);
}
Also used : InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 98 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DecisionComponentFilterTest method testQueryFilteredByDrgElementAndTerm.

@Test
public void testQueryFilteredByDrgElementAndTerm() {
    final DecisionComponentsItem item1 = item("Can Drive?", new Decision());
    final DecisionComponentsItem item2 = item("Is Allowed?", new Decision());
    final DecisionComponentsItem item3 = item("Age", new InputData());
    final DecisionComponentsItem item4 = item("Name", new InputData());
    final Stream<DecisionComponentsItem> stream = Stream.of(item1, item2, item3, item4);
    filter.setTerm("is");
    filter.setDrgElement("Decision");
    final Stream<DecisionComponentsItem> query = filter.query(stream);
    final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList());
    final List<DecisionComponentsItem> expectedResult = singletonList(item2);
    assertEquals(expectedResult, actualResult);
}
Also used : InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 99 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DecisionComponentFilterTest method testQueryFilteredByDrgElement.

@Test
public void testQueryFilteredByDrgElement() {
    final DecisionComponentsItem item1 = item("Can Drive?", new Decision());
    final DecisionComponentsItem item2 = item("Is Allowed?", new Decision());
    final DecisionComponentsItem item3 = item("Age", new InputData());
    final DecisionComponentsItem item4 = item("Name", new InputData());
    final Stream<DecisionComponentsItem> stream = Stream.of(item1, item2, item3, item4);
    filter.setDrgElement("Decision");
    final Stream<DecisionComponentsItem> query = filter.query(stream);
    final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList());
    final List<DecisionComponentsItem> expectedResult = asList(item1, item2);
    assertEquals(expectedResult, actualResult);
}
Also used : InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 100 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DefaultValueUtilitiesTest method testUpdateNewNodeName_KnowledgeSource.

@Test
public void testUpdateNewNodeName_KnowledgeSource() {
    // Add some existing nodes to ensure naming is not affected by existing content
    graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
    graph.addNode(makeMockNode(new Decision()));
    graph.addNode(makeMockNode(new InputData()));
    graph.addNode(makeMockNode(new TextAnnotation()));
    final KnowledgeSource knowledgeSource1 = new KnowledgeSource();
    final KnowledgeSource knowledgeSource2 = new KnowledgeSource();
    final KnowledgeSource knowledgeSource3 = new KnowledgeSource();
    final KnowledgeSource knowledgeSource4 = new KnowledgeSource();
    assertUpdateNewNodeName(knowledgeSource1, knowledgeSource2, (knowledgeSource) -> knowledgeSource.getName().getValue(), () -> KnowledgeSource.class.getSimpleName() + "-1", () -> KnowledgeSource.class.getSimpleName() + "-2");
    // Update existing names manually and add two more
    knowledgeSource1.getName().setValue("knowledgeSource");
    knowledgeSource2.getName().setValue(KnowledgeSource.class.getSimpleName() + "-5");
    assertUpdateNewNodeName(knowledgeSource3, knowledgeSource4, (knowledgeSource) -> knowledgeSource.getName().getValue(), () -> KnowledgeSource.class.getSimpleName() + "-6", () -> KnowledgeSource.class.getSimpleName() + "-7");
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Aggregations

Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)121 Test (org.junit.Test)79 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)39 View (org.kie.workbench.common.stunner.core.graph.content.view.View)38 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)37 Node (org.kie.workbench.common.stunner.core.graph.Node)28 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)23 Edge (org.kie.workbench.common.stunner.core.graph.Edge)23 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)22 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)21 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)21 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)20 List (java.util.List)16 TDecision (org.kie.dmn.model.v1_2.TDecision)16 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)16 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)16 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)16 ArrayList (java.util.ArrayList)15 Optional (java.util.Optional)15 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)15