Search in sources :

Example 26 with Decision

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

the class BoxedExpressionHelperTest method testGetExpression.

@Test
public void testGetExpression() {
    final View content = mock(View.class);
    final Decision decision = mock(Decision.class);
    final Expression expectedExpression = mock(Expression.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(decision);
    when(decision.getExpression()).thenReturn(expectedExpression);
    final Expression actualExpression = helper.getExpression(node);
    assertEquals(expectedExpression, actualExpression);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 27 with Decision

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

the class BoxedExpressionHelperTest method testGetOptionalExpressionWhenIsPresent.

@Test
public void testGetOptionalExpressionWhenIsPresent() {
    final View content = mock(View.class);
    final Decision decision = mock(Decision.class);
    final Expression expectedExpression = mock(Expression.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(decision);
    when(decision.getExpression()).thenReturn(expectedExpression);
    final Optional<Expression> optionalExpression = helper.getOptionalExpression(node);
    assertTrue(optionalExpression.isPresent());
    assertEquals(expectedExpression, optionalExpression.get());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 28 with Decision

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

the class DecisionComponentFilterTest method testQueryFilteredByDrgElementNoResult.

@Test
public void testQueryFilteredByDrgElementNoResult() {
    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("KnowledgeRequirement");
    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 29 with Decision

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

the class DecisionComponentFilterTest method testQueryFilteredByTermMultipleResults.

@Test
public void testQueryFilteredByTermMultipleResults() {
    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("?");
    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 30 with Decision

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

the class DecisionComponentFilterTest method testQueryWithoutFilters.

@Test
public void testQueryWithoutFilters() {
    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);
    final Stream<DecisionComponentsItem> query = filter.query(stream);
    final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList());
    final List<DecisionComponentsItem> expectedResult = asList(item1, item2, 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)

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