Search in sources :

Example 1 with JobDefinition

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);
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) ArrayList(java.util.ArrayList) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 2 with JobDefinition

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);
}
Also used : MockJobDefinitionBuilder(org.camunda.bpm.engine.rest.helper.MockJobDefinitionBuilder) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 3 with JobDefinition

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);
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 4 with 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;
}
Also used : JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Example 5 with JobDefinition

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);
}
Also used : Response(com.jayway.restassured.response.Response) HashMap(java.util.HashMap) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Aggregations

JobDefinition (org.camunda.bpm.engine.management.JobDefinition)219 Job (org.camunda.bpm.engine.runtime.Job)135 Deployment (org.camunda.bpm.engine.test.Deployment)112 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)86 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)73 HashMap (java.util.HashMap)67 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)64 Test (org.junit.Test)63 Batch (org.camunda.bpm.engine.batch.Batch)28 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)16 Date (java.util.Date)11 InputStream (java.io.InputStream)8 Deployment (org.camunda.bpm.engine.repository.Deployment)8 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)8 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)6 UserOperationLogEntry (org.camunda.bpm.engine.history.UserOperationLogEntry)4 ScenarioUnderTest (org.camunda.bpm.qa.upgrade.ScenarioUnderTest)4 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)3 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)3 Response (com.jayway.restassured.response.Response)2