Search in sources :

Example 6 with MigrateRequest

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

the class IntegrationServiceImplTest method testMigrateFromStunnerToJBPMDesignerFileAlreadyExists.

@Test
public void testMigrateFromStunnerToJBPMDesignerFileAlreadyExists() {
    MigrateRequest request = MigrateRequest.newFromStunnerToJBPMDesigner(path, NEW_FILE_NAME, NEW_EXTENSION, COMMIT_MESSAGE);
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true);
    MigrateResult result = service.migrateDiagram(request);
    verify(ioService, never()).move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class), any(CommentedOption.class));
    verify(ioService, never()).startBatch(any(FileSystem.class));
    verify(ioService, never()).endBatch();
    assertTrue(result.hasError());
    assertEquals(IntegrationService.ServiceError.JBPM_DESIGNER_PROCESS_ALREADY_EXIST, result.getError());
    assertEquals(IntegrationService.ServiceError.JBPM_DESIGNER_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) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) FileSystem(org.uberfire.java.nio.file.FileSystem) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest) Test(org.junit.Test)

Example 7 with MigrateRequest

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

the class IntegrationServiceImplTest method testMigrateFromStunnerToJBPMDesignerUnexpectedError.

@Test
public void testMigrateFromStunnerToJBPMDesignerUnexpectedError() {
    MigrateRequest request = MigrateRequest.newFromStunnerToJBPMDesigner(path, NEW_FILE_NAME, NEW_EXTENSION, COMMIT_MESSAGE);
    when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(false);
    when(ioService.move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class), any(CommentedOption.class))).thenThrow(new IOException("Unexpected error"));
    expectedException.expectMessage("An error was produced during diagram migration from Stunner to jBPMDesigner for diagram: " + PATH_URI);
    service.migrateDiagram(request);
    verify(ioService).move(any(org.uberfire.java.nio.file.Path.class), any(org.uberfire.java.nio.file.Path.class), any(CommentedOption.class));
    verify(ioService).startBatch(any(FileSystem.class));
    verify(ioService).endBatch();
}
Also used : Path(org.uberfire.backend.vfs.Path) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) FileSystem(org.uberfire.java.nio.file.FileSystem) IOException(org.uberfire.java.nio.IOException) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest) Test(org.junit.Test)

Example 8 with MigrateRequest

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

the class IntegrationHandlerImplTest method testMigrateFromStunnerToJBPMDesignerSuccessful.

private void testMigrateFromStunnerToJBPMDesignerSuccessful(boolean isDirty) {
    MigrateRequest expectedRequest = MigrateRequest.newFromStunnerToJBPMDesigner(stunnerPath, STUNNER_NAME, BPMN2_EXTENSION, ToJBPMCommitMessage);
    Path resultPath = mock(Path.class);
    MigrateResult result = new MigrateResult(resultPath, null, null, null);
    when(integrationService.migrateDiagram(expectedRequest)).thenReturn(result);
    handler.migrateFromStunnerToJBPMDesigner(stunnerPath, place, isDirty, saveSuccessfulCommand);
    verifySavePopupWasShownAndRespond(isDirty, true);
    verifyUserWasAskedForStartingToJBPMMigrationAndRespond(true);
    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 9 with MigrateRequest

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

the class IntegrationHandlerImplTest method testMigrateFromJBPMDesignerToStunnerMarshallingWithErrors.

private void testMigrateFromJBPMDesignerToStunnerMarshallingWithErrors(boolean isDirty) {
    List<MarshallingMessage> messages = Arrays.asList(mock(MarshallingMessage.class), mock(MarshallingMessage.class));
    prepareMigrateFromJBPMDesignerToStunner(MarshallingResponse.State.ERROR, messages);
    MigrateRequest expectedRequest = MigrateRequest.newFromJBPMDesignerToStunner(jbpmPath, JBPM_NAME, BPMN_EXTENSION, ToStunnerCommitMessage, projectDiagram);
    MigrateResult result = new MigrateResult(null, IntegrationService.ServiceError.JBPM_DESIGNER_PROCESS_ALREADY_EXIST, "messageKey", new ArrayList<>());
    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);
    verifyMarshallingResponseWithErrorsWereShown(messages);
}
Also used : MarshallingMessage(org.kie.workbench.common.stunner.core.marshaller.MarshallingMessage) MigrateResult(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult) MigrateRequest(org.kie.workbench.common.stunner.bpmn.integration.service.MigrateRequest)

Example 10 with MigrateRequest

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

the class IntegrationHandlerImplTest method testMigrateFromStunnerWithServiceError.

private void testMigrateFromStunnerWithServiceError(boolean isDirty) {
    MigrateRequest expectedRequest = MigrateRequest.newFromStunnerToJBPMDesigner(stunnerPath, STUNNER_NAME, BPMN2_EXTENSION, ToJBPMCommitMessage);
    Path resultPath = mock(Path.class);
    String messageKey = "messageKey";
    List<?> messageArguments = new ArrayList<>();
    MigrateResult result = new MigrateResult(resultPath, IntegrationService.ServiceError.JBPM_DESIGNER_PROCESS_ALREADY_EXIST, messageKey, messageArguments);
    when(integrationService.migrateDiagram(expectedRequest)).thenReturn(result);
    handler.migrateFromStunnerToJBPMDesigner(stunnerPath, place, isDirty, saveSuccessfulCommand);
    verifySavePopupWasShownAndRespond(isDirty, true);
    verifyUserWasAskedForStartingToJBPMMigrationAndRespond(true);
    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)

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