use of org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel in project kie-wb-common by kiegroup.
the class DefaultValueUtilitiesTest method testUpdateNewNodeName_BusinessKnowledgeModel.
@Test
public void testUpdateNewNodeName_BusinessKnowledgeModel() {
// Add some existing nodes to ensure naming is not affected by existing content
graph.addNode(makeMockNode(new Decision()));
graph.addNode(makeMockNode(new InputData()));
graph.addNode(makeMockNode(new KnowledgeSource()));
graph.addNode(makeMockNode(new TextAnnotation()));
final BusinessKnowledgeModel bkm1 = new BusinessKnowledgeModel();
final BusinessKnowledgeModel bkm2 = new BusinessKnowledgeModel();
final BusinessKnowledgeModel bkm3 = new BusinessKnowledgeModel();
final BusinessKnowledgeModel bkm4 = new BusinessKnowledgeModel();
assertUpdateNewNodeName(bkm1, bkm2, (bkm) -> bkm.getName().getValue(), () -> BusinessKnowledgeModel.class.getSimpleName() + "-1", () -> BusinessKnowledgeModel.class.getSimpleName() + "-2");
// Update existing names manually and add two more
bkm1.getName().setValue("bkm");
bkm2.getName().setValue(BusinessKnowledgeModel.class.getSimpleName() + "-5");
assertUpdateNewNodeName(bkm3, bkm4, (bkm) -> bkm.getName().getValue(), () -> BusinessKnowledgeModel.class.getSimpleName() + "-6", () -> BusinessKnowledgeModel.class.getSimpleName() + "-7");
}
use of org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testSynchronizeBusinessKnowledgeModelNode.
@Test
public void testSynchronizeBusinessKnowledgeModelNode() {
final BusinessKnowledgeModel from = mock(BusinessKnowledgeModel.class);
final BusinessKnowledgeModel to = mock(BusinessKnowledgeModel.class);
final InformationItemPrimary variable = mock(InformationItemPrimary.class);
when(from.getVariable()).thenReturn(variable);
synchronizer.synchronizeBusinessKnowledgeModelNode(from, to);
verify(to).setVariable(variable);
}
use of org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel in project kie-wb-common by kiegroup.
the class DMNElementsSynchronizerTest method testSynchronizeSpecializedProperties_BusinessKnowledgeModelNode.
@Test
public void testSynchronizeSpecializedProperties_BusinessKnowledgeModelNode() {
doNothing().when(synchronizer).synchronizeBusinessKnowledgeModelNode(any(BusinessKnowledgeModel.class), any(BusinessKnowledgeModel.class));
final BusinessKnowledgeModel from = mock(BusinessKnowledgeModel.class);
final BusinessKnowledgeModel to = mock(BusinessKnowledgeModel.class);
synchronizer.synchronizeSpecializedProperties(from, to);
verify(synchronizer).synchronizeBusinessKnowledgeModelNode(from, to);
}
use of org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel in project kie-wb-common by kiegroup.
the class DMNDeepCloneProcessTest method testCloneWhenSourceIsBusinessKnowledgeModel.
@Test
public void testCloneWhenSourceIsBusinessKnowledgeModel() {
final BusinessKnowledgeModel source = buildBusinessKnowledgeModel();
setLinks(source, FIRST_URL, SECOND_URL);
final BusinessKnowledgeModel cloned = dmnDeepCloneProcess.clone(source, new BusinessKnowledgeModel());
assertThat(cloned).isNotNull();
assertThat(cloned.getId().getValue()).isNotEqualTo(SOURCE_ID);
assertThat(cloned.getName().getValue()).isEqualTo(BKM_SOURCE_NAME + FIRST_INDEX_IN_SUFFIX);
assertThat(cloned.getLinksHolder().getValue().getLinks()).hasSize(2).extracting(DMNExternalLink::getUrl).contains(FIRST_URL, SECOND_URL);
assertThat(cloned.getVariable().getTypeRef()).isEqualTo(BuiltInType.BOOLEAN.asQName());
assertThat(cloned.getEncapsulatedLogic()).isNotNull();
assertThat(cloned.getEncapsulatedLogic().getId().getValue()).isNotEqualTo(FUNCTION_ID);
assertThat(cloned.getEncapsulatedLogic().getKind()).isEqualTo(JAVA);
assertThat(cloned.getEncapsulatedLogic().getTypeRef()).isEqualTo(BuiltInType.BOOLEAN.asQName());
assertThat(cloned.getEncapsulatedLogic().getExpression()).isInstanceOf(Context.class);
assertThat(cloned.getEncapsulatedLogic().getExpression().getId()).isNotEqualTo(CONTEXT_ID);
assertThat(cloned.getEncapsulatedLogic().getExpression().getTypeRef()).isEqualTo(BuiltInType.NUMBER.asQName());
}
use of org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel in project kie-wb-common by kiegroup.
the class StunnerConverter method ddExtAugmentStunner.
private void ddExtAugmentStunner(final Node currentNode, final JSIDMNShape shape) {
final View content = (View) currentNode.getContent();
final Bound ulBound = upperLeftBound(content);
final Bound lrBound = lowerRightBound(content);
final Object definition = content.getDefinition();
if (definition instanceof Decision) {
final Decision decision = (Decision) definition;
internalAugment(shape, ulBound, decision.getDimensionsSet(), lrBound, decision.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof InputData) {
final InputData inputData = (InputData) definition;
internalAugment(shape, ulBound, inputData.getDimensionsSet(), lrBound, inputData.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof BusinessKnowledgeModel) {
final BusinessKnowledgeModel businessKnowledgeModel = (BusinessKnowledgeModel) definition;
internalAugment(shape, ulBound, businessKnowledgeModel.getDimensionsSet(), lrBound, businessKnowledgeModel.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof KnowledgeSource) {
final KnowledgeSource knowledgeSource = (KnowledgeSource) definition;
internalAugment(shape, ulBound, knowledgeSource.getDimensionsSet(), lrBound, knowledgeSource.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof TextAnnotation) {
final TextAnnotation textAnnotation = (TextAnnotation) definition;
internalAugment(shape, ulBound, textAnnotation.getDimensionsSet(), lrBound, textAnnotation.getStylingSet(), (line) -> {
/*NOP*/
});
} else if (definition instanceof DecisionService) {
final DecisionService decisionService = (DecisionService) definition;
internalAugment(shape, ulBound, decisionService.getDimensionsSet(), lrBound, decisionService.getStylingSet(), (dividerLineY) -> decisionService.setDividerLineY(new DecisionServiceDividerLineY(dividerLineY - ulBound.getY())));
}
}
Aggregations