use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapperTest method testFromDMNModelExpressionGridCacheIsHit.
@Test
@SuppressWarnings("unchecked")
public void testFromDMNModelExpressionGridCacheIsHit() {
setup(false);
expression = new LiteralExpression();
mapper.fromDMNModel(0, 0);
verify(literalExpressionEditorDefinition).getEditor(eq(parent), nodeUUIDCaptor.capture(), eq(hasExpression), eq(Optional.of(hasName)), eq(false), eq(0));
verify(expressionGridCache).putExpressionGrid(nodeUUIDCaptor.getValue().get(), Optional.of(literalExpressionEditor));
mapper.fromDMNModel(0, 0);
// There should only be one interaction with LiteralExpressionEditorDefinition
verify(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt());
verify(expressionGridCache).putExpressionGrid(Mockito.<String>any(), any(Optional.class));
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapperTest method testFromDMNModelLiteralExpressionType.
@Test
@SuppressWarnings("unchecked")
public void testFromDMNModelLiteralExpressionType() {
setup(false);
expression = new LiteralExpression();
mapper.fromDMNModel(0, 0);
assertUiModel();
assertEditorType(literalExpressionEditor.getClass());
verify(literalExpressionEditorDefinition).getEditor(eq(parent), nodeUUIDCaptor.capture(), eq(hasExpression), eq(Optional.of(hasName)), eq(false), eq(0));
final Optional<String> nodeUUID = nodeUUIDCaptor.getValue();
assertThat(nodeUUID.isPresent()).isTrue();
assertThat(nodeUUID.get()).isEqualTo(NODE_UUID);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DecisionRuleFactoryTest method testDuplicateDecisionRule.
@Test
public void testDuplicateDecisionRule() {
final DecisionRule rule = DecisionRuleFactory.makeDecisionRule(dtable);
final List<UnaryTests> inputEntries = rule.getInputEntry();
assertThat(inputEntries.size()).isEqualTo(2);
inputEntries.get(0).getText().setValue(INPUT_CLAUSE_TEXT_1);
inputEntries.get(1).getText().setValue(INPUT_CLAUSE_TEXT_2);
inputEntries.get(0).setConstraintType(ConstraintType.ENUMERATION);
inputEntries.get(1).setConstraintType(ConstraintType.RANGE);
final List<LiteralExpression> outputEntries = rule.getOutputEntry();
assertThat(outputEntries.size()).isEqualTo(2);
outputEntries.get(0).getText().setValue(OUTPUT_CLAUSE_TEXT_1);
outputEntries.get(1).getText().setValue(OUTPUT_CLAUSE_TEXT_2);
final List<RuleAnnotationClauseText> annotationEntries = rule.getAnnotationEntry();
assertThat(annotationEntries.size()).isEqualTo(2);
annotationEntries.get(0).getText().setValue(RULE_ANNOTATION_CLAUSE_TEXT_1);
annotationEntries.get(1).getText().setValue(RULE_ANNOTATION_CLAUSE_TEXT_2);
dtable.getRule().add(rule);
final DecisionRule duplicate = DecisionRuleFactory.duplicateDecisionRule(0, dtable);
final List<UnaryTests> duplicateInputEntries = duplicate.getInputEntry();
assertThat(duplicateInputEntries.size()).isEqualTo(2);
assertUnaryTestsText(duplicateInputEntries.get(0), INPUT_CLAUSE_TEXT_1);
assertUnaryTestsText(duplicateInputEntries.get(1), INPUT_CLAUSE_TEXT_2);
assertThat(duplicateInputEntries.get(0).getConstraintType()).isEqualTo(ConstraintType.ENUMERATION);
assertThat(duplicateInputEntries.get(1).getConstraintType()).isEqualTo(ConstraintType.RANGE);
assertUnaryTestsInstancesAreNotTheSame(inputEntries.get(0), duplicateInputEntries.get(0));
assertUnaryTestsInstancesAreNotTheSame(inputEntries.get(1), duplicateInputEntries.get(1));
assertThat(duplicateInputEntries).allSatisfy(unaryTests -> assertThat(unaryTests.getParent()).isEqualTo(duplicate));
final List<LiteralExpression> duplicateOutputEntries = duplicate.getOutputEntry();
assertThat(duplicateOutputEntries.size()).isEqualTo(2);
assertLiteralExpressionText(duplicateOutputEntries.get(0), OUTPUT_CLAUSE_TEXT_1);
assertLiteralExpressionText(duplicateOutputEntries.get(1), OUTPUT_CLAUSE_TEXT_2);
assertLiteralExpressionInstancesAreNotTheSame(outputEntries.get(0), duplicateOutputEntries.get(0));
assertLiteralExpressionInstancesAreNotTheSame(outputEntries.get(1), duplicateOutputEntries.get(1));
assertThat(duplicateOutputEntries).allSatisfy(literalExpression -> assertThat(literalExpression.getParent()).isEqualTo(duplicate));
final List<RuleAnnotationClauseText> duplicateRuleAnnotationClauses = duplicate.getAnnotationEntry();
assertThat(duplicateRuleAnnotationClauses.size()).isEqualTo(2);
assertAnnotationClauseText(duplicateRuleAnnotationClauses.get(0), RULE_ANNOTATION_CLAUSE_TEXT_1);
assertAnnotationClauseText(duplicateRuleAnnotationClauses.get(1), RULE_ANNOTATION_CLAUSE_TEXT_2);
assertRuleAnnotationClauseInstancesAreNotTheSame(annotationEntries.get(0), duplicateRuleAnnotationClauses.get(0));
assertRuleAnnotationClauseInstancesAreNotTheSame(annotationEntries.get(1), duplicateRuleAnnotationClauses.get(1));
assertThat(duplicateRuleAnnotationClauses).allSatisfy(ruleAnnotationClauseText -> assertThat(ruleAnnotationClauseText.getParent()).isEqualTo(duplicate));
assertThat(duplicate.getParent()).isEqualTo(dtable);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionContainerGridTest method testSpyHasExpressionWithExpressionSet.
@Test
public void testSpyHasExpressionWithExpressionSet() {
final HasExpression hasExpression = new HasExpression() {
private Expression expression = new LiteralExpression();
@Override
public Expression getExpression() {
return expression;
}
@Override
public void setExpression(final Expression expression) {
this.expression = expression;
}
@Override
public DMNModelInstrumentedBase asDMNModelInstrumentedBase() {
return null;
}
};
grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
final HasExpression spy = grid.spyHasExpression(hasExpression);
spy.setExpression(null);
assertThat(hasExpression.getExpression()).isNull();
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionContainerGridTest method testSelectCellWithDomainObjectInStunnerGraph.
@Test
public void testSelectCellWithDomainObjectInStunnerGraph() {
final int uiRowIndex = 0;
final int uiColumnIndex = 1;
final LiteralExpression domainObject = mock(LiteralExpression.class);
when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(domainObject);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
final Definition definition = mock(Definition.class);
when(node.getUUID()).thenReturn(NODE_UUID);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(domainObject);
grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
grid.selectCell(uiRowIndex, uiColumnIndex, false, true);
verify(gridLayer).select(eq(grid));
verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
assertThat(refreshFormPropertiesEvent.getUuid()).isEqualTo(NODE_UUID);
assertThat(refreshFormPropertiesEvent.getSession()).isEqualTo(session);
verify(cellSelectionManager).selectCell(eq(uiRowIndex), eq(uiColumnIndex), eq(false), eq(true));
}
Aggregations