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