Search in sources :

Example 1 with MigrateRequest

use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest in project kie-wb-common by kiegroup.

the class IntegrationHandlerImplTest method testMigrateFromJBPMDesignerToStunnerWithServiceError.

private void testMigrateFromJBPMDesignerToStunnerWithServiceError(boolean isDirty, List<MarshallingMessage> messages) {
    prepareMigrateFromJBPMDesignerToStunner(MarshallingResponse.State.SUCCESS, messages);
    MigrateRequest expectedRequest = MigrateRequest.newFromJBPMDesignerToStunner(jbpmPath, JBPM_NAME, BPMN_EXTENSION, ToStunnerCommitMessage, projectDiagram);
    Path resultPath = mock(Path.class);
    String messageKey = "messageKey";
    List<?> messageArguments = new ArrayList<>();
    MigrateResult result = new MigrateResult(resultPath, IntegrationService.ServiceError.STUNNER_PROCESS_ALREADY_EXIST, messageKey, messageArguments);
    when(integrationService.migrateDiagram(expectedRequest)).thenReturn(result);
    handler.migrateFromJBPMDesignerToStunner(jbpmPath, place, isDirty, saveSuccessfulCommand);
    // ask user for saving and say yes.
    verifySavePopupWasShownAndRespond(isDirty, true);
    // ask user for starting the migration and say yes
    verifyUserWasAskedForStartingToStunnerMigrationAndRespond(true);
    // show the marshaling messages and ask user for proceeding with the migration
    if (!messages.isEmpty()) {
        verifyMarshallingResponseWasShownAndRespond(messages, true);
    } else {
        verifyMarshallingResponseWasNeverShown();
    }
    when(translationService.getValue(messageKey, messageArguments.toArray())).thenReturn(ERROR);
    errorPopup.showMessage(ERROR);
}
Also used : Path(org.uberfire.backend.vfs.Path) MigrateResult(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest)

Example 2 with MigrateRequest

use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest in project kie-wb-common by kiegroup.

the class IntegrationHandlerImplTest method testMigrateFromJBPMDesignerToStunnerSuccessful.

private void testMigrateFromJBPMDesignerToStunnerSuccessful(boolean isDirty, List<MarshallingMessage> messages) {
    prepareMigrateFromJBPMDesignerToStunner(MarshallingResponse.State.SUCCESS, messages);
    MigrateRequest expectedRequest = MigrateRequest.newFromJBPMDesignerToStunner(jbpmPath, JBPM_NAME, BPMN_EXTENSION, ToStunnerCommitMessage, projectDiagram);
    Path resultPath = mock(Path.class);
    MigrateResult result = new MigrateResult(resultPath, null, null, null);
    when(integrationService.migrateDiagram(expectedRequest)).thenReturn(result);
    handler.migrateFromJBPMDesignerToStunner(jbpmPath, place, isDirty, saveSuccessfulCommand);
    // ask user for saving and say yes.
    verifySavePopupWasShownAndRespond(isDirty, true);
    // ask user for starting the migration and say yes
    verifyUserWasAskedForStartingToStunnerMigrationAndRespond(true);
    // show the marshaling messages and ask user for proceeding with the migration
    if (!messages.isEmpty()) {
        verifyMarshallingResponseWasShownAndRespond(messages, true);
    } else {
        verifyMarshallingResponseWasNeverShown();
    }
    verifyMigrationFinished();
}
Also used : Path(org.uberfire.backend.vfs.Path) MigrateResult(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest)

Example 3 with MigrateRequest

use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest in project kie-wb-common by kiegroup.

the class IntegrationServiceImplTest method testMigrateFromJBPMDesignerToStunnerFileAlreadyExists.

