use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class WrapperUtilsTest method testGetDmnElementRefWithFakeNamespace.
@Test
public void testGetDmnElementRefWithFakeNamespace() {
final Decision drgElement = mock(Decision.class);
final View<? extends DMNElement> view = new ViewImpl<>(drgElement, null);
final String defaultNamespace = "://default";
final Name drgElementName = mock(Name.class);
final Id id = mock(Id.class);
final org.kie.workbench.common.dmn.api.definition.model.Definitions definitions = mock(org.kie.workbench.common.dmn.api.definition.model.Definitions.class);
when(id.getValue()).thenReturn("0000-1111-2222");
when(drgElementName.getValue()).thenReturn("fakeNamespace.Decision");
when(drgElement.getId()).thenReturn(id);
when(drgElement.getName()).thenReturn(drgElementName);
when(drgElement.getParent()).thenReturn(definitions);
when(definitions.getImport()).thenReturn(emptyList());
final QName actual = getDmnElementRef(definitions, view, defaultNamespace);
assertEquals(defaultNamespace, actual.getNamespaceURI());
assertEquals("0000-1111-2222", actual.getLocalPart());
assertEquals("", actual.getPrefix());
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class WrapperUtilsTest method testGetDmnElementRefWithoutNamespace.
@Test
public void testGetDmnElementRefWithoutNamespace() {
final Decision drgElement = mock(Decision.class);
final View<? extends DMNElement> view = new ViewImpl<>(drgElement, null);
final String defaultNamespace = "://default";
final Name drgElementName = mock(Name.class);
final Id id = mock(Id.class);
final org.kie.workbench.common.dmn.api.definition.model.Definitions definitions = mock(org.kie.workbench.common.dmn.api.definition.model.Definitions.class);
when(id.getValue()).thenReturn("0000-1111-2222");
when(drgElementName.getValue()).thenReturn("Decision");
when(drgElement.getId()).thenReturn(id);
when(drgElement.getName()).thenReturn(drgElementName);
when(drgElement.getParent()).thenReturn(definitions);
when(definitions.getImport()).thenReturn(emptyList());
final QName actual = getDmnElementRef(definitions, view, defaultNamespace);
assertEquals(defaultNamespace, actual.getNamespaceURI());
assertEquals("0000-1111-2222", actual.getLocalPart());
assertEquals("", actual.getPrefix());
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class WrapperUtilsTest method testGetDmnElementRefWithNamespace.
@Test
public void testGetDmnElementRefWithNamespace() {
final Decision drgElement = mock(Decision.class);
final View<? extends DMNElement> view = new ViewImpl<>(drgElement, null);
final Name drgElementName = mock(Name.class);
final Name importName = mock(Name.class);
final Id id = mock(Id.class);
final org.kie.workbench.common.dmn.api.definition.model.Definitions definitions = mock(org.kie.workbench.common.dmn.api.definition.model.Definitions.class);
final Import anImport = mock(Import.class);
final List<Import> imports = singletonList(anImport);
final String includedModelName = "includedModel";
final String defaultNamespace = "://default";
final String namespaceName = "include1";
final String importNamespace = "://namespace";
final Map<String, String> nsContext = new HashMap<>();
when(importName.getValue()).thenReturn(includedModelName);
when(anImport.getName()).thenReturn(importName);
when(anImport.getNamespace()).thenReturn(importNamespace);
when(id.getValue()).thenReturn("0000-1111-2222");
when(drgElementName.getValue()).thenReturn(includedModelName + ".Decision");
when(drgElement.getId()).thenReturn(id);
when(drgElement.getName()).thenReturn(drgElementName);
when(drgElement.getParent()).thenReturn(definitions);
nsContext.put(namespaceName, importNamespace);
when(definitions.getImport()).thenReturn(imports);
when(definitions.getNsContext()).thenReturn(nsContext);
final QName actual = getDmnElementRef(definitions, view, defaultNamespace);
assertEquals(defaultNamespace, actual.getNamespaceURI());
assertEquals("include1:0000-1111-2222", actual.getLocalPart());
assertEquals("", actual.getPrefix());
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class MonacoFEELSuggestionsTest method makeDecisionNode.
private NodeImpl<Definition<Decision>> makeDecisionNode(final String name, final BuiltInType builtInType) {
final NodeImpl<Definition<Decision>> node = makeNodeImpl();
final Definition<Decision> definition = makeDefinition();
final Decision decision = spy(new Decision());
final InformationItemPrimary informationItemPrimary = mock(InformationItemPrimary.class);
final QName qName = builtInType == null ? null : new QName(builtInType);
when(informationItemPrimary.getTypeRef()).thenReturn(qName);
when(node.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(decision);
decision.setName(new Name(name));
decision.setVariable(informationItemPrimary);
return node;
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class WrapperUtils method stunnerToDDExt.
private static JSIDMNShape stunnerToDDExt(final JSIDMNDiagram diagram, final List<String> dmnDiagramElementIds, final Definitions definitionsStunnerPojo, final View<? extends DMNElement> v, final String namespaceURI) {
final JSIDMNShape result = new JSIDMNShape();
final DMNElement definition = v.getDefinition();
final String dmnElementId = definition.getId().getValue();
final String shapeId = getShapeId(diagram, dmnDiagramElementIds, dmnElementId);
result.setId(shapeId);
result.setDmnElementRef(getDmnElementRef(definitionsStunnerPojo, v, namespaceURI));
final JSIBounds bounds = new JSIBounds();
result.setBounds(bounds);
bounds.setX(xOfBound(upperLeftBound(v)));
bounds.setY(yOfBound(upperLeftBound(v)));
result.setDMNLabel(new JSIDMNLabel());
// TODO {gcardosi}: HARDCODED
result.setIsCollapsed(false);
final JSIDMNStyle style = new JSIDMNStyle();
if (v.getDefinition() instanceof Decision) {
final Decision d = (Decision) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof InputData) {
InputData d = (InputData) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof BusinessKnowledgeModel) {
final BusinessKnowledgeModel d = (BusinessKnowledgeModel) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof KnowledgeSource) {
final KnowledgeSource d = (KnowledgeSource) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof TextAnnotation) {
final TextAnnotation d = (TextAnnotation) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
} else if (v.getDefinition() instanceof DecisionService) {
final DecisionService d = (DecisionService) v.getDefinition();
applyBounds(d.getDimensionsSet(), bounds);
applyStylingStyles(d.getStylingSet(), style);
final JSIDMNDecisionServiceDividerLine dl = new JSIDMNDecisionServiceDividerLine();
final JSIPoint leftPoint = new JSIPoint();
leftPoint.setX(v.getBounds().getUpperLeft().getX());
final double dlY = v.getBounds().getUpperLeft().getY() + d.getDividerLineY().getValue();
leftPoint.setY(dlY);
dl.addWaypoint(leftPoint);
final JSIPoint rightPoint = new JSIPoint();
rightPoint.setX(v.getBounds().getLowerRight().getX());
rightPoint.setY(dlY);
dl.addWaypoint(rightPoint);
result.setDMNDecisionServiceDividerLine(dl);
}
result.setStyle(getWrappedJSIDMNStyle(style));
return result;
}
Aggregations