use of org.kie.workbench.common.dmn.api.definition.model.InputData in project kie-wb-common by kiegroup.
the class DecisionComponentFilterTest method testQueryFilteredByTerm.
@Test
public void testQueryFilteredByTerm() {
final DecisionComponentsItem item1 = item("Can Drive?", new Decision());
final DecisionComponentsItem item2 = item("Is Allowed?", new Decision());
final DecisionComponentsItem item3 = item("Age", new InputData());
final DecisionComponentsItem item4 = item("Name", new InputData());
final Stream<DecisionComponentsItem> stream = Stream.of(item1, item2, item3, item4);
filter.setTerm("name");
final Stream<DecisionComponentsItem> query = filter.query(stream);
final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList());
final List<DecisionComponentsItem> expectedResult = singletonList(item4);
assertEquals(expectedResult, actualResult);
}
use of org.kie.workbench.common.dmn.api.definition.model.InputData in project kie-wb-common by kiegroup.
the class DMNDeepCloneProcessTest method testCloneWhenSourceIsInputData.
@Test
public void testCloneWhenSourceIsInputData() {
final InputData source = buildInputData();
setLinks(source, FIRST_URL, SECOND_URL);
final InputData cloned = dmnDeepCloneProcess.clone(source, new InputData());
assertThat(cloned).isNotNull();
assertThat(cloned.getId().getValue()).isNotEqualTo(SOURCE_ID);
assertThat(cloned.getName().getValue()).isEqualTo(INPUT_DATA_NAME + FIRST_INDEX_IN_SUFFIX);
assertThat(cloned.getVariable().getTypeRef()).isEqualTo(BuiltInType.STRING.asQName());
assertThat(cloned.getLinksHolder().getValue().getLinks()).hasSize(2).extracting(DMNExternalLink::getUrl).contains(FIRST_URL, SECOND_URL);
}
use of org.kie.workbench.common.dmn.api.definition.model.InputData in project kie-wb-common by kiegroup.
the class TextAnnotationTextPropertyProviderImplTest method checkSupportsTextAnnotationElements.
@Test
@SuppressWarnings("unchecked")
public void checkSupportsTextAnnotationElements() {
assertTrue(provider.supports(element));
final Element other = mock(Element.class);
final Definition otherContent = mock(Definition.class);
final InputData otherDefinition = mock(InputData.class);
when(other.getContent()).thenReturn(otherContent);
when(otherContent.getDefinition()).thenReturn(otherDefinition);
assertFalse(provider.supports(other));
}
use of org.kie.workbench.common.dmn.api.definition.model.InputData in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method enrichInputClauses.
@SuppressWarnings("unchecked")
void enrichInputClauses(final String uuid, final DecisionTable dtable) {
final Graph<?, Node> graph = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph();
final Node<?, Edge> node = graph.getNode(uuid);
if (Objects.isNull(node)) {
return;
}
// Get all Decision nodes feeding into this DecisionTable
final List<Decision> decisionSet = node.getInEdges().stream().map(Edge::getSourceNode).map(Node::getContent).filter(content -> content instanceof Definition).map(content -> (Definition) content).map(Definition::getDefinition).filter(definition -> definition instanceof Decision).map(definition -> (Decision) definition).collect(Collectors.toList());
// Get all InputData nodes feeding into this DecisionTable
final List<InputData> inputDataSet = node.getInEdges().stream().map(Edge::getSourceNode).map(Node::getContent).filter(content -> content instanceof Definition).map(content -> (Definition) content).map(Definition::getDefinition).filter(definition -> definition instanceof InputData).map(definition -> (InputData) definition).collect(Collectors.toList());
if (decisionSet.isEmpty() && inputDataSet.isEmpty()) {
return;
}
// Extract individual components of InputData TypeRefs
final Definitions definitions = dmnGraphUtils.getModelDefinitions();
final List<ClauseRequirement> inputClauseRequirements = new ArrayList<>();
decisionSet.forEach(decision -> addInputClauseRequirement(decision.getVariable().getTypeRef(), definitions, inputClauseRequirements, decision.getName().getValue()));
inputDataSet.forEach(inputData -> addInputClauseRequirement(inputData.getVariable().getTypeRef(), definitions, inputClauseRequirements, inputData.getName().getValue()));
// Add InputClause columns for each InputData TypeRef component, sorted alphabetically
dtable.getInput().clear();
dtable.getRule().stream().forEach(decisionRule -> decisionRule.getInputEntry().clear());
inputClauseRequirements.stream().sorted(Comparator.comparing(inputClauseRequirement -> inputClauseRequirement.text)).forEach(inputClauseRequirement -> {
final InputClause inputClause = new InputClause();
final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression();
literalExpression.getText().setValue(inputClauseRequirement.text);
literalExpression.setTypeRef(inputClauseRequirement.typeRef);
inputClause.setInputExpression(literalExpression);
dtable.getInput().add(inputClause);
dtable.getRule().stream().forEach(decisionRule -> {
final UnaryTests decisionRuleUnaryTest = new UnaryTests();
decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT);
decisionRule.getInputEntry().add(decisionRuleUnaryTest);
decisionRuleUnaryTest.setParent(decisionRule);
});
inputClause.setParent(dtable);
literalExpression.setParent(inputClause);
});
}
use of org.kie.workbench.common.dmn.api.definition.model.InputData in project kie-wb-common by kiegroup.
the class DMNIncludedModelHandlerTest method testDestroy.
@Test
public void testDestroy() {
final Decision drgElement1 = makeDecision("model1.tUUID", "string", true);
final Decision drgElement2 = makeDecision("model1.imported person", "model1.tPerson", true);
final InputData drgElement3 = makeInputData("local person", "model1.tPerson", false);
final InputData drgElement4 = makeInputData("regular DRG Element", "boolean", false);
final List<DRGElement> drgElements = asList(drgElement1, drgElement2, drgElement3, drgElement4);
doNothing().when(handler).deleteDRGElement(any());
when(dmnGraphUtils.getModelDRGElements()).thenReturn(drgElements);
handler.destroy("model1");
verify(handler).deleteDRGElement(drgElement1);
verify(handler).deleteDRGElement(drgElement2);
}
Aggregations