@Test
public void testMigrateFromJBPMDesignerToStunnerFileAlreadyExists() {
    ProjectDiagram projectDiagram = mock(ProjectDiagram.class);
    ProjectMetadata metadata = mock(ProjectMetadata.class);
    when(projectDiagram.getMetadata()).thenReturn(metadata);
    MigrateRequest request = MigrateRequest.newFromJBPMDesignerToStunner(path, NEW_FILE_NAME, NEW_EXTENSION, COMMIT_MESSAGE, projectDiagram);
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);
    MigrateResult result = service.migrateDiagram(request);
    verify(diagramService, never()).saveOrUpdate(projectDiagram);
    verify(metadata, never()).setTitle(anyString());
    verify(metadata, never()).setPath(anyObject());
    assertTrue(result.hasError());
    assertEquals(IntegrationService.ServiceError.STUNNER_PROCESS_ALREADY_EXIST, result.getError());
    assertEquals(IntegrationService.ServiceError.STUNNER_PROCESS_ALREADY_EXIST.i18nKey(), result.getMessageKey());
    assertEquals(1, result.getMessageArguments().size());
    assertEquals(path.toString(), result.getMessageArguments().get(0).toString());
}
Also used : Path(org.uberfire.backend.vfs.Path) MigrateResult(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult) ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Test(org.junit.Test)

Example 4 with MigrateRequest

use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest in project kie-wb-common by kiegroup.

the class IntegrationServiceImplTest method testMigrateFromStunnerToJBPMDesignerSuccessful.

@Test
public void testMigrateFromStunnerToJBPMDesignerSuccessful() {
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(false);
    MigrateRequest request = MigrateRequest.newFromStunnerToJBPMDesigner(path, NEW_FILE_NAME, NEW_EXTENSION, COMMIT_MESSAGE);
    MigrateResult result = service.migrateDiagram(request);
    verify(ioService).move(sourcePathCaptor.capture(), targetPathCaptor.capture(), eq(commentedOption));
    assertEquals(PATH_URI, sourcePathCaptor.getValue().toUri().toString());
    assertEquals(EXPECTED_FILE_URI, targetPathCaptor.getValue().toUri().toString());
    verify(ioService).startBatch(any(FileSystem.class));
    verify(ioService).endBatch();
    assertFalse(result.hasError());
    assertEquals(EXPECTED_FILE_URI, result.getPath().toURI());
}
Also used : Path(org.uberfire.backend.vfs.Path) MigrateResult(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult) FileSystem(org.uberfire.java.nio.file.FileSystem) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest) Test(org.junit.Test)

Example 5 with MigrateRequest

use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest in project kie-wb-common by kiegroup.

the class IntegrationServiceImplTest method testMigrateFromJBPMDesignerToStunnerSuccessful.

@Test
public void testMigrateFromJBPMDesignerToStunnerSuccessful() {
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(false);
    ProjectDiagram projectDiagram = mock(ProjectDiagram.class);
    ProjectMetadata metadata = mock(ProjectMetadata.class);
    when(projectDiagram.getMetadata()).thenReturn(metadata);
    MigrateRequest request = MigrateRequest.newFromJBPMDesignerToStunner(path, NEW_FILE_NAME, NEW_EXTENSION, COMMIT_MESSAGE, projectDiagram);
    MigrateResult result = service.migrateDiagram(request);
    verify(diagramService).saveOrUpdate(projectDiagram);
    verify(metadata).setTitle(NEW_FILE_NAME);
    verify(metadata).setPath(vfsTargetPathCaptor.capture());
    assertEquals(EXPECTED_FILE_URI, vfsTargetPathCaptor.getValue().toURI());
    assertFalse(result.hasError());
    assertEquals(EXPECTED_FILE_URI, result.getPath().toURI());
}
Also used : Path(org.uberfire.backend.vfs.Path) MigrateResult(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult) ProjectMetadata(org.kie.workbench.common.stunner.project.diagram.ProjectMetadata) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Test(org.junit.Test)

Aggregations

MigrateRequest (org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest)10 MigrateResult (org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult)9 Path (org.uberfire.backend.vfs.Path)9 Test (org.junit.Test)5 FileSystem (org.uberfire.java.nio.file.FileSystem)3 ArrayList (java.util.ArrayList)2 ProjectDiagram (org.kie.workbench.common.stunner.project.diagram.ProjectDiagram)2 ProjectMetadata (org.kie.workbench.common.stunner.project.diagram.ProjectMetadata)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)2 MarshallingMessage (org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage)1 IOException (org.uberfire.java.nio.IOException)1