use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.
the class DecisionServiceParametersListWidgetTest method createInputData.
private InputData createInputData(final String name, final String type) {
final InputData input = mock(InputData.class);
final InformationItemPrimary variable = mock(InformationItemPrimary.class);
final QName typeRef = mock(QName.class);
when(input.getVariable()).thenReturn(variable);
when(input.getName()).thenReturn(new Name(name));
when(typeRef.getLocalPart()).thenReturn(type);
when(variable.getTypeRef()).thenReturn(typeRef);
return input;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testSynchronizeDecisionNodeNode.
@Test
public void testSynchronizeDecisionNodeNode() {
final Decision from = mock(Decision.class);
final Decision to = mock(Decision.class);
final Question question = mock(Question.class);
final AllowedAnswers allowedAnswers = mock(AllowedAnswers.class);
final Expression expression = mock(Expression.class);
final InformationItemPrimary variable = mock(InformationItemPrimary.class);
when(from.getQuestion()).thenReturn(question);
when(from.getAllowedAnswers()).thenReturn(allowedAnswers);
when(from.getExpression()).thenReturn(expression);
when(from.getVariable()).thenReturn(variable);
synchronizer.synchronizeDecisionNode(from, to);
verify(to).setQuestion(question);
verify(to).setAllowedAnswers(allowedAnswers);
verify(to).setExpression(expression);
verify(to).setVariable(variable);
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.
the class DMNIncludedNodeFactoryTest method makeInformationItemPrimary.
private InformationItemPrimary makeInformationItemPrimary(final String localPart) {
final InformationItemPrimary informationItemPrimary = new InformationItemPrimary();
informationItemPrimary.setTypeRef(new QName(QName.NULL_NS_URI, localPart, QName.DEFAULT_NS_PREFIX));
return informationItemPrimary;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.
the class BusinessKnowledgeModelConverter method nodeFromDMN.
@Override
public Node<View<BusinessKnowledgeModel>, ?> nodeFromDMN(final NodeEntry nodeEntry) {
final JSITBusinessKnowledgeModel dmn = Js.uncheckedCast(nodeEntry.getDmnElement());
@SuppressWarnings("unchecked") final Node<View<BusinessKnowledgeModel>, ?> node = (Node<View<BusinessKnowledgeModel>, ?>) factoryManager.newElement(nodeEntry.getId(), getDefinitionId(BusinessKnowledgeModel.class)).asNode();
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final Name name = new Name(dmn.getName());
final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
final JSITFunctionDefinition dmnFunctionDefinition = dmn.getEncapsulatedLogic();
final FunctionDefinition functionDefinition = FunctionDefinitionPropertyConverter.wbFromDMN(dmnFunctionDefinition, nodeEntry.getComponentWidthsConsumer());
final BusinessKnowledgeModel bkm = new BusinessKnowledgeModel(id, description, name, informationItem, functionDefinition, new StylingSet(), new GeneralRectangleDimensionsSet());
bkm.setDiagramId(nodeEntry.getDiagramId());
node.getContent().setDefinition(bkm);
if (Objects.nonNull(informationItem)) {
informationItem.setParent(bkm);
}
if (Objects.nonNull(functionDefinition)) {
functionDefinition.setParent(bkm);
}
if (Objects.nonNull(dmnFunctionDefinition)) {
nodeEntry.getComponentWidthsConsumer().accept(dmnFunctionDefinition.getId(), functionDefinition);
}
DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, bkm);
return node;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenDecisionTypeRefIsStructureAndOneSubfieldIsStructure.
@Test
public void testModelEnrichmentWhenDecisionTypeRefIsStructureAndOneSubfieldIsStructure() {
final DMNGraphUtils dmnGraphUtils = mock(DMNGraphUtils.class);
final Definitions definitions = mock(Definitions.class);
final HasExpression hasExpression = mock(HasExpression.class);
final Decision decision = mock(Decision.class);
final InformationItemPrimary informationItemPrimary = mock(InformationItemPrimary.class);
final ItemDefinition tCompany = mockTCompanyStructure();
when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
when(definitions.getItemDefinition()).thenReturn(Collections.singletonList(tCompany));
when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(decision);
when(decision.getVariable()).thenReturn(informationItemPrimary);
when(informationItemPrimary.getTypeRef()).thenReturn(new QName("", TYPE_COMPANY));
final DecisionTableEditorDefinitionEnricher enricher = new DecisionTableEditorDefinitionEnricher(null, dmnGraphUtils, itemDefinitionUtils);
final Optional<DecisionTable> oModel = definition.getModelClass();
final DecisionTable model = oModel.get();
enricher.buildOutputClausesByDataType(hasExpression, model, new DecisionRule());
final List<OutputClause> outputClauses = model.getOutput();
assertThat(outputClauses.size()).isEqualTo(2);
final OutputClause outputClause1 = outputClauses.get(0);
final OutputClause outputClause2 = outputClauses.get(1);
assertEquals("address", outputClause1.getName());
assertEquals(ANY.asQName(), outputClause1.getTypeRef());
assertEquals("name", outputClause2.getName());
assertEquals(STRING.asQName(), outputClause2.getTypeRef());
}
Aggregations