use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class ProcessEngineRestServiceTest method createJobDefinitionMock.
private void createJobDefinitionMock() {
List<JobDefinition> jobDefinitions = new ArrayList<JobDefinition>();
JobDefinition mockJobDefinition = MockProvider.createMockJobDefinition();
jobDefinitions.add(mockJobDefinition);
JobDefinitionQuery mockJobDefinitionQuery = mock(JobDefinitionQuery.class);
when(mockJobDefinitionQuery.list()).thenReturn(jobDefinitions);
when(mockManagementService.createJobDefinitionQuery()).thenReturn(mockJobDefinitionQuery);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionRestServiceInteractionTest method testJobDefinitionGetNullJobPriority.
@Test
public void testJobDefinitionGetNullJobPriority() {
// given
JobDefinition mockJobDefinition = new MockJobDefinitionBuilder().id(MockProvider.EXAMPLE_JOB_DEFINITION_ID).jobPriority(null).build();
when(mockQuery.singleResult()).thenReturn(mockJobDefinition);
given().pathParam("id", MockProvider.EXAMPLE_JOB_DEFINITION_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("id", equalTo(MockProvider.EXAMPLE_JOB_DEFINITION_ID)).body("jobPriority", nullValue()).when().get(SINGLE_JOB_DEFINITION_RESOURCE_URL);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionResourceImpl method getJobDefinition.
public JobDefinitionDto getJobDefinition() {
ManagementService managementService = engine.getManagementService();
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(jobDefinitionId).singleResult();
if (jobDefinition == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Job Definition with id " + jobDefinitionId + " does not exist");
}
return JobDefinitionDto.fromJobDefinition(jobDefinition);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class MockJobDefinitionBuilder method build.
public JobDefinition build() {
JobDefinition mockJobDefinition = mock(JobDefinition.class);
when(mockJobDefinition.getId()).thenReturn(id);
when(mockJobDefinition.getActivityId()).thenReturn(activityId);
when(mockJobDefinition.getJobConfiguration()).thenReturn(jobConfiguration);
when(mockJobDefinition.getOverridingJobPriority()).thenReturn(jobPriority);
when(mockJobDefinition.getJobType()).thenReturn(jobType);
when(mockJobDefinition.getProcessDefinitionId()).thenReturn(processDefinitionId);
when(mockJobDefinition.getProcessDefinitionKey()).thenReturn(processDefinitionKey);
when(mockJobDefinition.isSuspended()).thenReturn(suspended);
when(mockJobDefinition.getTenantId()).thenReturn(tenantId);
return mockJobDefinition;
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionRestServiceQueryTest method testIncludeJobDefinitionsWithoutTenantIdPostParameter.
@Test
public void testIncludeJobDefinitionsWithoutTenantIdPostParameter() {
List<JobDefinition> jobDefinitions = Arrays.asList(MockProvider.mockJobDefinition().tenantId(null).build(), MockProvider.mockJobDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
mockedQuery = setUpMockDefinitionQuery(jobDefinitions);
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("tenantIdIn", new String[] { MockProvider.EXAMPLE_TENANT_ID });
queryParameters.put("includeJobDefinitionsWithoutTenantId", true);
Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(queryParameters).expect().statusCode(Status.OK.getStatusCode()).when().post(JOB_DEFINITION_QUERY_URL);
verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(mockedQuery).includeJobDefinitionsWithoutTenantId();
verify(mockedQuery).list();
String content = response.asString();
List<String> definitions = from(content).getList("");
assertThat(definitions).hasSize(2);
String returnedTenantId1 = from(content).getString("[0].tenantId");
String returnedTenantId2 = from(content).getString("[1].tenantId");
assertThat(returnedTenantId1).isEqualTo(null);
assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
}
Aggregations