use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult 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.MigrateResult in project kie-wb-common by kiegroup.
the class IntegrationServiceImpl method migrateFromJBPMDesignerToStunner.
private MigrateResult migrateFromJBPMDesignerToStunner(final MigrateRequest request) {
validateRequest(request);
final org.uberfire.java.nio.file.Path _path = Paths.convert(request.getPath());
final org.uberfire.java.nio.file.Path _target = _path.resolveSibling(request.getNewName() + request.getNewExtension());
final Path target = Paths.convert(_target);
if (ioService.exists(_target)) {
return new MigrateResult(target, STUNNER_PROCESS_ALREADY_EXIST, STUNNER_PROCESS_ALREADY_EXIST.i18nKey(), Collections.singletonList(request.getPath()));
}
request.getProjectDiagram().getMetadata().setPath(target);
request.getProjectDiagram().getMetadata().setTitle(request.getNewName());
diagramService.saveOrUpdate(request.getProjectDiagram());
return new MigrateResult(target);
}
use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult in project kie-wb-common by kiegroup.
the class IntegrationServiceImpl method migrateFromStunnerToJBPMDesigner.
private MigrateResult migrateFromStunnerToJBPMDesigner(final MigrateRequest request) {
validateRequest(request);
final org.uberfire.java.nio.file.Path _path = Paths.convert(request.getPath());
final org.uberfire.java.nio.file.Path _target = resolveTargetPath(_path, request.getNewName(), request.getNewExtension());
final Path target = Paths.convert(_target);
if (ioService.exists(_target)) {
return new MigrateResult(target, JBPM_DESIGNER_PROCESS_ALREADY_EXIST, JBPM_DESIGNER_PROCESS_ALREADY_EXIST.i18nKey(), Collections.singletonList(request.getPath()));
}
try {
ioService.startBatch(_target.getFileSystem());
ioService.move(_path, _target, optionFactory.makeCommentedOption(request.getCommitMessage()));
} catch (Exception e) {
final String message = String.format("An error was produced during diagram migration from Stunner to jBPMDesigner for diagram: %s", request.getPath());
LOGGER.error(message, e);
throw new RuntimeException(message, e);
} finally {
ioService.endBatch();
}
return new MigrateResult(target);
}
use of org.kie.workbench.common.stunner.bpmn.integration.service.MigrateResult 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.MigrateResult 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);
}
Aggregations