use of org.kie.workbench.common.dmn.api.definition.HasTypeRef in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testNotifyExpressions.
@Test
public void testNotifyExpressions() {
final Node node = mock(Node.class);
final HasExpression hasExpression = mock(HasExpression.class);
final Expression expression = mock(Expression.class);
final HasTypeRef hasTypeRef1 = mock(HasTypeRef.class);
final HasTypeRef hasTypeRef2 = mock(HasTypeRef.class);
when(expression.getHasTypeRefs()).thenReturn(asList(hasTypeRef1, hasTypeRef2));
when(hasExpression.getExpression()).thenReturn(expression);
doNothing().when(notifier).notifyOutdatedElement(any(), any());
notifier.notifyExpressions(node, hasExpression);
verify(notifier).notifyOutdatedElement(node, hasTypeRef1);
verify(notifier).notifyOutdatedElement(node, hasTypeRef2);
}
use of org.kie.workbench.common.dmn.api.definition.HasTypeRef in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testNotifyOutdatedNodeWhenNodeDoesNotHaveTypeRef.
@Test
public void testNotifyOutdatedNodeWhenNodeDoesNotHaveTypeRef() {
final Node node = mock(Node.class);
final HasTypeRef elementTypeRef = mock(HasTypeRef.class);
final QName newQName = mock(QName.class);
final String oldLocalPart = "tPerson";
when(elementTypeRef.getTypeRef()).thenReturn(null);
doNothing().when(notifier).refreshFormProperties(any());
notifier.withOldLocalPart(oldLocalPart).withNewQName(newQName).notifyOutdatedElement(node, elementTypeRef);
verify(elementTypeRef, never()).setTypeRef(any());
verify(notifier, never()).refreshFormProperties(any());
}
use of org.kie.workbench.common.dmn.api.definition.HasTypeRef in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testNotifyOutdatedNodeWhenNodeIsNotOutdated.
@Test
public void testNotifyOutdatedNodeWhenNodeIsNotOutdated() {
final Node node = mock(Node.class);
final HasTypeRef elementTypeRef = mock(HasTypeRef.class);
final QName newQName = mock(QName.class);
final QName typeRef = mock(QName.class);
final String oldLocalPart = "tPerson";
final String elementLocalPart = "";
when(elementTypeRef.getTypeRef()).thenReturn(typeRef);
when(typeRef.getLocalPart()).thenReturn(elementLocalPart);
notifier.withOldLocalPart(oldLocalPart).withNewQName(newQName).notifyOutdatedElement(node, elementTypeRef);
verify(elementTypeRef, never()).setTypeRef(any());
verify(notifier, never()).refreshFormProperties(any());
}
use of org.kie.workbench.common.dmn.api.definition.HasTypeRef in project kie-wb-common by kiegroup.
the class PropertiesPanelNotifierTest method testNotifyOutdatedNodeWhenNodeIsOutdated.
@Test
public void testNotifyOutdatedNodeWhenNodeIsOutdated() {
final Node node = mock(Node.class);
final HasTypeRef elementTypeRef = mock(HasTypeRef.class);
final QName newQName = mock(QName.class);
final QName typeRef = mock(QName.class);
final String oldLocalPart = "tPerson";
final String elementLocalPart = "tPerson";
when(elementTypeRef.getTypeRef()).thenReturn(typeRef);
when(typeRef.getLocalPart()).thenReturn(elementLocalPart);
doNothing().when(notifier).refreshFormProperties(any());
notifier.withOldLocalPart(oldLocalPart).withNewQName(newQName).notifyOutdatedElement(node, elementTypeRef);
verify(elementTypeRef).setTypeRef(newQName);
verify(notifier).refreshFormProperties(node);
}
use of org.kie.workbench.common.dmn.api.definition.HasTypeRef in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method buildOutputClausesByDataType.
void buildOutputClausesByDataType(final HasExpression hasExpression, final DecisionTable dTable, final DecisionRule decisionRule) {
final HasTypeRef hasTypeRef = getHasTypeRef(hasExpression, dTable);
final QName typeRef = !Objects.isNull(hasTypeRef) ? hasTypeRef.getTypeRef() : BuiltInType.UNDEFINED.asQName();
final String name = DecisionTableDefaultValueUtilities.getNewOutputClauseName(dTable);
final List<ClauseRequirement> outputClausesRequirement = generateOutputClauseRequirements(dmnGraphUtils.getModelDefinitions(), typeRef, name);
if (outputClausesRequirement.isEmpty()) {
dTable.getOutput().add(buildOutputClause(dTable, typeRef, name));
populateOutputEntries(decisionRule);
} else {
outputClausesRequirement.stream().sorted(Comparator.comparing(outputClauseRequirement -> outputClauseRequirement.text)).map(outputClauseRequirement -> buildOutputClause(dTable, outputClauseRequirement.typeRef, outputClauseRequirement.text)).forEach(outputClause -> {
dTable.getOutput().add(outputClause);
populateOutputEntries(decisionRule);
});
}
}
Aggregations