use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class JobDefinitionCreationWithParseListenerTest method testCreateJobDefinitionWithParseListener.
@Test
public void testCreateJobDefinitionWithParseListener() {
// given
String modelFileName = "jobCreationWithinParseListener.bpmn20.xml";
InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
// when the asyncBefore is set in the parse listener
Deployment deployment = builder.deploy();
engineRule.manageDeployment(deployment);
// then there exists a new job definition
JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
JobDefinition jobDef = query.singleResult();
assertNotNull(jobDef);
assertEquals(jobDef.getProcessDefinitionKey(), "oneTaskProcess");
assertEquals(jobDef.getActivityId(), "servicetask1");
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class JobDefinitionCreationWithParseListenerTest method testCreateJobDefinitionWithParseListenerAndAsyncInXml.
@Test
public void testCreateJobDefinitionWithParseListenerAndAsyncInXml() {
// given the asyncBefore is set in the xml
String modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml";
InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
// when the asyncBefore is set in the parse listener
Deployment deployment = builder.deploy();
engineRule.manageDeployment(deployment);
// then there exists only one job definition
JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
JobDefinition jobDef = query.singleResult();
assertNotNull(jobDef);
assertEquals(jobDef.getProcessDefinitionKey(), "oneTaskProcess");
assertEquals(jobDef.getActivityId(), "servicetask1");
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class JobDefinitionCreationBothAsyncWithParseListenerTest method testCreateBothAsyncJobDefinitionWithParseListener.
@Test
public void testCreateBothAsyncJobDefinitionWithParseListener() {
// given
String modelFileName = "jobCreationWithinParseListener.bpmn20.xml";
InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
// when the asyncBefore and asyncAfter is set to true in the parse listener
Deployment deployment = builder.deploy();
engineRule.manageDeployment(deployment);
// then there exists two job definitions
JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
List<JobDefinition> definitions = query.orderByJobConfiguration().asc().list();
assertEquals(definitions.size(), 2);
// asyncAfter
JobDefinition asyncAfterAfter = definitions.get(0);
assertEquals(asyncAfterAfter.getProcessDefinitionKey(), "oneTaskProcess");
assertEquals(asyncAfterAfter.getActivityId(), "servicetask1");
assertEquals(asyncAfterAfter.getJobConfiguration(), MessageJobDeclaration.ASYNC_AFTER);
// asyncBefore
JobDefinition asyncAfterBefore = definitions.get(1);
assertEquals(asyncAfterBefore.getProcessDefinitionKey(), "oneTaskProcess");
assertEquals(asyncAfterBefore.getActivityId(), "servicetask1");
assertEquals(asyncAfterBefore.getJobConfiguration(), MessageJobDeclaration.ASYNC_BEFORE);
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class JobDefinitionDeletionWithParseListenerTest method testDeleteNonExistingJobDefinitionWithParseListener.
@Test
public void testDeleteNonExistingJobDefinitionWithParseListener() {
// given
String modelFileName = "jobCreationWithinParseListener.bpmn20.xml";
InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
// when the asyncBefore is set to false in the parse listener
Deployment deployment = builder.deploy();
engineRule.manageDeployment(deployment);
// then there exists no job definition
JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
assertNull(query.singleResult());
}
use of org.camunda.bpm.engine.repository.DeploymentBuilder in project camunda-bpm-platform by camunda.
the class RepositoryServiceTest method testDeleteDeploymentSkipCustomListeners.
public void testDeleteDeploymentSkipCustomListeners() {
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/RepositoryServiceTest.testDeleteProcessInstanceSkipCustomListeners.bpmn20.xml");
String deploymentId = deploymentBuilder.deploy().getId();
runtimeService.startProcessInstanceByKey("testProcess");
repositoryService.deleteDeployment(deploymentId, true, false);
assertEquals(1, TestExecutionListener.collectedEvents.size());
TestExecutionListener.reset();
deploymentId = deploymentBuilder.deploy().getId();
runtimeService.startProcessInstanceByKey("testProcess");
repositoryService.deleteDeployment(deploymentId, true, true);
assertTrue(TestExecutionListener.collectedEvents.isEmpty());
TestExecutionListener.reset();
}
Aggregations