Search in sources :

Example 21 with HasTypeRef

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

the class InvocationTest method testGetHasTypeRefs.

@Test
public void testGetHasTypeRefs() {
    final Expression expression = mock(Expression.class);
    // added
    final Binding binding1 = mock(Binding.class);
    // added
    final Binding binding2 = mock(Binding.class);
    final List<Binding> binding = asList(binding1, binding2);
    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(invocation).getExpression();
    doReturn(binding).when(invocation).getBinding();
    when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2));
    when(binding1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3));
    when(binding2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4));
    final List<HasTypeRef> actualHasTypeRefs = invocation.getHasTypeRefs();
    final List<HasTypeRef> expectedHasTypeRefs = asList(invocation, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4);
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) Test(org.junit.Test)

Example 22 with HasTypeRef

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

the class HasTypeRefHelperTest method testGetFlatHasTypeRefs.

@Test
public void testGetFlatHasTypeRefs() {
    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);
    final List<HasTypeRef> typeRefList1 = asList(hasTypeRef3, hasTypeRef4);
    final List<HasTypeRef> typeRefList2 = asList(hasTypeRef5, hasTypeRef6);
    final List<HasTypeRefs> hasTypeRefs = asList(hasTypeRef1, hasTypeRef2);
    when(hasTypeRef1.getHasTypeRefs()).thenReturn(typeRefList1);
    when(hasTypeRef2.getHasTypeRefs()).thenReturn(typeRefList2);
    final List<HasTypeRef> actual = HasTypeRefHelper.getFlatHasTypeRefs(hasTypeRefs);
    final List<HasTypeRef> expected = asList(hasTypeRef3, hasTypeRef4, hasTypeRef5, hasTypeRef6);
    assertEquals(expected, actual);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) HasTypeRefs(org.kie.workbench.common.dmn.api.definition.HasTypeRefs) 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