Search in sources :

Example 21 with DeploymentBuilder

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");
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InputStream(java.io.InputStream) Deployment(org.camunda.bpm.engine.repository.Deployment) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 22 with DeploymentBuilder

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");
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InputStream(java.io.InputStream) Deployment(org.camunda.bpm.engine.repository.Deployment) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 23 with DeploymentBuilder

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);
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InputStream(java.io.InputStream) Deployment(org.camunda.bpm.engine.repository.Deployment) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 24 with DeploymentBuilder

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());
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InputStream(java.io.InputStream) Deployment(org.camunda.bpm.engine.repository.Deployment) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) Test(org.junit.Test)

Example 25 with DeploymentBuilder

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();
}
Also used : DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder)

Aggregations

DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)26 Test (org.junit.Test)14 Deployment (org.camunda.bpm.engine.repository.Deployment)11 InputStream (java.io.InputStream)10 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)10 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)8 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 IdentityLink (org.camunda.bpm.engine.task.IdentityLink)4 IOException (java.io.IOException)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)2 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 Method (java.lang.reflect.Method)1 ZipInputStream (java.util.zip.ZipInputStream)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)1 ByteArrayResource (org.springframework.core.io.ByteArrayResource)1 ContextResource (org.springframework.core.io.ContextResource)1