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());
}
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();
}
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();
}
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);
}
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);
}
Aggregations