use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.
the class JobDefinitionCreationBothAsyncWithParseListenerTest method testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml.
@Test
public void testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml() {
// given the asyncBefore AND asyncAfter is set in the xml
String modelFileName = "jobAsyncBothCreationWithinParseListener.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.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.
the class JobDefinitionCreationBothAsyncWithParseListenerTest method testCreateBothJobDefinitionWithParseListenerAndAsyncBeforeInXml.
@Test
public void testCreateBothJobDefinitionWithParseListenerAndAsyncBeforeInXml() {
// 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 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.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.
the class JobDefinitionDeletionWithParseListenerTest method testDeleteJobDefinitionWithParseListenerAndAsyncInXml.
@Test
public void testDeleteJobDefinitionWithParseListenerAndAsyncInXml() {
// 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 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.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.
the class JobDefinitionRestServiceImpl method queryJobDefinitionsCount.
public CountResultDto queryJobDefinitionsCount(JobDefinitionQueryDto queryDto) {
queryDto.setObjectMapper(getObjectMapper());
JobDefinitionQuery query = queryDto.toQuery(getProcessEngine());
long count = query.count();
CountResultDto result = new CountResultDto();
result.setCount(count);
return result;
}
use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.
the class JobDefinitionRestServiceImpl method queryJobDefinitions.
public List<JobDefinitionDto> queryJobDefinitions(JobDefinitionQueryDto queryDto, Integer firstResult, Integer maxResults) {
queryDto.setObjectMapper(getObjectMapper());
JobDefinitionQuery query = queryDto.toQuery(getProcessEngine());
List<JobDefinition> matchingJobDefinitions;
if (firstResult != null || maxResults != null) {
matchingJobDefinitions = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingJobDefinitions = query.list();
}
List<JobDefinitionDto> jobDefinitionResults = new ArrayList<JobDefinitionDto>();
for (JobDefinition jobDefinition : matchingJobDefinitions) {
JobDefinitionDto result = JobDefinitionDto.fromJobDefinition(jobDefinition);
jobDefinitionResults.add(result);
}
return jobDefinitionResults;
}
Aggregations