use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsDuplicatedButIsNotImported.
@Test
public void testMakeDragProxyCallbackImplWhenNodeIsDuplicatedButIsNotImported() {
final ClientSession currentSession = mock(ClientSession.class);
final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
final ShapeFactory factory = mock(ShapeFactory.class);
final DRGElement drgElement = mock(DRGElement.class);
final int x = 10;
final int y = 20;
final Graph<?, Node> graph = mock(Graph.class);
final List<Node> nodes = new ArrayList<>();
final String id1 = "123";
final String id2 = "123";
nodes.add(createNode(id1));
nodes.add(createNode(id2));
when(graph.nodes()).thenReturn(nodes);
when(drgElement.getId()).thenReturn(new Id(id1));
when(sessionManager.getCurrentSession()).thenReturn(currentSession);
when(currentSession.getCanvasHandler()).thenReturn(canvasHandler);
doReturn(graph).when(view).getGraph();
view.setIsImported(false);
view.makeDragProxyCallbackImpl(drgElement, factory).onComplete(x, y);
verify(buildCanvasShapeEvent).fire(any());
verify(notificationEvent, never()).fire(notificationEventArgumentCaptor.capture());
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DecisionComponentsItemViewTest method testDecisionComponentItemMouseDown.
@Test
public void testDecisionComponentItemMouseDown() {
final MouseDownEvent mouseDownEvent = mock(MouseDownEvent.class);
final Callback proxy = mock(Callback.class);
final DRGElement drgElement = mock(DRGElement.class);
final DMNShapeFactory factory = mock(DMNShapeFactory.class);
final ShapeGlyphDragHandler.Item item = mock(ShapeGlyphDragHandler.Item.class);
final Glyph glyph = mock(Glyph.class);
final int x = 10;
final int y = 20;
when(dmnShapeSet.getShapeFactory()).thenReturn(factory);
when(presenter.getDrgElement()).thenReturn(drgElement);
when(factory.getGlyph(any())).thenReturn(glyph);
when(mouseDownEvent.getX()).thenReturn(x);
when(mouseDownEvent.getY()).thenReturn(y);
doReturn(proxy).when(view).makeDragProxyCallbackImpl(drgElement, factory);
doReturn(item).when(view).makeDragHandler(glyph);
view.decisionComponentItemMouseDown(mouseDownEvent);
verify(shapeGlyphDragHandler).show(item, x, y, proxy);
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionStateTest method testGetModelDRGElements.
@Test
public void testGetModelDRGElements() {
final DRGElement drgElement1 = mock(DRGElement.class);
final DRGElement drgElement2 = mock(DRGElement.class);
final DRGElement drgElement3 = mock(DRGElement.class);
final DRGElement drgElement4 = mock(DRGElement.class);
final DRGElement drgElement5 = mock(DRGElement.class);
final DRGElement drgElement6 = mock(DRGElement.class);
when(dmnDiagramUtils.getDRGElements(stunnerDiagram1)).thenReturn(asList(drgElement1, drgElement2));
when(dmnDiagramUtils.getDRGElements(stunnerDiagram2)).thenReturn(asList(drgElement3, drgElement4, drgElement5));
when(dmnDiagramUtils.getDRGElements(stunnerDiagram3)).thenReturn(singletonList(drgElement6));
final List<DRGElement> drgElements = sessionState.getModelDRGElements();
assertTrue(drgElements.contains(drgElement1));
assertTrue(drgElements.contains(drgElement2));
assertTrue(drgElements.contains(drgElement3));
assertTrue(drgElements.contains(drgElement4));
assertTrue(drgElements.contains(drgElement5));
assertTrue(drgElements.contains(drgElement6));
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNDocumentationFactoryTest method testCreate.
@Test
public void testCreate() {
final String diagramName = "Diagram name";
final String diagramDescription = "Diagram description";
final String image = "<image>";
final String admin = "admin";
final String currentDate = "2 January 1992";
final String namespace = "://namespace";
final String expectedDroolsLogo = "droolsLogo";
final String expectedSupportedByRedHatLogo = "supportedByRedHatLogo";
final List<DRGElement> drgElements = singletonList(mock(DRGElement.class));
final ItemDefinition uuid = makeItemDefinition("tUUID", "String");
final ItemDefinition id = makeItemDefinition("id", "tUUID");
final ItemDefinition name = makeItemDefinition("name", "String");
final ItemDefinition person = makeItemDefinition("tPerson", null, id, name);
final List<ItemDefinition> itemDefinitions = asList(uuid, person);
final UnaryTests unaryTests = new UnaryTests();
unaryTests.setText(new Text("[1, 2, 3]"));
id.setAllowedValues(unaryTests);
id.setIsCollection(true);
doReturn(image).when(documentationFactory).getDiagramImage();
doReturn(i18n).when(documentationFactory).getDocumentationI18n();
doReturn(moment).when(documentationFactory).moment();
when(definitions.getNamespace()).thenReturn(new Text(namespace));
when(graphUtils.getDefinitions(diagram)).thenReturn(definitions);
when(definitions.getName()).thenReturn(new Name(diagramName));
when(definitions.getDescription()).thenReturn(new Description(diagramDescription));
when(graphUtils.getDRGElements(diagram)).thenReturn(drgElements);
when(definitions.getItemDefinition()).thenReturn(itemDefinitions);
when(sessionInfo.getIdentity()).thenReturn(user);
when(user.getIdentifier()).thenReturn(admin);
when(moment.format("D MMMM YYYY")).thenReturn(currentDate);
final DMNDocumentation documentation = documentationFactory.create(diagram);
assertEquals(namespace, documentation.getNamespace());
assertEquals(diagramName, documentation.getDiagramName());
assertEquals(diagramDescription, documentation.getDiagramDescription());
assertEquals(image, documentation.getDiagramImage());
assertEquals(admin, documentation.getCurrentUser());
assertEquals(currentDate, documentation.getCurrentDate());
assertEquals(expectedDroolsLogo, documentation.getDroolsLogoURI());
assertEquals(expectedSupportedByRedHatLogo, documentation.getSupportedByRedHatLogoURI());
assertEquals(i18n, documentation.getI18n());
assertNotNull(documentation.getModuleName());
assertNotNull(documentation.getDataTypes());
assertTrue(documentation.hasGraphNodes());
final List<DMNDocumentationDataType> dataTypes = documentation.getDataTypesList();
assertEquals(4, dataTypes.size());
assertEquals("", dataTypes.get(0).getConstraint());
assertEquals("tUUID", dataTypes.get(0).getName());
assertEquals("String", dataTypes.get(0).getType());
assertEquals("", dataTypes.get(0).getListLabel());
assertEquals(0, dataTypes.get(0).getLevel());
assertTrue(dataTypes.get(0).isTopLevel());
assertEquals("", dataTypes.get(1).getConstraint());
assertEquals("tPerson", dataTypes.get(1).getName());
assertEquals("Structure", dataTypes.get(1).getType());
assertEquals("", dataTypes.get(1).getListLabel());
assertEquals(0, dataTypes.get(1).getLevel());
assertTrue(dataTypes.get(1).isTopLevel());
assertEquals("Constraints: [1, 2, 3]", dataTypes.get(2).getConstraint());
assertEquals("id", dataTypes.get(2).getName());
assertEquals("tUUID", dataTypes.get(2).getType());
assertEquals("List: Yes", dataTypes.get(2).getListLabel());
assertEquals(1, dataTypes.get(2).getLevel());
assertFalse(dataTypes.get(2).isTopLevel());
assertEquals("", dataTypes.get(3).getConstraint());
assertEquals("name", dataTypes.get(3).getName());
assertEquals("String", dataTypes.get(3).getType());
assertEquals("", dataTypes.get(3).getListLabel());
assertEquals(1, dataTypes.get(3).getLevel());
assertFalse(dataTypes.get(3).isTopLevel());
}
use of org.kie.workbench.common.dmn.api.definition.model.DRGElement in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionTest method testGetDRGElementFromContentDefinition.
@Test
public void testGetDRGElementFromContentDefinition() {
final Node nodeWithContentDefinition = mock(Node.class);
final Definition definition = mock(Definition.class);
final DRGElement drgElement = mock(DRGElement.class);
when(nodeWithContentDefinition.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(drgElement);
final DRGElement actual = dmnDiagramsSession.getDRGElementFromContentDefinition(nodeWithContentDefinition);
assertEquals(drgElement, actual);
}
Aggregations