Search in sources :

Example 1 with HasTypeRef

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

the class RelationTest method testGetHasTypeRefs.

@Test
public void testGetHasTypeRefs() {
    final InformationItem column1 = mock(InformationItem.class);
    final InformationItem column2 = mock(InformationItem.class);
    final List<InformationItem> column = asList(column1, column2);
    final org.kie.workbench.common.dmn.api.definition.model.List row1 = mock(org.kie.workbench.common.dmn.api.definition.model.List.class);
    final org.kie.workbench.common.dmn.api.definition.model.List row2 = mock(org.kie.workbench.common.dmn.api.definition.model.List.class);
    final List<org.kie.workbench.common.dmn.api.definition.model.List> row = asList(row1, row2);
    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(column).when(relation).getColumn();
    doReturn(row).when(relation).getRow();
    when(column1.getHasTypeRefs()).thenReturn(asList(hasTypeRef1));
    when(column2.getHasTypeRefs()).thenReturn(asList(hasTypeRef2));
    when(row1.getHasTypeRefs()).thenReturn(asList(hasTypeRef3));
    when(row2.getHasTypeRefs()).thenReturn(asList(hasTypeRef4));
    final List<HasTypeRef> actualHasTypeRefs = relation.getHasTypeRefs();
    final List<HasTypeRef> expectedHasTypeRefs = asList(relation, hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4);
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) ArrayList(java.util.ArrayList) List(java.util.List) Arrays.asList(java.util.Arrays.asList) Test(org.junit.Test)

Example 2 with HasTypeRef

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

the class InformationItemCellInformationItemTest method testHasNameAndDataTypeCellGetHasTypeRefs.

@Test
public void testHasNameAndDataTypeCellGetHasTypeRefs() {
    final InformationItem informationItem = mock(InformationItem.class);
    final HasNameAndDataTypeCell hasNameAndDataTypeCell = HasNameAndDataTypeCell.wrap(informationItem);
    final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
    final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
    final List<HasTypeRef> expectedHasTypeRefs = asList(hasTypeRef1, hasTypeRef2);
    when(informationItem.getHasTypeRefs()).thenReturn(expectedHasTypeRefs);
    final List<HasTypeRef> actualHasTypeRefs = hasNameAndDataTypeCell.getHasTypeRefs();
    assertEquals(expectedHasTypeRefs, actualHasTypeRefs);
}
Also used : HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) HasNameAndDataTypeCell(org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemCell.HasNameAndDataTypeCell) Test(org.junit.Test)

Example 3 with HasTypeRef

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

the class PropertiesPanelNotifier method notifyExpressions.

void notifyExpressions(final Node node, final Object definition) {
    if (definition instanceof HasExpression) {
        final HasExpression hasExpression = asHasExpression(definition);
        final List<HasTypeRef> hasTypeRefs = getNotNullHasTypeRefs(hasExpression.getExpression());
        for (final HasTypeRef hasTypeRef : hasTypeRefs) {
            notifyOutdatedElement(node, hasTypeRef);
        }
    }
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasTypeRef(org.kie.workbench.common.dmn.api.definition.HasTypeRef)

Example 4 with HasTypeRef

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

the class InputClauseTest method testGetHasTypeRefs.

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

Example 5 with HasTypeRef

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

the class HasTypeRefHelperTest method testGetFlatHasTypeRefsFromExpressions.

@Test
public void testGetFlatHasTypeRefsFromExpressions() {
    final Expression expression1 = mock(Expression.class);
    final Expression expression2 = mock(Expression.class);
    final DMNModelInstrumentedBase parent = mock(DMNModelInstrumentedBase.class);
    final HasExpression hasExpression1 = HasExpression.wrap(parent, expression1);
    final HasExpression hasExpression2 = HasExpression.wrap(parent, expression2);
    final List<HasExpression> hasExpressions = asList(hasExpression1, hasExpression2);
    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 List<HasTypeRef> typeRefList1 = asList(hasTypeRef1, hasTypeRef2);
    final List<HasTypeRef> typeRefList2 = asList(hasTypeRef3, hasTypeRef4);
    when(expression1.getHasTypeRefs()).thenReturn(typeRefList1);
    when(expression2.getHasTypeRefs()).thenReturn(typeRefList2);
    final List<HasTypeRef> actual = HasTypeRefHelper.getFlatHasTypeRefsFromExpressions(hasExpressions);
    final List<HasTypeRef> expected = asList(hasTypeRef1, hasTypeRef2, hasTypeRef3, hasTypeRef4);
    assertEquals(expected, actual);
}
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) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) 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