Search in sources :

Example 6 with MarshallingMessage

use of org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage in project kie-wb-common by kiegroup.

the class IntegrationServiceImplTest method testGetDiagramByPathSuccessful.

@Test
@SuppressWarnings("unchecked")
public void testGetDiagramByPathSuccessful() {
    Graph<DefinitionSet, ?> graph = mock(Graph.class);
    DefinitionSet definitionSet = mock(DefinitionSet.class);
    String definitionValue = "theDefinitionValue";
    when(graph.getContent()).thenReturn(definitionSet);
    when(definitionSet.getDefinition()).thenReturn(definitionValue);
    when(factoryRegistry.getDiagramFactory(definitionValue, ProjectMetadata.class)).thenReturn(diagramFactory);
    ProjectDiagram diagram = mock(ProjectDiagram.class);
    when(diagramFactory.build(eq(NAME), any(ProjectMetadata.class), eq(graph))).thenReturn(diagram);
    List<MarshallingMessage> messages = new ArrayList<>();
    MarshallingResponse response = mockResponse(MarshallingResponse.State.SUCCESS, messages, graph);
    MarshallingResponse result = prepareTestGetDiagramByPath(response, null);
    assertEquals(MarshallingResponse.State.SUCCESS, result.getState());
    assertEquals(messages, result.getMessages());
    assertNotNull(result.getResult());
    assertEquals(diagram, result.getResult());
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) ArrayList(java.util.ArrayList) MarshallingResponse(org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Test(org.junit.Test)

Example 7 with MarshallingMessage

use of org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method testConvertLanes.

@Test
public void testConvertLanes() {
    Task task0_1 = mockTask("TASK0_1");
    Task task0_2 = mockTask("TASK0_2");
    Task task0_3 = mockTask("TASK0_3");
    Task task1_1 = mockTask("TASK1_1");
    Lane lane1 = mockLane("Lane1", "Lane1Name", task1_1);
    Task task2_1 = mockTask("TASK2_1");
    Lane lane2 = mockLane("Lane2", "Lane2Name", task2_1);
    LaneSet laneSet1 = mockLaneSet("LaneSet1", lane1, lane2);
    Task task3_2_1 = mockTask("TASK3_2_1");
    Task task3_2_2 = mockTask("TASK3_2_2");
    Lane lane3_2 = mockLane("Lane3_2", "Lane3_2Name", task3_2_1, task3_2_2);
    Task task3_1_2_1 = mockTask("TASK3_1_2_1");
    Lane lane3_1_2 = mockLane("Lane3_1_2", "Lane3_1_2Name", task3_1_2_1);
    Task task3_1_1_1_1 = mockTask("task3_1_1_1_1");
    Lane lane3_1_1_1 = mockLane("Lane3_1_1_1", "lane3_1_1_1Name", task3_1_1_1_1);
    Task task3_1_1_2_1 = mockTask("task3_1_1_2_1");
    Lane lane3_1_1_2 = mockLane("Lane3_1_1_2", "lane3_1_1_2Name", task3_1_1_2_1);
    Lane lane3_1_1 = mockLane("Lane3_1_1", "Lane3_1_1Name", mockLaneSet("laneSet3_1_1", lane3_1_1_1, lane3_1_1_2));
    Lane lane3_1 = mockLane("Lane3_1", "Lane3_1Name", mockLaneSet("laneSet3_1", lane3_1_1, lane3_1_2));
    Lane lane3 = mockLane("Lane3", "Lane3Name", mockLaneSet("LaneSet3", lane3_1, lane3_2));
    LaneSet laneSet2 = mockLaneSet("LaneSet2", lane3);
    List<FlowElement> flowElements = Arrays.asList(task0_1, task0_2, task0_3, task1_1, task2_1, task3_1_1_1_1, task3_1_1_2_1, task3_1_2_1, task3_2_1, task3_2_2);
    List<LaneSet> laneSets = Arrays.asList(laneSet1, laneSet2);
    Result<Map<String, BpmnNode>> result = converterDelegate.convertChildNodes(parentNode, flowElements, laneSets);
    Map<String, BpmnNode> nodes = result.value();
    assertEquals(16, nodes.size());
    assertEquals(9, parentNode.getChildren().size());
    assertHasChildren(parentNode, task0_1.getId(), task0_2.getId(), task0_3.getId(), lane1.getId(), lane2.getId(), lane3_2.getId(), lane3_1_2.getId(), lane3_1_1_1.getId(), lane3_1_1_2.getId());
    BpmnNode lane1Node = getChildById(parentNode, lane1.getId());
    assertNotNull(lane1Node);
    assertHasChildren(lane1Node, task1_1.getId());
    BpmnNode lane2Node = getChildById(parentNode, lane2.getId());
    assertNotNull(lane2Node);
    assertHasChildren(lane2Node, task2_1.getId());
    BpmnNode lane3_1_1_1Node = getChildById(parentNode, lane3_1_1_1.getId());
    assertNotNull(lane3_1_1_1Node);
    assertHasChildren(lane3_1_1_1Node, task3_1_1_1_1.getId());
    BpmnNode lane3_1_1_2Node = getChildById(parentNode, lane3_1_1_2.getId());
    assertNotNull(lane3_1_1_2Node);
    assertHasChildren(lane3_1_1_2Node, task3_1_1_2_1.getId());
    BpmnNode lane3_1_2Node = getChildById(parentNode, lane3_1_2.getId());
    assertNotNull(lane3_1_2Node);
    assertHasChildren(lane3_1_2Node, task3_1_2_1.getId());
    BpmnNode lane3_2Node = getChildById(parentNode, lane3_2.getId());
    assertHasChildren(lane3_2Node);
    assertHasChildren(lane3_2Node, task3_2_1.getId(), task3_2_2.getId());
    // assert messages for converted lane sets
    List<MarshallingMessage> messages = result.messages();
    assertEquals(4, messages.size());
    assertTrue(messages.stream().map(MarshallingMessage::getMessageKey).allMatch(MarshallingMessageKeys.childLaneSetConverted::equals));
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) Task(org.eclipse.bpmn2.Task) ManualTask(org.eclipse.bpmn2.ManualTask) Lane(org.eclipse.bpmn2.Lane) LaneSet(org.eclipse.bpmn2.LaneSet) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) FlowElement(org.eclipse.bpmn2.FlowElement) MarshallingMessageKeys(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessageKeys) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 8 with MarshallingMessage

