Search in sources :

Example 16 with HasTypeRef

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

the class ContextTest method testGetHasTypeRefs.

@Test
public void testGetHasTypeRefs() {
    final ContextEntry contextEntry1 = mock(ContextEntry.class);
    final ContextEntry contextEntry2 = mock(ContextEntry.class);
    final List<ContextEntry> contextEntry = asList(contextEntry1, contextEntry2);
    final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
    doReturn(contextEntry).when(context).getContextEntry();
    when(contextEntry1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1));
    when(contextEntry2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2));
    final List<HasTypeRef> actualHasTypeRefs = context.getHasTypeRefs();
    final List<HasTypeRef> expectedHasTypeRefs = asList(context, hasTypeRef1, hasTypeRef2);
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) Test(org.junit.Test)

Example 17 with HasTypeRef

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

the class FunctionDefinitionTest method testGetHasTypeRefs.

@Test
public void testGetHasTypeRefs() {
    final Expression expression = mock(Expression.class);
    final InformationItem informationItem1 = mock(InformationItem.class);
    final InformationItem informationItem2 = mock(InformationItem.class);
    final List<InformationItem> formalParameter = asList(informationItem1, informationItem2);
    final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class);
    doReturn(expression).when(functionDefinition).getExpression();
    doReturn(formalParameter).when(functionDefinition).getFormalParameter();
    when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2));
    when(informationItem1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3));
    when(informationItem2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4));
    final List<HasTypeRef> actualHasTypeRefs = functionDefinition.getHasTypeRefs();
    final List<HasTypeRef> expectedHasTypeRefs = asList(functionDefinition, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4);
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) Test(org.junit.Test)

Example 18 with HasTypeRef

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

the class ListTest method testGetHasTypeRefs.

@Test
public void testGetHasTypeRefs() {
    // added
    final Expression expression1 = mock(Expression.class);
    // added
    final Expression expression2 = mock(Expression.class);
    final List<HasExpression> hasExpressions = asList(HasExpression.wrap(list, expression1), HasExpression.wrap(list, expression2));
    final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
    doReturn(hasExpressions).when(list).getExpression();
    when(expression1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1));
    when(expression2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2));
    final List<HasTypeRef> actualHasTypeRefs = list.getHasTypeRefs();
    final List<HasTypeRef> expectedHasTypeRefs = asList(list, hasTypeRef1, hasTypeRef2);
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Test(org.junit.Test)

Example 19 with HasTypeRef

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

the class HasTypeRefHelperTest method testGetNotNullHasTypeRefs.

@Test
public void testGetNotNullHasTypeRefs() {
    final HasTypeRef hasTypeRef = mock(HasTypeRef.class);
    final List<HasTypeRef> expectedHasTypeRefs = asList(mock(HasTypeRef.class), mock(HasTypeRef.class));
    when(hasTypeRef.getHasTypeRefs()).thenReturn(expectedHasTypeRefs);
    final List<HasTypeRef> actualHasTypeRefs = HasTypeRefHelper.getNotNullHasTypeRefs(hasTypeRef);
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) Test(org.junit.Test)

Example 20 with HasTypeRef

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

the class DecisionTableTest method testGetHasTypeRefs.

@Test
public void testGetHasTypeRefs() {
    final InputClause inputClauses1 = mock(InputClause.class);
    final InputClause inputClauses2 = mock(InputClause.class);
    final List<InputClause> inputClauses = asList(inputClauses1, inputClauses2);
    final OutputClause outputClauses1 = mock(OutputClause.class);
    final OutputClause outputClauses2 = mock(OutputClause.class);
    final List<OutputClause> outputClauses = asList(outputClauses1, outputClauses2);
    final DecisionRule decisionRules1 = mock(DecisionRule.class);
    final DecisionRule decisionRules2 = mock(DecisionRule.class);
    final List<DecisionRule> decisionRules = asList(decisionRules1, decisionRules2);
    final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef3 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef4 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef5 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef6 = mock(HasTypeRef.class);
    doReturn(inputClauses).when(decisionTable).getInput();
    doReturn(outputClauses).when(decisionTable).getOutput();
    doReturn(decisionRules).when(decisionTable).getRule();
    when(inputClauses1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1));
    when(inputClauses2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2));
    when(outputClauses1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3));
    when(outputClauses2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4));
    when(decisionRules1.getHasTypeRefs()).thenReturn(asList(hasTypeRef5));
    when(decisionRules2.getHasTypeRefs()).thenReturn(asList(hasTypeRef6));
    final List<HasTypeRef> actualHasTypeRefs = decisionTable.getHasTypeRefs();
    final List<HasTypeRef> expectedHasTypeRefs = asList(decisionTable, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4, hasTypeRef5, hasTypeRef6);
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) Test(org.junit.Test)

Aggregations

HasTypeRef (org.kie.workbench.common.dmn.api.definition.HasTypeRef)22 Test (org.junit.Test)18 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)5 DMNModelInstrumentedBase (org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase)4 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)4 Node (org.kie.workbench.common.stunner.core.graph.Node)4 HasVariable (org.kie.workbench.common.dmn.api.definition.HasVariable)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)2 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)2 IsInformationItem (org.kie.workbench.common.dmn.api.definition.model.IsInformationItem)2 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1