提交 7c8fcb95 编写于 作者: M Miguel Ruiz 提交者: mergify[bot]

Activiti 3760 definition upgrade logic (#2893)

* ACTIVITI-3760 Change logic for deployment versioning

* ACTIVITI-3760 Mybatis xml descriptor to support versioning

* ACTIVITI-3760 Mybatis descriptor clean up

* ACTIVITI-3760 logic to set procdef version as deployment/application version

* ACTIVITI-3760 Logic to calculate versioning for procdefs

* ACTIVITI-3760 Mybatis config to support app versioning of procdefs

* ACTIVITI-3760 Add sql commands for postgres

* ACTIVITI-3760 Add manifest to test resources

* ACTIVITI-3760 Add new project release version property to deployment

* ACTIVITI-3760 Add new column to table in postgres

* ACTIVITI-3760 Core logic for project release and application version bump up

* ACTIVITI-3760 Add spring configuration

* ACTIVITI-3760 Add properties to tests

* ACTIVITI-3760 Reset version in manifest

* ACTIVITI-3760 Refactor method

* ACTIVITI-3760 Add logger to DefaultAutoDeploymentStrategy class

* ACTIVITI-3760 Clean up

* ACTIVITI-3760 Ensure baackwards compatibility

* ACTIVITI-3760 Add method to Deployment interface

* ACTIVITI-3760 Add IT coverage

* Refactor deployment strategies

* ACTIVITI-3760 Refactor of DB and entities

* ACTIVITI-3760 Rely on default property

* Use SpringBoot test instead of SpringApplicationBuilder

* Clean up

* Update how to set deployment version

Avoid extra query retrieve latest deployment that was already loaded before
上级 fea1edbf
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
<groupId>org.activiti.api</groupId> <groupId>org.activiti.api</groupId>
<artifactId>activiti-api-runtime-shared</artifactId> <artifactId>activiti-api-runtime-shared</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.activiti.core.common</groupId>
<artifactId>activiti-project-model</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.activiti</groupId> <groupId>org.activiti</groupId>
<artifactId>activiti-bpmn-converter</artifactId> <artifactId>activiti-bpmn-converter</artifactId>
......
...@@ -168,6 +168,19 @@ public class BpmnDeployer implements Deployer { ...@@ -168,6 +168,19 @@ public class BpmnDeployer implements Deployer {
Map<ProcessDefinitionEntity, ProcessDefinitionEntity> mapNewToOldProcessDefinitions) { Map<ProcessDefinitionEntity, ProcessDefinitionEntity> mapNewToOldProcessDefinitions) {
CommandContext commandContext = Context.getCommandContext(); CommandContext commandContext = Context.getCommandContext();
if(parsedDeployment.getDeployment().getProjectReleaseVersion() != null){
Integer version = parsedDeployment.getDeployment().getVersion();
for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
processDefinition.setVersion(version);
processDefinition.setId(getIdForNewProcessDefinition(processDefinition));
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED,
processDefinition));
}
}
}else{
for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) { for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
int version = 1; int version = 1;
...@@ -186,6 +199,9 @@ public class BpmnDeployer implements Deployer { ...@@ -186,6 +199,9 @@ public class BpmnDeployer implements Deployer {
} }
} }
}
/** /**
* Saves each process definition. It is assumed that the deployment is new, the definitions * Saves each process definition. It is assumed that the deployment is new, the definitions
* have never been saved before, and that they have all their values properly set up. * have never been saved before, and that they have all their values properly set up.
......
...@@ -52,6 +52,9 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable { ...@@ -52,6 +52,9 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable {
deployment.setDeploymentTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime()); deployment.setDeploymentTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());
setProjectReleaseVersion(deployment);
deployment.setVersion(1);
if (deploymentBuilder.isDuplicateFilterEnabled()) { if (deploymentBuilder.isDuplicateFilterEnabled()) {
List<Deployment> existingDeployments = new ArrayList<Deployment>(); List<Deployment> existingDeployments = new ArrayList<Deployment>();
...@@ -74,8 +77,13 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable { ...@@ -74,8 +77,13 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable {
existingDeployment = (DeploymentEntity) existingDeployments.get(0); existingDeployment = (DeploymentEntity) existingDeployments.get(0);
} }
if ((existingDeployment != null) && !deploymentsDiffer(deployment, existingDeployment)) { if (existingDeployment != null) {
if (!deploymentsDiffer(deployment,
existingDeployment)) {
return existingDeployment; return existingDeployment;
} else {
deployment.setVersion(existingDeployment.getVersion() + 1);
}
} }
} }
...@@ -107,7 +115,19 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable { ...@@ -107,7 +115,19 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable {
return deployment; return deployment;
} }
protected boolean deploymentsDiffer(DeploymentEntity deployment, DeploymentEntity saved) { private void setProjectReleaseVersion(DeploymentEntity deployment) {
if (deploymentBuilder.hasProjectManifestSet()) {
deployment.setProjectReleaseVersion(deploymentBuilder.getProjectManifest().getVersion());
}
}
protected boolean deploymentsDiffer(DeploymentEntity deployment,
DeploymentEntity saved) {
if (deploymentBuilder.hasProjectManifestSet()) {
return !deployment.getProjectReleaseVersion().equals(saved.getProjectReleaseVersion());
} else {
if (deployment.getResources() == null || saved.getResources() == null) { if (deployment.getResources() == null || saved.getResources() == null) {
return true; return true;
...@@ -119,21 +139,24 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable { ...@@ -119,21 +139,24 @@ public class DeployCmd<T> implements Command<Deployment>, Serializable {
for (String resourceName : resources.keySet()) { for (String resourceName : resources.keySet()) {
ResourceEntity savedResource = savedResources.get(resourceName); ResourceEntity savedResource = savedResources.get(resourceName);
if (savedResource == null) if (savedResource == null) {
return true; return true;
}
if (!savedResource.isGenerated()) { if (!savedResource.isGenerated()) {
ResourceEntity resource = resources.get(resourceName); ResourceEntity resource = resources.get(resourceName);
byte[] bytes = resource.getBytes(); byte[] bytes = resource.getBytes();
byte[] savedBytes = savedResource.getBytes(); byte[] savedBytes = savedResource.getBytes();
if (!Arrays.equals(bytes, savedBytes)) { if (!Arrays.equals(bytes,
savedBytes)) {
return true; return true;
} }
} }
} }
return false; return false;
} }
}
protected void scheduleProcessDefinitionActivation(CommandContext commandContext, DeploymentEntity deployment) { protected void scheduleProcessDefinitionActivation(CommandContext commandContext, DeploymentEntity deployment) {
for (ProcessDefinitionEntity processDefinitionEntity : deployment.getDeployedArtifacts(ProcessDefinitionEntity.class)) { for (ProcessDefinitionEntity processDefinitionEntity : deployment.getDeployedArtifacts(ProcessDefinitionEntity.class)) {
......
...@@ -55,4 +55,12 @@ public interface DeploymentEntity extends Deployment, Entity { ...@@ -55,4 +55,12 @@ public interface DeploymentEntity extends Deployment, Entity {
void setEngineVersion(String engineVersion); void setEngineVersion(String engineVersion);
Integer getVersion();
void setVersion(Integer version);
String getProjectReleaseVersion();
void setProjectReleaseVersion(String projectReleaseVersion);
} }
...@@ -38,6 +38,8 @@ public class DeploymentEntityImpl extends AbstractEntityNoRevision implements De ...@@ -38,6 +38,8 @@ public class DeploymentEntityImpl extends AbstractEntityNoRevision implements De
protected Map<String, ResourceEntity> resources; protected Map<String, ResourceEntity> resources;
protected Date deploymentTime; protected Date deploymentTime;
protected boolean isNew; protected boolean isNew;
protected Integer version;
private String projectReleaseVersion;
// Backwards compatibility // Backwards compatibility
protected String engineVersion; protected String engineVersion;
...@@ -168,6 +170,22 @@ public class DeploymentEntityImpl extends AbstractEntityNoRevision implements De ...@@ -168,6 +170,22 @@ public class DeploymentEntityImpl extends AbstractEntityNoRevision implements De
this.engineVersion = engineVersion; this.engineVersion = engineVersion;
} }
public Integer getVersion(){
return version;
}
public void setVersion(Integer version){
this.version = version;
}
public String getProjectReleaseVersion() {
return projectReleaseVersion;
}
public void setProjectReleaseVersion(String projectReleaseVersion) {
this.projectReleaseVersion = projectReleaseVersion;
}
// common methods ////////////////////////////////////////////////////////// // common methods //////////////////////////////////////////////////////////
@Override @Override
......
...@@ -24,6 +24,7 @@ import java.util.zip.ZipInputStream; ...@@ -24,6 +24,7 @@ import java.util.zip.ZipInputStream;
import org.activiti.bpmn.converter.BpmnXMLConverter; import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel; import org.activiti.bpmn.model.BpmnModel;
import org.activiti.core.common.project.model.ProjectManifest;
import org.activiti.engine.ActivitiException; import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException; import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.RepositoryServiceImpl; import org.activiti.engine.impl.RepositoryServiceImpl;
...@@ -55,6 +56,7 @@ public class DeploymentBuilderImpl implements DeploymentBuilder, Serializable { ...@@ -55,6 +56,7 @@ public class DeploymentBuilderImpl implements DeploymentBuilder, Serializable {
protected boolean isDuplicateFilterEnabled; protected boolean isDuplicateFilterEnabled;
protected Date processDefinitionsActivationDate; protected Date processDefinitionsActivationDate;
protected Map<String, Object> deploymentProperties = new HashMap<>(); protected Map<String, Object> deploymentProperties = new HashMap<>();
private ProjectManifest projectManifest;
public DeploymentBuilderImpl(RepositoryServiceImpl repositoryService) { public DeploymentBuilderImpl(RepositoryServiceImpl repositoryService) {
this(repositoryService, this(repositoryService,
...@@ -82,6 +84,19 @@ public class DeploymentBuilderImpl implements DeploymentBuilder, Serializable { ...@@ -82,6 +84,19 @@ public class DeploymentBuilderImpl implements DeploymentBuilder, Serializable {
return this; return this;
} }
public DeploymentBuilder setProjectManifest(ProjectManifest projectManifest) {
this.projectManifest = projectManifest;
return this;
}
public ProjectManifest getProjectManifest(){
return this.projectManifest;
}
public boolean hasProjectManifestSet(){
return this.projectManifest != null;
}
@Override @Override
public DeploymentBuilder addInputStream(String resourceName, public DeploymentBuilder addInputStream(String resourceName,
Resource resource) { Resource resource) {
......
...@@ -44,4 +44,8 @@ public interface Deployment { ...@@ -44,4 +44,8 @@ public interface Deployment {
String getTenantId(); String getTenantId();
Integer getVersion();
String getProjectReleaseVersion();
} }
...@@ -17,6 +17,7 @@ import java.util.Date; ...@@ -17,6 +17,7 @@ import java.util.Date;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import org.activiti.bpmn.model.BpmnModel; import org.activiti.bpmn.model.BpmnModel;
import org.activiti.core.common.project.model.ProjectManifest;
import org.activiti.engine.api.internal.Internal; import org.activiti.engine.api.internal.Internal;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
...@@ -48,6 +49,8 @@ public interface DeploymentBuilder { ...@@ -48,6 +49,8 @@ public interface DeploymentBuilder {
DeploymentBuilder addBpmnModel(String resourceName, BpmnModel bpmnModel); DeploymentBuilder addBpmnModel(String resourceName, BpmnModel bpmnModel);
DeploymentBuilder setProjectManifest(ProjectManifest projectManifest);
/** /**
* If called, no XML schema validation against the BPMN 2.0 XSD. * If called, no XML schema validation against the BPMN 2.0 XSD.
* *
......
...@@ -32,6 +32,8 @@ create table ACT_RE_DEPLOYMENT ( ...@@ -32,6 +32,8 @@ create table ACT_RE_DEPLOYMENT (
TENANT_ID_ varchar(255) default '', TENANT_ID_ varchar(255) default '',
DEPLOY_TIME_ timestamp, DEPLOY_TIME_ timestamp,
ENGINE_VERSION_ varchar(255), ENGINE_VERSION_ varchar(255),
VERSION_ integer,
PROJECT_RELEASE_VERSION_ varchar(255),
primary key (ID_) primary key (ID_)
); );
......
...@@ -32,6 +32,8 @@ create table ACT_RE_DEPLOYMENT ( ...@@ -32,6 +32,8 @@ create table ACT_RE_DEPLOYMENT (
TENANT_ID_ varchar(255) default '', TENANT_ID_ varchar(255) default '',
DEPLOY_TIME_ timestamp, DEPLOY_TIME_ timestamp,
ENGINE_VERSION_ varchar(255), ENGINE_VERSION_ varchar(255),
VERSION_ integer,
PROJECT_RELEASE_VERSION_ varchar(255),
primary key (ID_) primary key (ID_)
); );
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<!-- DEPLOYMENT INSERT --> <!-- DEPLOYMENT INSERT -->
<insert id="insertDeployment" parameterType="org.activiti.engine.impl.persistence.entity.DeploymentEntityImpl"> <insert id="insertDeployment" parameterType="org.activiti.engine.impl.persistence.entity.DeploymentEntityImpl">
insert into ${prefix}ACT_RE_DEPLOYMENT(ID_, NAME_, CATEGORY_, KEY_, TENANT_ID_, DEPLOY_TIME_, ENGINE_VERSION_) insert into ${prefix}ACT_RE_DEPLOYMENT(ID_, NAME_, CATEGORY_, KEY_, TENANT_ID_, DEPLOY_TIME_, ENGINE_VERSION_, VERSION_, PROJECT_RELEASE_VERSION_)
values(#{id, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{category, jdbcType=VARCHAR}, #{key, jdbcType=VARCHAR}, #{tenantId, jdbcType=VARCHAR}, #{deploymentTime, jdbcType=TIMESTAMP}, #{engineVersion, jdbcType=VARCHAR}) values(#{id, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{category, jdbcType=VARCHAR}, #{key, jdbcType=VARCHAR}, #{tenantId, jdbcType=VARCHAR}, #{deploymentTime, jdbcType=TIMESTAMP}, #{engineVersion, jdbcType=VARCHAR}, #{version, jdbcType=INTEGER}, #{projectReleaseVersion, jdbcType=VARCHAR})
</insert> </insert>
<insert id="bulkInsertDeployment" parameterType="java.util.List"> <insert id="bulkInsertDeployment" parameterType="java.util.List">
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#{deployment.category, jdbcType=VARCHAR}, #{deployment.category, jdbcType=VARCHAR},
#{deployment.key, jdbcType=VARCHAR}, #{deployment.key, jdbcType=VARCHAR},
#{deployment.tenantId, jdbcType=VARCHAR}, #{deployment.tenantId, jdbcType=VARCHAR},
#{deployment.deploymentTime, jdbcType=TIMESTAMP}) #{deployment.deploymentTime, jdbcType=TIMESTAMP}),
#{version, jdbcType=INTEGER},
#{projectReleaseVersion, jdbcType=VARCHAR}
</foreach> </foreach>
</insert> </insert>
...@@ -33,7 +35,9 @@ ...@@ -33,7 +35,9 @@
#{deployment.category, jdbcType=VARCHAR}, #{deployment.category, jdbcType=VARCHAR},
#{deployment.key, jdbcType=VARCHAR}, #{deployment.key, jdbcType=VARCHAR},
#{deployment.tenantId, jdbcType=VARCHAR}, #{deployment.tenantId, jdbcType=VARCHAR},
#{deployment.deploymentTime, jdbcType=TIMESTAMP}) #{deployment.deploymentTime, jdbcType=TIMESTAMP}),
#{version, jdbcType=INTEGER},
#{projectReleaseVersion, jdbcType=VARCHAR}
</foreach> </foreach>
SELECT * FROM dual SELECT * FROM dual
</insert> </insert>
...@@ -44,7 +48,8 @@ ...@@ -44,7 +48,8 @@
update ${prefix}ACT_RE_DEPLOYMENT set update ${prefix}ACT_RE_DEPLOYMENT set
CATEGORY_ = #{category, jdbcType=VARCHAR}, CATEGORY_ = #{category, jdbcType=VARCHAR},
KEY_ = #{key, jdbcType=VARCHAR}, KEY_ = #{key, jdbcType=VARCHAR},
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR} TENANT_ID_ = #{tenantId, jdbcType=VARCHAR},
VERSION_ = #{version, jdbcType=INTEGER}
where ID_ = #{id, jdbcType=VARCHAR} where ID_ = #{id, jdbcType=VARCHAR}
</update> </update>
...@@ -64,6 +69,8 @@ ...@@ -64,6 +69,8 @@
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" /> <result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="deploymentTime" column="DEPLOY_TIME_" jdbcType="TIMESTAMP"/> <result property="deploymentTime" column="DEPLOY_TIME_" jdbcType="TIMESTAMP"/>
<result property="engineVersion" column="ENGINE_VERSION_" jdbcType="VARCHAR" /> <result property="engineVersion" column="ENGINE_VERSION_" jdbcType="VARCHAR" />
<result property="version" column="VERSION_" jdbcType="INTEGER" />
<result property="projectReleaseVersion" column="PROJECT_RELEASE_VERSION_" jdbcType="VARCHAR" />
</resultMap> </resultMap>
<!-- DEPLOYMENT SELECT --> <!-- DEPLOYMENT SELECT -->
......
...@@ -23,6 +23,7 @@ import javax.sql.DataSource; ...@@ -23,6 +23,7 @@ import javax.sql.DataSource;
import org.activiti.api.process.model.events.ProcessDeployedEvent; import org.activiti.api.process.model.events.ProcessDeployedEvent;
import org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener; import org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener;
import org.activiti.api.runtime.shared.identity.UserGroupManager; import org.activiti.api.runtime.shared.identity.UserGroupManager;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.cfg.ProcessEngineConfigurator; import org.activiti.engine.cfg.ProcessEngineConfigurator;
import org.activiti.engine.impl.event.EventSubscriptionPayloadMappingProvider; import org.activiti.engine.impl.event.EventSubscriptionPayloadMappingProvider;
...@@ -70,10 +71,11 @@ public class ProcessEngineAutoConfiguration extends AbstractProcessEngineAutoCon ...@@ -70,10 +71,11 @@ public class ProcessEngineAutoConfiguration extends AbstractProcessEngineAutoCon
SpringAsyncExecutor springAsyncExecutor, SpringAsyncExecutor springAsyncExecutor,
ActivitiProperties activitiProperties, ActivitiProperties activitiProperties,
ProcessDefinitionResourceFinder processDefinitionResourceFinder, ProcessDefinitionResourceFinder processDefinitionResourceFinder,
ProjectModelService projectModelService,
@Autowired(required = false) List<ProcessEngineConfigurationConfigurer> processEngineConfigurationConfigurers, @Autowired(required = false) List<ProcessEngineConfigurationConfigurer> processEngineConfigurationConfigurers,
@Autowired(required = false) List<ProcessEngineConfigurator> processEngineConfigurators) throws IOException { @Autowired(required = false) List<ProcessEngineConfigurator> processEngineConfigurators) throws IOException {
SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(); SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(projectModelService);
conf.setConfigurators(processEngineConfigurators); conf.setConfigurators(processEngineConfigurators);
configureProcessDefinitionResources(processDefinitionResourceFinder, configureProcessDefinitionResources(processDefinitionResourceFinder,
conf); conf);
......
package org.activiti.spring.boot;
import org.activiti.core.common.project.model.ProjectManifest;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class ApplicationUpgradeIT {
@Autowired
private RepositoryService repositoryService;
@Test
public void should_UpdateDeploymentVersion_When_ManifestIsPresent() {
ProjectManifest projectManifest = new ProjectManifest();
projectManifest.setVersion("7");
Deployment deployment1 = repositoryService.createDeployment()
.setProjectManifest(projectManifest)
.enableDuplicateFiltering()
.name("deploymentName")
.deploy();
assertThat(deployment1.getVersion()).isEqualTo(1);
assertThat(deployment1.getProjectReleaseVersion()).isEqualTo("7");
projectManifest.setVersion("17");
Deployment deployment2 = repositoryService.createDeployment()
.setProjectManifest(projectManifest)
.enableDuplicateFiltering()
.name("deploymentName")
.deploy();
assertThat(deployment2.getProjectReleaseVersion()).isEqualTo("17");
assertThat(deployment2.getVersion()).isEqualTo(2);
}
}
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.activiti.spring.boot; package org.activiti.spring.boot;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.spring.SpringProcessEngineConfiguration; import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.process.validation.AsyncPropertyValidator; import org.activiti.spring.boot.process.validation.AsyncPropertyValidator;
import org.activiti.validation.ProcessValidator; import org.activiti.validation.ProcessValidator;
...@@ -24,8 +25,9 @@ import org.assertj.core.api.Condition; ...@@ -24,8 +25,9 @@ import org.assertj.core.api.Condition;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.MockitoAnnotations.initMocks; import static org.mockito.MockitoAnnotations.initMocks;
public class ProcessEngineAutoConfigurationTest { public class ProcessEngineAutoConfigurationTest {
...@@ -33,6 +35,9 @@ public class ProcessEngineAutoConfigurationTest { ...@@ -33,6 +35,9 @@ public class ProcessEngineAutoConfigurationTest {
@InjectMocks @InjectMocks
private ProcessEngineAutoConfiguration processEngineAutoConfiguration; private ProcessEngineAutoConfiguration processEngineAutoConfiguration;
@Mock
private ProjectModelService projectModelServiceMock;
@Before @Before
public void setUp() { public void setUp() {
initMocks(this); initMocks(this);
...@@ -43,7 +48,7 @@ public class ProcessEngineAutoConfigurationTest { ...@@ -43,7 +48,7 @@ public class ProcessEngineAutoConfigurationTest {
//given //given
ActivitiProperties activitiProperties = new ActivitiProperties(); ActivitiProperties activitiProperties = new ActivitiProperties();
activitiProperties.setAsyncExecutorActivate(false); activitiProperties.setAsyncExecutorActivate(false);
SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(); SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(projectModelServiceMock);
//when //when
processEngineAutoConfiguration.addAsyncPropertyValidator(activitiProperties, processEngineAutoConfiguration.addAsyncPropertyValidator(activitiProperties,
...@@ -65,7 +70,7 @@ public class ProcessEngineAutoConfigurationTest { ...@@ -65,7 +70,7 @@ public class ProcessEngineAutoConfigurationTest {
//given //given
ActivitiProperties activitiProperties = new ActivitiProperties(); ActivitiProperties activitiProperties = new ActivitiProperties();
activitiProperties.setAsyncExecutorActivate(true); activitiProperties.setAsyncExecutorActivate(true);
SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(); SpringProcessEngineConfiguration conf = new SpringProcessEngineConfiguration(projectModelServiceMock);
//when //when
processEngineAutoConfiguration.addAsyncPropertyValidator(activitiProperties, processEngineAutoConfiguration.addAsyncPropertyValidator(activitiProperties,
......
{
"createdBy": "superadminuser",
"creationDate": "2019-08-16T15:58:46.056+0000",
"lastModifiedBy": "qa-modeler-1",
"lastModifiedDate": "2019-08-16T16:03:41.941+0000",
"id": "c519a458-539f-4385-a937-2edfb4045eb9",
"name": "projectA",
"description": "",
"version": "1"
}
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
<groupId>org.activiti.api</groupId> <groupId>org.activiti.api</groupId>
<artifactId>activiti-api-runtime-shared</artifactId> <artifactId>activiti-api-runtime-shared</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.activiti.core.common</groupId>
<artifactId>activiti-spring-project</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId> <artifactId>spring-beans</artifactId>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
package org.activiti.spring; package org.activiti.spring;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.ActivitiException; import org.activiti.engine.ActivitiException;
import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration; import org.activiti.engine.ProcessEngineConfiguration;
...@@ -39,6 +40,8 @@ import org.springframework.transaction.PlatformTransactionManager; ...@@ -39,6 +40,8 @@ import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/** /**
...@@ -54,15 +57,21 @@ public class SpringProcessEngineConfiguration extends ProcessEngineConfiguration ...@@ -54,15 +57,21 @@ public class SpringProcessEngineConfiguration extends ProcessEngineConfiguration
protected String deploymentMode = "default"; protected String deploymentMode = "default";
protected ApplicationContext applicationContext; protected ApplicationContext applicationContext;
protected Integer transactionSynchronizationAdapterOrder = null; protected Integer transactionSynchronizationAdapterOrder = null;
private Collection<AutoDeploymentStrategy> deploymentStrategies = new ArrayList<AutoDeploymentStrategy>(); private Collection<AutoDeploymentStrategy> deploymentStrategies = new ArrayList<>();
private DefaultAutoDeploymentStrategy defaultAutoDeploymentStrategy;
public SpringProcessEngineConfiguration() { public SpringProcessEngineConfiguration() {
this(null);
}
public SpringProcessEngineConfiguration(ProjectModelService projectModelService) {
this.transactionsExternallyManaged = true; this.transactionsExternallyManaged = true;
deploymentStrategies.add(new DefaultAutoDeploymentStrategy()); defaultAutoDeploymentStrategy = new DefaultAutoDeploymentStrategy(projectModelService);
deploymentStrategies.add(new SingleResourceAutoDeploymentStrategy()); deploymentStrategies.add(defaultAutoDeploymentStrategy);
deploymentStrategies.add(new ResourceParentFolderAutoDeploymentStrategy()); deploymentStrategies.add(new SingleResourceAutoDeploymentStrategy(projectModelService));
deploymentStrategies.add(new FailOnNoProcessAutoDeploymentStrategy()); deploymentStrategies.add(new ResourceParentFolderAutoDeploymentStrategy(projectModelService));
deploymentStrategies.add(new NeverFailAutoDeploymentStrategy()); deploymentStrategies.add(new FailOnNoProcessAutoDeploymentStrategy(projectModelService));
deploymentStrategies.add(new NeverFailAutoDeploymentStrategy(projectModelService));
} }
@Override @Override
...@@ -181,7 +190,7 @@ public class SpringProcessEngineConfiguration extends ProcessEngineConfiguration ...@@ -181,7 +190,7 @@ public class SpringProcessEngineConfiguration extends ProcessEngineConfiguration
* @return the deployment strategy to use for the mode. Never <code>null</code> * @return the deployment strategy to use for the mode. Never <code>null</code>
*/ */
protected AutoDeploymentStrategy getAutoDeploymentStrategy(final String mode) { protected AutoDeploymentStrategy getAutoDeploymentStrategy(final String mode) {
AutoDeploymentStrategy result = new DefaultAutoDeploymentStrategy(); AutoDeploymentStrategy result = defaultAutoDeploymentStrategy;
for (final AutoDeploymentStrategy strategy : deploymentStrategies) { for (final AutoDeploymentStrategy strategy : deploymentStrategies) {
if (strategy.handlesMode(mode)) { if (strategy.handlesMode(mode)) {
result = strategy; result = strategy;
......
...@@ -18,8 +18,10 @@ import java.util.List; ...@@ -18,8 +18,10 @@ import java.util.List;
import org.activiti.bpmn.converter.BpmnXMLConverter; import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel; import org.activiti.bpmn.model.BpmnModel;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.impl.util.io.InputStreamSource; import org.activiti.engine.impl.util.io.InputStreamSource;
import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.validation.ValidationError; import org.activiti.validation.ValidationError;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -37,6 +39,12 @@ public abstract class AbstractAutoDeploymentStrategy implements AutoDeploymentSt ...@@ -37,6 +39,12 @@ public abstract class AbstractAutoDeploymentStrategy implements AutoDeploymentSt
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractAutoDeploymentStrategy.class); protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractAutoDeploymentStrategy.class);
private ProjectModelService projectModelService;
public AbstractAutoDeploymentStrategy(ProjectModelService projectModelService) {
this.projectModelService = projectModelService;
}
/** /**
* Gets the deployment mode this strategy handles. * Gets the deployment mode this strategy handles.
* *
...@@ -111,4 +119,15 @@ public abstract class AbstractAutoDeploymentStrategy implements AutoDeploymentSt ...@@ -111,4 +119,15 @@ public abstract class AbstractAutoDeploymentStrategy implements AutoDeploymentSt
} }
return true; return true;
} }
protected DeploymentBuilder loadProjectManifest(DeploymentBuilder deploymentBuilder) {
if (projectModelService != null && projectModelService.hasProjectManifest()) {
try {
deploymentBuilder.setProjectManifest(projectModelService.loadProjectManifest());
} catch (IOException e) {
LOGGER.warn("Manifest of application not found. Project release version will not be set for deployment.");
}
}
return deploymentBuilder;
}
} }
...@@ -13,14 +13,13 @@ ...@@ -13,14 +13,13 @@
package org.activiti.spring.autodeployment; package org.activiti.spring.autodeployment;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.DeploymentBuilder; import org.activiti.engine.repository.DeploymentBuilder;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
/** /**
* Default implementation of {@link AutoDeploymentStrategy} that groups all {@link Resource}s into a single deployment. This implementation is equivalent to the previously used implementation. * Default implementation of {@link AutoDeploymentStrategy} that groups all {@link Resource}s into a single deployment. This implementation is equivalent to the previously used implementation.
*
*/ */
public class DefaultAutoDeploymentStrategy extends AbstractAutoDeploymentStrategy { public class DefaultAutoDeploymentStrategy extends AbstractAutoDeploymentStrategy {
...@@ -29,18 +28,25 @@ public class DefaultAutoDeploymentStrategy extends AbstractAutoDeploymentStrateg ...@@ -29,18 +28,25 @@ public class DefaultAutoDeploymentStrategy extends AbstractAutoDeploymentStrateg
*/ */
public static final String DEPLOYMENT_MODE = "default"; public static final String DEPLOYMENT_MODE = "default";
public DefaultAutoDeploymentStrategy(ProjectModelService projectModelService) {
super(projectModelService);
}
@Override @Override
protected String getDeploymentMode() { protected String getDeploymentMode() {
return DEPLOYMENT_MODE; return DEPLOYMENT_MODE;
} }
@Override @Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) { public void deployResources(final String deploymentNameHint,
final Resource[] resources,
final RepositoryService repositoryService) {
// Create a single deployment for all resources using the name hint as // Create a single deployment for all resources using the name hint as
// the // the
// literal name // literal name
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentNameHint);
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentNameHint);
for (final Resource resource : resources) { for (final Resource resource : resources) {
final String resourceName = determineResourceName(resource); final String resourceName = determineResourceName(resource);
...@@ -49,7 +55,6 @@ public class DefaultAutoDeploymentStrategy extends AbstractAutoDeploymentStrateg ...@@ -49,7 +55,6 @@ public class DefaultAutoDeploymentStrategy extends AbstractAutoDeploymentStrateg
resource); resource);
} }
deploymentBuilder.deploy(); loadProjectManifest(deploymentBuilder).deploy();
} }
} }
package org.activiti.spring.autodeployment; package org.activiti.spring.autodeployment;
import java.io.IOException;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.ActivitiException; import org.activiti.engine.ActivitiException;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.DeploymentBuilder; import org.activiti.engine.repository.DeploymentBuilder;
...@@ -13,6 +16,10 @@ public class FailOnNoProcessAutoDeploymentStrategy extends AbstractAutoDeploymen ...@@ -13,6 +16,10 @@ public class FailOnNoProcessAutoDeploymentStrategy extends AbstractAutoDeploymen
public static final String DEPLOYMENT_MODE = "fail-on-no-process"; public static final String DEPLOYMENT_MODE = "fail-on-no-process";
public FailOnNoProcessAutoDeploymentStrategy(ProjectModelService projectModelService) {
super(projectModelService);
}
@Override @Override
protected String getDeploymentMode() { protected String getDeploymentMode() {
return DEPLOYMENT_MODE; return DEPLOYMENT_MODE;
...@@ -20,7 +27,7 @@ public class FailOnNoProcessAutoDeploymentStrategy extends AbstractAutoDeploymen ...@@ -20,7 +27,7 @@ public class FailOnNoProcessAutoDeploymentStrategy extends AbstractAutoDeploymen
@Override @Override
public void deployResources(String deploymentNameHint, Resource[] resources, RepositoryService repositoryService) { public void deployResources(String deploymentNameHint, Resource[] resources, RepositoryService repositoryService) {
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering() DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering()
.name(deploymentNameHint); .name(deploymentNameHint);
int validProcessCount = 0; int validProcessCount = 0;
...@@ -36,6 +43,8 @@ public class FailOnNoProcessAutoDeploymentStrategy extends AbstractAutoDeploymen ...@@ -36,6 +43,8 @@ public class FailOnNoProcessAutoDeploymentStrategy extends AbstractAutoDeploymen
} }
} }
deploymentBuilder = loadProjectManifest(deploymentBuilder);
if (validProcessCount != 0) { if (validProcessCount != 0) {
deploymentBuilder.deploy(); deploymentBuilder.deploy();
} else { } else {
......
package org.activiti.spring.autodeployment; package org.activiti.spring.autodeployment;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.DeploymentBuilder; import org.activiti.engine.repository.DeploymentBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -12,6 +13,10 @@ public class NeverFailAutoDeploymentStrategy extends AbstractAutoDeploymentStrat ...@@ -12,6 +13,10 @@ public class NeverFailAutoDeploymentStrategy extends AbstractAutoDeploymentStrat
public static final String DEPLOYMENT_MODE = "never-fail"; public static final String DEPLOYMENT_MODE = "never-fail";
public NeverFailAutoDeploymentStrategy(ProjectModelService projectModelService) {
super(projectModelService);
}
@Override @Override
protected String getDeploymentMode() { protected String getDeploymentMode() {
return DEPLOYMENT_MODE; return DEPLOYMENT_MODE;
...@@ -19,7 +24,7 @@ public class NeverFailAutoDeploymentStrategy extends AbstractAutoDeploymentStrat ...@@ -19,7 +24,7 @@ public class NeverFailAutoDeploymentStrategy extends AbstractAutoDeploymentStrat
@Override @Override
public void deployResources(String deploymentNameHint, Resource[] resources, RepositoryService repositoryService) { public void deployResources(String deploymentNameHint, Resource[] resources, RepositoryService repositoryService) {
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering() DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering()
.name(deploymentNameHint); .name(deploymentNameHint);
int validProcessCount = 0; int validProcessCount = 0;
...@@ -35,6 +40,8 @@ public class NeverFailAutoDeploymentStrategy extends AbstractAutoDeploymentStrat ...@@ -35,6 +40,8 @@ public class NeverFailAutoDeploymentStrategy extends AbstractAutoDeploymentStrat
} }
} }
deploymentBuilder = loadProjectManifest(deploymentBuilder);
if (validProcessCount != 0) { if (validProcessCount != 0) {
deploymentBuilder.deploy(); deploymentBuilder.deploy();
} }
......
...@@ -20,8 +20,11 @@ import java.util.Map; ...@@ -20,8 +20,11 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.DeploymentBuilder; import org.activiti.engine.repository.DeploymentBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
/** /**
...@@ -39,6 +42,10 @@ public class ResourceParentFolderAutoDeploymentStrategy extends AbstractAutoDepl ...@@ -39,6 +42,10 @@ public class ResourceParentFolderAutoDeploymentStrategy extends AbstractAutoDepl
private static final String DEPLOYMENT_NAME_PATTERN = "%s.%s"; private static final String DEPLOYMENT_NAME_PATTERN = "%s.%s";
public ResourceParentFolderAutoDeploymentStrategy(ProjectModelService projectModelService) {
super(projectModelService);
}
@Override @Override
protected String getDeploymentMode() { protected String getDeploymentMode() {
return DEPLOYMENT_MODE; return DEPLOYMENT_MODE;
...@@ -56,7 +63,7 @@ public class ResourceParentFolderAutoDeploymentStrategy extends AbstractAutoDepl ...@@ -56,7 +63,7 @@ public class ResourceParentFolderAutoDeploymentStrategy extends AbstractAutoDepl
final String deploymentName = determineDeploymentName(deploymentNameHint, group.getKey()); final String deploymentName = determineDeploymentName(deploymentNameHint, group.getKey());
final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentName); DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentName);
for (final Resource resource : group.getValue()) { for (final Resource resource : group.getValue()) {
final String resourceName = determineResourceName(resource); final String resourceName = determineResourceName(resource);
...@@ -64,7 +71,8 @@ public class ResourceParentFolderAutoDeploymentStrategy extends AbstractAutoDepl ...@@ -64,7 +71,8 @@ public class ResourceParentFolderAutoDeploymentStrategy extends AbstractAutoDepl
deploymentBuilder.addInputStream(resourceName, deploymentBuilder.addInputStream(resourceName,
resource); resource);
} }
deploymentBuilder.deploy();
loadProjectManifest(deploymentBuilder).deploy();
} }
} }
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
package org.activiti.spring.autodeployment; package org.activiti.spring.autodeployment;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.DeploymentBuilder; import org.activiti.engine.repository.DeploymentBuilder;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
...@@ -29,6 +31,10 @@ public class SingleResourceAutoDeploymentStrategy extends AbstractAutoDeployment ...@@ -29,6 +31,10 @@ public class SingleResourceAutoDeploymentStrategy extends AbstractAutoDeployment
*/ */
public static final String DEPLOYMENT_MODE = "single-resource"; public static final String DEPLOYMENT_MODE = "single-resource";
public SingleResourceAutoDeploymentStrategy(ProjectModelService projectModelService) {
super(projectModelService);
}
@Override @Override
protected String getDeploymentMode() { protected String getDeploymentMode() {
return DEPLOYMENT_MODE; return DEPLOYMENT_MODE;
...@@ -48,7 +54,8 @@ public class SingleResourceAutoDeploymentStrategy extends AbstractAutoDeployment ...@@ -48,7 +54,8 @@ public class SingleResourceAutoDeploymentStrategy extends AbstractAutoDeployment
deploymentBuilder.addInputStream(resourceName, deploymentBuilder.addInputStream(resourceName,
resource); resource);
deploymentBuilder.deploy(); loadProjectManifest(deploymentBuilder).deploy();
} }
} }
......
...@@ -16,9 +16,11 @@ package org.activiti.spring.test.autodeployment; ...@@ -16,9 +16,11 @@ package org.activiti.spring.test.autodeployment;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import org.activiti.core.common.spring.project.ProjectModelService;
import org.activiti.engine.RepositoryService; import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment; import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.DeploymentBuilder; import org.activiti.engine.repository.DeploymentBuilder;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.junit.Before; import org.junit.Before;
import org.mockito.Mock; import org.mockito.Mock;
import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ByteArrayResource;
...@@ -73,6 +75,9 @@ public class AbstractAutoDeploymentStrategyTest { ...@@ -73,6 +75,9 @@ public class AbstractAutoDeploymentStrategyTest {
@Mock @Mock
private Deployment deploymentMock; private Deployment deploymentMock;
@Mock
protected ProjectModelService projectModelServiceMock;
protected final String deploymentNameHint = "nameHint"; protected final String deploymentNameHint = "nameHint";
protected final String resourceName1 = "resourceName1.bpmn"; protected final String resourceName1 = "resourceName1.bpmn";
......
...@@ -38,7 +38,7 @@ public class DefaultAutoDeploymentStrategyTest extends AbstractAutoDeploymentStr ...@@ -38,7 +38,7 @@ public class DefaultAutoDeploymentStrategyTest extends AbstractAutoDeploymentStr
@Before @Before
public void before() throws Exception { public void before() throws Exception {
super.before(); super.before();
deploymentStrategy = new DefaultAutoDeploymentStrategy(); deploymentStrategy = new DefaultAutoDeploymentStrategy(projectModelServiceMock);
} }
@Test @Test
......
...@@ -39,7 +39,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes ...@@ -39,7 +39,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes
@Test @Test
public void testValidResources() { public void testValidResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1)};
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -47,7 +47,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes ...@@ -47,7 +47,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes
@Test @Test
public void testInvalidResources() { public void testInvalidResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1), new ClassPathResource(invalidName2)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1), new ClassPathResource(invalidName2)};
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -55,7 +55,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes ...@@ -55,7 +55,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes
@Test @Test
public void testWithParsingErrorResources() { public void testWithParsingErrorResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1)};
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -63,7 +63,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes ...@@ -63,7 +63,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes
@Test @Test
public void testWithValidationErrorResources() { public void testWithValidationErrorResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName2)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName2)};
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -71,7 +71,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes ...@@ -71,7 +71,7 @@ public class FailOnNoProcessAutoDeploymentStrategyTest extends SpringActivitiTes
@Test @Test
public void testOnlyInvalidResources() { public void testOnlyInvalidResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(invalidName1)}; final Resource[] resources = new Resource[]{new ClassPathResource(invalidName1)};
FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(); FailOnNoProcessAutoDeploymentStrategy deploymentStrategy = new FailOnNoProcessAutoDeploymentStrategy(null);
try { try {
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
} catch (ActivitiException e) { } catch (ActivitiException e) {
......
...@@ -38,7 +38,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase ...@@ -38,7 +38,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase
@Test @Test
public void testValidResources() { public void testValidResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1)};
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -46,7 +46,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase ...@@ -46,7 +46,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase
@Test @Test
public void testInvalidResources() { public void testInvalidResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1), new ClassPathResource(invalidName2)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1), new ClassPathResource(invalidName2)};
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -54,7 +54,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase ...@@ -54,7 +54,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase
@Test @Test
public void testWithParsingErrorResources() { public void testWithParsingErrorResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName1)};
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -62,7 +62,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase ...@@ -62,7 +62,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase
@Test @Test
public void testWithValidationErrorResources() { public void testWithValidationErrorResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName2)}; final Resource[] resources = new Resource[]{new ClassPathResource(validName1), new ClassPathResource(invalidName2)};
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(1, repositoryService.createDeploymentQuery().count()); assertEquals(1, repositoryService.createDeploymentQuery().count());
} }
...@@ -70,7 +70,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase ...@@ -70,7 +70,7 @@ public class NeverFailAutoDeploymentStrategyTest extends SpringActivitiTestCase
@Test @Test
public void testOnlyInvalidResources() { public void testOnlyInvalidResources() {
final Resource[] resources = new Resource[]{new ClassPathResource(invalidName1)}; final Resource[] resources = new Resource[]{new ClassPathResource(invalidName1)};
NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(); NeverFailAutoDeploymentStrategy deploymentStrategy = new NeverFailAutoDeploymentStrategy(null);
deploymentStrategy.deployResources(nameHint, resources, repositoryService); deploymentStrategy.deployResources(nameHint, resources, repositoryService);
assertEquals(0, repositoryService.createDeploymentQuery().count()); assertEquals(0, repositoryService.createDeploymentQuery().count());
} }
......
...@@ -51,7 +51,7 @@ public class ResourceParentFolderAutoDeploymentStrategyTest extends AbstractAuto ...@@ -51,7 +51,7 @@ public class ResourceParentFolderAutoDeploymentStrategyTest extends AbstractAuto
@Before @Before
public void before() throws Exception { public void before() throws Exception {
super.before(); super.before();
deploymentStrategy = new ResourceParentFolderAutoDeploymentStrategy(); deploymentStrategy = new ResourceParentFolderAutoDeploymentStrategy(projectModelServiceMock);
assertNotNull(deploymentStrategy); assertNotNull(deploymentStrategy);
when(parentFile1Mock.getName()).thenReturn(parentFilename1); when(parentFile1Mock.getName()).thenReturn(parentFilename1);
......
...@@ -37,7 +37,7 @@ public class SingleResourceAutoDeploymentStrategyTest extends AbstractAutoDeploy ...@@ -37,7 +37,7 @@ public class SingleResourceAutoDeploymentStrategyTest extends AbstractAutoDeploy
@Before @Before
public void before() throws Exception { public void before() throws Exception {
super.before(); super.before();
deploymentStrategy = new SingleResourceAutoDeploymentStrategy(); deploymentStrategy = new SingleResourceAutoDeploymentStrategy(projectModelServiceMock);
assertNotNull(deploymentStrategy); assertNotNull(deploymentStrategy);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册