Commit bbc29502 authored by Romain Bioteau's avatar Romain Bioteau Committed by Adrien
Browse files

fix(webservice) Update webservice connector (#286)

* fix(webservice) Update webservice connector

* Add proxy support
* Fix redirect issue

fixes BS-16121
parent a7e3bf20
......@@ -14381,5 +14381,8 @@
<releases xmi:id="_V5DkcKwLEeaAKfvw_yYhbg" date="2016-11-16T10:43:27.494+0100" label="7.4.0-004">
<changes xsi:type="history:MigrationChange" xmi:id="_V5DkcawLEeaAKfvw_yYhbg" migration="org.bonitasoft.studio.migration.custom.migration.connector.UpdateRestConnectorVersionTo100"/>
</releases>
<releases xmi:id="_NyHXsO3kEeafiZdzQoO6tA" date="2017-02-08T10:43:27.494+0100" label="7.5.0-001">
<changes xsi:type="history:MigrationChange" xmi:id="_NyHXse3kEeafiZdzQoO6tA" migration="org.bonitasoft.studio.migration.custom.migration.connector.UpdateWebServiceConnectorVersionTo110"/>
</releases>
<releases xmi:id="_15TmyGnREeaTLbmqFFisdA"/>
</history:History>
......@@ -49,7 +49,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.bonitasoft.studio.connectors.model;bundle-version="6.4.0",
org.eclipse.e4.core.services,
org.eclipse.e4.core.di;bundle-version="1.4.0",
com.google.guava;bundle-version="11.0.1";visibility:=reexport
com.google.guava;bundle-version="11.0.1";visibility:=reexport,
org.eclipse.emf.edapt.history
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.api,
......
......@@ -14,30 +14,34 @@
*/
package org.bonitasoft.studio.common;
import java.io.File;
import java.net.URL;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.edapt.common.ResourceUtils;
import org.eclipse.emf.edapt.spi.history.History;
/**
* @author Romain Bioteau
*/
public class ModelVersion {
public static final String VERSION_6_0_0_ALPHA = "6.0.0-Alpha";
public static final String CURRENT_VERSION = "7.4.0-004";
public static boolean sameVersion(final String version) {
return CURRENT_VERSION.equals(version);
public static final String CURRENT_VERSION = lastModelVersion();
}
public static boolean sameMinorVersion(final String version) {
if (version == null) {
return false;
}
final String minor = CURRENT_VERSION.substring(0, CURRENT_VERSION.lastIndexOf("."));
final String[] split = version.split("\\.");
String testedVersion = version;
if (split.length > 2) {
testedVersion = split[0] + "." + split[1];
private static String lastModelVersion() {
try {
final URL resource = Platform.getBundle("org.bonitasoft.studio-models").getResource("process.history");
final URI historyURI = URI.createFileURI(new File(FileLocator.toFileURL(resource).getFile()).getAbsolutePath());
final History history = ResourceUtils.loadElement(historyURI);
return history.getLatestRelease().getLabel();
} catch (final Throwable t) {
BonitaStudioLog.error("Failed to load model version from process history", Activator.PLUGIN_ID);
return VERSION_6_0_0_ALPHA;
}
return minor.equals(testedVersion);
}
}
......@@ -435,8 +435,8 @@
<artifactItem>
<groupId>org.bonitasoft.connectors</groupId>
<artifactId>bonita-connector-webservice-impl</artifactId>
<version>1.0.13</version>
<classifier>connector</classifier>
<version>1.1.0</version>
<classifier>all</classifier>
<type>zip</type>
</artifactItem>
<!--REST CONNECTORS -->
......
......@@ -5,12 +5,10 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
......@@ -38,17 +36,14 @@ import org.bonitasoft.studio.model.process.diagram.providers.ElementInitializers
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.preference.IPreferenceStore;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
/**
* @author Romain Bioteau
*
*/
@RunWith(MockitoJUnitRunner.class)
public class NewDiagramFactoryTest {
......@@ -80,19 +75,14 @@ public class NewDiagramFactoryTest {
when(preferenceStore.getBoolean(BonitaPreferenceConstants.PREF_ENABLE_VALIDATION)).thenReturn(true);
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
/**
* Test method for {@link org.bonitasoft.studio.diagram.custom.repository.NewDiagramFactory#create(org.eclipse.core.runtime.IProgressMonitor)}.
*/
@Test
public void should_createModel_creae_a_basic_initial_model() throws Exception {
final Map<Class<?>, EObject> domainElements = newDiagramFactory.createlModel(ProcessFactory.eINSTANCE, "", elementInitalizers,
public void should_createModel_create_a_basic_initial_model() throws Exception {
final Map<Class<?>, EObject> domainElements = newDiagramFactory.createlModel(ProcessFactory.eINSTANCE, "",
elementInitalizers,
"7.5.0-001",
Repository.NULL_PROGRESS_MONITOR);
assertThat(domainElements).containsKey(MainProcess.class);
assertThat(domainElements).containsKey(Pool.class);
......
......@@ -92,7 +92,8 @@ public class NewDiagramFactory {
monitor.beginTask(Messages.newDiagram, 7);
final String diagramIdentifier = getNewProcessIdentifier();
final Map<Class<?>, EObject> domainElements = createlModel(processFactory, diagramIdentifier, ElementInitializers.getInstance(), monitor);
final Map<Class<?>, EObject> domainElements = createlModel(processFactory, diagramIdentifier,
ElementInitializers.getInstance(), ModelVersion.CURRENT_VERSION, monitor);
final Diagram diagram = createViews(domainElements, monitor);
final MainProcess mainProcess = (MainProcess) domainElements.get(MainProcess.class);
......@@ -111,26 +112,30 @@ public class NewDiagramFactory {
final Node poolNode = processViewProvider.createPool_2007(domainElements.get(Pool.class), diagram, -1, true,
ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
final Node laneNode = processViewProvider.createLane_3007(domainElements.get(Lane.class), (View) poolNode.getPersistedChildren().get(1), -1, true,
final Node laneNode = processViewProvider.createLane_3007(domainElements.get(Lane.class),
(View) poolNode.getPersistedChildren().get(1), -1, true,
ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
monitor.worked(1);
final View laneCompartmentView = (View) laneNode.getPersistedChildren().get(1);
final Node stepShape = processViewProvider.createTask_3005(domainElements.get(Task.class), laneCompartmentView, -1, true,
final Node stepShape = processViewProvider.createTask_3005(domainElements.get(Task.class), laneCompartmentView, -1,
true,
ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
final Bounds taskLayoutConstraint = (Bounds) stepShape.getLayoutConstraint();
taskLayoutConstraint.setX(160);
taskLayoutConstraint.setY(60);
monitor.worked(1);
final Node startEventShape = processViewProvider.createStartEvent_3002(domainElements.get(StartEvent.class), laneCompartmentView, -1, true,
final Node startEventShape = processViewProvider.createStartEvent_3002(domainElements.get(StartEvent.class),
laneCompartmentView, -1, true,
ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
final Bounds stepLayoutConstraint = (Bounds) startEventShape.getLayoutConstraint();
stepLayoutConstraint.setX(60);
stepLayoutConstraint.setY(68);
monitor.worked(1);
final Connector edge = (Connector) processViewProvider.createSequenceFlow_4001(domainElements.get(SequenceFlow.class), diagram, -1, true,
final Connector edge = (Connector) processViewProvider.createSequenceFlow_4001(
domainElements.get(SequenceFlow.class), diagram, -1, true,
ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
edge.setSource(startEventShape);
edge.setTarget(stepShape);
......@@ -169,7 +174,8 @@ public class NewDiagramFactory {
return newProcessName;
}
protected void createDefaultProcessArtifact(final TransactionalEditingDomain editingDomain, final MainProcess diagram, final IProgressMonitor monitor) {
protected void createDefaultProcessArtifact(final TransactionalEditingDomain editingDomain, final MainProcess diagram,
final IProgressMonitor monitor) {
final Pool pool = (Pool) diagram.getElements().get(0);
final String processUUID = ModelHelper.getEObjectID(pool);
final ProcessConfigurationRepositoryStore processConfStore = RepositoryManager.getInstance().getRepositoryStore(
......@@ -180,8 +186,10 @@ public class NewDiagramFactory {
createDefaultActorMapping(conf);
confFile.save(conf);
final ApplicationResourceRepositoryStore resourceStore = RepositoryManager.getInstance().getRepositoryStore(ApplicationResourceRepositoryStore.class);
final LookNFeelRepositoryStore lookNFeelStore = RepositoryManager.getInstance().getRepositoryStore(LookNFeelRepositoryStore.class);
final ApplicationResourceRepositoryStore resourceStore = RepositoryManager.getInstance()
.getRepositoryStore(ApplicationResourceRepositoryStore.class);
final LookNFeelRepositoryStore lookNFeelStore = RepositoryManager.getInstance()
.getRepositoryStore(LookNFeelRepositoryStore.class);
final ApplicationResourceFileStore artifact = resourceStore.getChild(processUUID);
if (artifact == null) {
final String themeId = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore()
......@@ -190,7 +198,8 @@ public class NewDiagramFactory {
final CompoundCommand templateCommand = WebTemplatesUtil.createAddTemplateCommand(editingDomain, pool, file);
// add an empty application folder
editingDomain.getCommandStack().execute(templateCommand);
final org.eclipse.emf.common.command.Command createDefaultResourceFolders = WebTemplatesUtil.createDefaultResourceFolders(editingDomain, pool);
final org.eclipse.emf.common.command.Command createDefaultResourceFolders = WebTemplatesUtil
.createDefaultResourceFolders(editingDomain, pool);
if (createDefaultResourceFolders != null) {
editingDomain.getCommandStack().execute(createDefaultResourceFolders);
}
......@@ -250,7 +259,7 @@ public class NewDiagramFactory {
}
private List<AbstractProcess> getAllProcess(final DiagramRepositoryStore diagramStore) {
final List<AbstractProcess> l = new ArrayList<AbstractProcess>();
final List<AbstractProcess> l = new ArrayList<>();
for (final DiagramFileStore diagramFileStore : diagramStore.getChildren()) {
final MainProcess m = diagramFileStore.getContent();
l.addAll(ModelHelper.getAllProcesses(m));
......@@ -268,7 +277,7 @@ public class NewDiagramFactory {
}
protected List<Actor> createInitialActors(final ProcessFactory factory) {
final List<Actor> actors = new ArrayList<Actor>();
final List<Actor> actors = new ArrayList<>();
final Actor initiator = factory.createActor();
initiator.setInitiator(true);
initiator.setName("Employee actor");
......@@ -277,15 +286,19 @@ public class NewDiagramFactory {
return actors;
}
protected Map<Class<?>, EObject> createlModel(final ProcessFactory processFactory, final String diagramIdentifier, final ElementInitializers initializers,
protected Map<Class<?>, EObject> createlModel(final ProcessFactory processFactory,
final String diagramIdentifier,
final ElementInitializers initializers,
final String modelVersion,
final IProgressMonitor monitor) {
final Map<Class<?>, EObject> domainElements = new HashMap<Class<?>, EObject>();
final String diagramName = NamingUtils.convertToValidURI(org.bonitasoft.studio.diagram.custom.i18n.Messages.newFilePrefix + diagramIdentifier);
final Map<Class<?>, EObject> domainElements = new HashMap<>();
final String diagramName = NamingUtils
.convertToValidURI(org.bonitasoft.studio.diagram.custom.i18n.Messages.newFilePrefix + diagramIdentifier);
final MainProcess mainProcess = processFactory.createMainProcess();
mainProcess.setName(diagramName);
mainProcess.setVersion(BASE_VERSION);
mainProcess.setBonitaVersion(ProductVersion.CURRENT_VERSION);
mainProcess.setBonitaModelVersion(ModelVersion.CURRENT_VERSION);
mainProcess.setBonitaModelVersion(modelVersion);
mainProcess.setEnableValidation(preferenceStore.getBoolean(BonitaPreferenceConstants.PREF_ENABLE_VALIDATION));
mainProcess.setConfigId(getConfigurationId(mainProcess));
ModelHelper.addDataTypes(mainProcess);
......@@ -337,7 +350,8 @@ public class NewDiagramFactory {
}
public void setDefaultPoolWidth(final int defaultWidth) {
final IPreferenceStore store = (IPreferenceStore) ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT.getPreferenceStore();
final IPreferenceStore store = (IPreferenceStore) ProcessDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT
.getPreferenceStore();
store.setDefault(POOL_DEFAULT_WIDTH, defaultWidth);
}
......
......@@ -232,8 +232,8 @@ public class ImportBosArchiveControlSupplier implements ControlSupplier {
filePathObserveValue.addValueChangeListener(this::parseArchive);
textWidget = new TextWidget.Builder()
.withLabel(Messages.selectFileToImport)
.widthHint(500)
.alignLeft()
.grabHorizontalSpace()
.fill()
.alignMiddle()
.labelAbove()
.withTargetToModelStrategy(updateValueStrategy()
......@@ -250,16 +250,17 @@ public class ImportBosArchiveControlSupplier implements ControlSupplier {
}
protected void browseFile(Event e) {
final Optional<String> file = Optional.ofNullable(openFileDialog(Display.getDefault().getActiveShell()));
if (file.isPresent()) {
final String filePath = file.get();
textWidget.setText(filePath);
if (new File(filePath).exists()) {
savePath(filePath);
} else {
descriptionLabel.setText("");
viewer.setInput(null);
}
Optional.ofNullable(openFileDialog(Display.getDefault().getActiveShell()))
.ifPresent(this::updateFilePath);
}
private void updateFilePath(String filePath) {
textWidget.setText(filePath);
if (new File(filePath).exists()) {
savePath(filePath);
} else {
descriptionLabel.setText("");
viewer.setInput(null);
}
}
......
......@@ -495,7 +495,8 @@ public class BPMNToProc extends ToProcProcessor {
return location;
}
private void createProcessWithLanes(final EList<TFlowElement> flowElements, final List<TLane> lanes) throws ProcBuilderException {
private void createProcessWithLanes(final EList<TFlowElement> flowElements, final List<TLane> lanes)
throws ProcBuilderException {
int nbActivities = 0;
for (final TLane tLane : lanes) {
final Dimension sizeFor = getSizeFor(tLane.getId());
......@@ -684,8 +685,9 @@ public class BPMNToProc extends ToProcProcessor {
for (final TArtifact tArtifact : artifacts) {
if (!(tArtifact instanceof TTextAnnotation)) {
if (!(tArtifact instanceof TAssociation && (sourceRefs.contains(((TAssociation) tArtifact).getSourceRef().getLocalPart())
|| sourceRefs.contains(((TAssociation) tArtifact).getTargetRef().getLocalPart())))) {
if (!(tArtifact instanceof TAssociation
&& (sourceRefs.contains(((TAssociation) tArtifact).getSourceRef().getLocalPart())
|| sourceRefs.contains(((TAssociation) tArtifact).getTargetRef().getLocalPart())))) {
status.add(new Status(IStatus.ERROR, ImporterPlugin.PLUGIN_ID, tArtifact.eClass().getName() + ": "
+ tArtifact.getId()));
BonitaStudioLog.log("can't create element for " + tArtifact);
......@@ -1073,7 +1075,8 @@ public class BPMNToProc extends ToProcProcessor {
if (edge != null) {
final BPMNLabel label = edge.getBPMNLabel();
if (label != null && label.getBounds() != null) {
final SequenceFlowLabelLocationCalculator locationCalculator = new SequenceFlowLabelLocationCalculator(edge, label);
final SequenceFlowLabelLocationCalculator locationCalculator = new SequenceFlowLabelLocationCalculator(
edge, label);
builder.setLabelPositionOnSequenceFlowOrEvent(locationCalculator.computeLabelLocation());
}
}
......@@ -1119,9 +1122,12 @@ public class BPMNToProc extends ToProcProcessor {
}
}
} else {
final String sourceRef = sequenceFlow.getSourceRef() != null ? sequenceFlow.getSourceRef() : "<Unspecified source>";
final String targetRef = sequenceFlow.getTargetRef() != null ? sequenceFlow.getTargetRef() : "<Unspecified Target>";
BonitaStudioLog.log("The model is not clean. There is a missing id on a SequenceFlow from " + sourceRef + "to " + targetRef);
final String sourceRef = sequenceFlow.getSourceRef() != null ? sequenceFlow.getSourceRef()
: "<Unspecified source>";
final String targetRef = sequenceFlow.getTargetRef() != null ? sequenceFlow.getTargetRef()
: "<Unspecified Target>";
BonitaStudioLog.log(
"The model is not clean. There is a missing id on a SequenceFlow from " + sourceRef + "to " + targetRef);
}
return isDefault;
}
......@@ -1158,7 +1164,8 @@ public class BPMNToProc extends ToProcProcessor {
* @param process
* @throws ProcBuilderException
*/
private int processActivities(final List<TFlowElement> flowElements, final boolean fromSubProcess) throws ProcBuilderException {
private int processActivities(final List<TFlowElement> flowElements, final boolean fromSubProcess)
throws ProcBuilderException {
int activityNumber = 0;
if (flowElements != null) {
for (final TFlowElement flowElement : flowElements) {
......@@ -1283,7 +1290,8 @@ public class BPMNToProc extends ToProcProcessor {
final TExpression completionConditionExpression = ((TMultiInstanceLoopCharacteristics) loopCharacteristics)
.getCompletionCondition();
if (completionConditionExpression != null) {
builder.addCompletionConditionExpression(getBonitaExpressionFromBPMNExpression(completionConditionExpression));
builder.addCompletionConditionExpression(
getBonitaExpressionFromBPMNExpression(completionConditionExpression));
}
final TExpression cardinalityExpression = ((TMultiInstanceLoopCharacteristics) loopCharacteristics)
.getLoopCardinality();
......@@ -1295,7 +1303,8 @@ public class BPMNToProc extends ToProcProcessor {
final TExpression expression = ((TStandardLoopCharacteristics) loopCharacteristics).getLoopCondition();
builder.addLoopCondition(getBonitaExpressionFromBPMNExpression(expression),
String.valueOf(((TStandardLoopCharacteristics) loopCharacteristics).getLoopMaximum()),
((TStandardLoopCharacteristics) loopCharacteristics).isTestBefore() ? TestTimeType.BEFORE : TestTimeType.AFTER);
((TStandardLoopCharacteristics) loopCharacteristics).isTestBefore() ? TestTimeType.BEFORE
: TestTimeType.AFTER);
}
}
......@@ -1370,7 +1379,8 @@ public class BPMNToProc extends ToProcProcessor {
}
}
}
builder.addCallActivityTargetProcess(calledElementName != null ? calledElementName : calledElementID, ""/* "1.0" */);
builder.addCallActivityTargetProcess(calledElementName != null ? calledElementName : calledElementID,
""/* "1.0" */);
}
}
......@@ -1453,14 +1463,14 @@ public class BPMNToProc extends ToProcProcessor {
processBonitaConnector(name, id, tServiceTask, operationRefName);
} else if ("##WebService".equals(tServiceTask.getImplementation())) {
// TODO: handle default implem for web services as Service tasks
builder.addConnector(id, name, "webservice", "1.0.0", ConnectorEvent.ON_FINISH, true);
builder.addConnector(id, name, "webservice", "1.0.1", ConnectorEvent.ON_FINISH, true);
}
}
}
protected void processBonitaConnector(final String name, final String id,
final TServiceTask tServiceTask, final String operationRefName)
throws ProcBuilderException {
throws ProcBuilderException {
final String connectorId = operationRefName.replaceFirst("Exec", "");
final String version = "1.0.0";// FIXME where is stored version now??
// Need to parse the filename of xsd
......@@ -1919,7 +1929,7 @@ public class BPMNToProc extends ToProcProcessor {
protected void createBonitaData(final TFlowElement flowElement,
final boolean isMultiple, final QName itemDef, final boolean isTransient)
throws ProcBuilderException {
throws ProcBuilderException {
final TItemDefinition itemDefinition = getItemDefinition(itemDef);
String id = null;
DataType dataType = null;
......@@ -1957,7 +1967,8 @@ public class BPMNToProc extends ToProcProcessor {
// "");
final TDataInput dataInput = getDataInputById((TActivity) flowElement, entryValue);
if (dataInput != null) {
final TProperty property = getPropertyByItemSubjectRef((TActivity) flowElement, dataInput.getItemSubjectRef());
final TProperty property = getPropertyByItemSubjectRef((TActivity) flowElement,
dataInput.getItemSubjectRef());
if (property != null) {
final TExpression fromExpression = assignment.getFrom();
defaultValueContent = retrieveDefaultValueContent(fromExpression);
......
......@@ -8,7 +8,7 @@ Bundle-Vendor: BonitaSoft S.A.
Bundle-Localization: plugin
Require-Bundle: org.mockito;bundle-version="1.9.5";resolution:=optional,
org.junit;bundle-version="4.11.0";resolution:=optional,
assertj-core;bundle-version="1.5.0";resolution:=optional,
assertj-core;bundle-version="3.6.1";resolution:=optional,
org.bonitasoft.studio.tests-utils;bundle-version="6.4.1";resolution:=optional,
org.eclipse.core.runtime,
org.bonitasoft.studio.common.repository;bundle-version="7.5.0",
......
......@@ -44,10 +44,10 @@ public class NewApplicationHandlerTest {
@Test
public void should_open_a_new_application_wizard() throws Exception {
NewApplicationHandler newApplicationHandler = spy(new NewApplicationHandler());
RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
ApplicationFileStore applicationFileStore = mock(ApplicationFileStore.class);
WizardBuilder<ApplicationFileStore> wizardBuilder = mock(WizardBuilder.class);
final NewApplicationHandler newApplicationHandler = spy(new NewApplicationHandler());
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final ApplicationFileStore applicationFileStore = mock(ApplicationFileStore.class);
final WizardBuilder<ApplicationFileStore> wizardBuilder = mock(WizardBuilder.class);
doReturn(wizardBuilder).when(newApplicationHandler).createWizard(notNull(WizardBuilder.class),
any(RepositoryAccessor.class));
when(wizardBuilder.open(any(Shell.class), eq(Messages.create))).thenReturn(Optional.of(applicationFileStore));
......@@ -59,9 +59,9 @@ public class NewApplicationHandlerTest {
@Test
public void should_create_a_new_application_wizard() throws Exception {
NewApplicationHandler newApplicationHandler = spy(new NewApplicationHandler());
RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
WizardBuilder<ApplicationFileStore> builder = spy(WizardBuilder.newWizard());
final NewApplicationHandler newApplicationHandler = spy(new NewApplicationHandler());
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final WizardBuilder<ApplicationFileStore> builder = spy(WizardBuilder.newWizard());
newApplicationHandler.createWizard(builder, repositoryAccessor);
verify(builder).withTitle(Messages.createNewApplication);
......@@ -71,20 +71,20 @@ public class NewApplicationHandlerTest {
@Test
public void should_create_an_applicationFileStore_onFinish() throws Exception {
NewApplicationHandler newApplicationHandler = new NewApplicationHandler();
RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
ApplicationRepositoryStore applicationStore = mock(ApplicationRepositoryStore.class);
ApplicationFileStore applicationFileStore = mock(ApplicationFileStore.class);
final NewApplicationHandler newApplicationHandler = new NewApplicationHandler();
final RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
final ApplicationRepositoryStore applicationStore = mock(ApplicationRepositoryStore.class);
final ApplicationFileStore applicationFileStore = mock(ApplicationFileStore.class);
when(applicationStore.createRepositoryFileStore("testAppToken.xml")).thenReturn(applicationFileStore);
when(repositoryAccessor.getRepositoryStore(ApplicationRepositoryStore.class)).thenReturn(applicationStore);
ApplicationNode applicationNode = newApplication("testAppToken", "My App Display Name", "0.1").create();
Optional<ApplicationFileStore> fileStore = newApplicationHandler.createApplicationFileStore(
final ApplicationNode applicationNode = newApplication("testAppToken", "My App Display Name", "0.1").create();
final Optional<ApplicationFileStore> fileStore = newApplicationHandler.createApplicationFileStore(
applicationNode,
repositoryAccessor);
assertThat(fileStore).isPresent();
ArgumentCaptor<ApplicationNodeContainer> captor = ArgumentCaptor.forClass(ApplicationNodeContainer.class);
final ArgumentCaptor<ApplicationNodeContainer> captor = ArgumentCaptor.forClass(ApplicationNodeContainer.class);
verify(applicationFileStore).save(captor.capture());
assertThat(captor.getValue().getApplications()).extracting("token").contains("testAppToken");
}
......
/**
* Copyright (C) 2014 Bonitasoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.migration.custom.migration.connector;
/**
* @author Romain Bioteau
*/
public class UpdateWebServiceConnectorVersionTo110 extends UpdateConnectorVersionMigration {
private static final String WEB_SERVICE_CONNECTOR_DEFINITION = "webservice";
@Override
protected String getNewDefinitionVersion() {
return "1.0.1";
}
@Override
protected String getOldDefinitionVersion() {
return "1.0.0";
}
@Override
protected boolean shouldUpdateVersion(final String defId) {
return WEB_SERVICE_CONNECTOR_DEFINITION.equals(defId);
}
}
......@@ -64,7 +64,9 @@ public abstract class ControlWidget extends Composite {