use of org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage in project kie-wb-common by kiegroup.

the class MarshallingResponsePopupTest method testDisplayableValueForMessageWithoutTranslation.

@Test
public void testDisplayableValueForMessageWithoutTranslation() {
    List<?> messageArguments = new ArrayList<>();
    MarshallingMessage message = new MarshallingMessage.MarshallingMessageBuilder().messageKey(MESSAGE_KEY).message(MESSAGE).messageArguments(messageArguments).build();
    when(translationService.getValue(MESSAGE_KEY, toArray(messageArguments))).thenReturn("!!!" + MESSAGE_KEY + "!!!");
    assertEquals(MESSAGE, popup.displayableValue(message));
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with MarshallingMessage

use of org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage in project kie-wb-common by kiegroup.

the class IntegrationServiceImplTest method testGetDiagramByPathWithError.

@Test
@SuppressWarnings("unchecked")
public void testGetDiagramByPathWithError() {
    List<MarshallingMessage> messages = new ArrayList<>();
    MarshallingResponse response = mockResponse(MarshallingResponse.State.ERROR, messages, null);
    MarshallingResponse result = prepareTestGetDiagramByPath(response, null);
    assertEquals(MarshallingResponse.State.ERROR, result.getState());
    assertEquals(messages, result.getMessages());
    assertNull(result.getResult());
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) ArrayList(java.util.ArrayList) MarshallingResponse(org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse) Test(org.junit.Test)

Example 10 with MarshallingMessage

use of org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage in project kie-wb-common by kiegroup.

the class IntegrationServiceImplTest method testGetDiagramByPathWithUnexpectedError.

@Test
public void testGetDiagramByPathWithUnexpectedError() {
    List<MarshallingMessage> messages = new ArrayList<>();
    MarshallingResponse response = mockResponse(MarshallingResponse.State.ERROR, messages, null);
    RuntimeException unexpectedError = new RuntimeException("Unexpected error");
    expectedException.expectMessage("An error was produced while diagram loading from file " + PATH_URI);
    prepareTestGetDiagramByPath(response, unexpectedError);
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) ArrayList(java.util.ArrayList) MarshallingResponse(org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse) Test(org.junit.Test)

Aggregations

MarshallingMessage (org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage)11 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)6 MarshallingResponse (org.kie.workbench.common.stunner.core.marshaller.MarshallingResponse)4 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)2 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)1 InputStream (java.io.InputStream)1 Collection (java.util.Collection)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 BaseElement (org.eclipse.bpmn2.BaseElement)1 FlowElement (org.eclipse.bpmn2.FlowElement)1 Lane (org.eclipse.bpmn2.Lane)1 LaneSet (org.eclipse.bpmn2.LaneSet)1 ManualTask (org.eclipse.bpmn2.ManualTask)1 Task (org.eclipse.bpmn2.Task)1 BPMNEdge (org.eclipse.bpmn2.di.BPMNEdge)1 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)1