Search in sources :

Example 1 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery 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 JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class JobDefinitionRestServiceInteractionTest method setUpMockJobDefinitionQuery.

private JobDefinitionQuery setUpMockJobDefinitionQuery(List<JobDefinition> mockedJobDefinitions) {
    JobDefinitionQuery sampleJobDefinitionQuery = mock(JobDefinitionQuery.class);
    when(sampleJobDefinitionQuery.list()).thenReturn(mockedJobDefinitions);
    when(sampleJobDefinitionQuery.count()).thenReturn((long) mockedJobDefinitions.size());
    if (mockedJobDefinitions.size() == 1) {
        when(sampleJobDefinitionQuery.singleResult()).thenReturn(mockedJobDefinitions.get(0));
    }
    when(sampleJobDefinitionQuery.jobDefinitionId(MockProvider.EXAMPLE_JOB_DEFINITION_ID)).thenReturn(sampleJobDefinitionQuery);
    when(processEngine.getManagementService().createJobDefinitionQuery()).thenReturn(sampleJobDefinitionQuery);
    when(mockManagementService.createJobDefinitionQuery()).thenReturn(sampleJobDefinitionQuery);
    return sampleJobDefinitionQuery;
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery)

Example 3 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class JobDefinitionRestServiceInteractionTest method testJobDefinitionGetIdDoesntExist.

@Test
public void testJobDefinitionGetIdDoesntExist() {
    JobDefinitionQuery invalidQueryNonExistingJobDefinition;
    invalidQueryNonExistingJobDefinition = mock(JobDefinitionQuery.class);
    when(mockManagementService.createJobDefinitionQuery().jobDefinitionId(MockProvider.NON_EXISTING_JOB_DEFINITION_ID)).thenReturn(invalidQueryNonExistingJobDefinition);
    when(invalidQueryNonExistingJobDefinition.singleResult()).thenReturn(null);
    String jobDefinitionId = MockProvider.NON_EXISTING_JOB_DEFINITION_ID;
    given().pathParam("id", jobDefinitionId).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Job Definition with id " + jobDefinitionId + " does not exist")).when().get(SINGLE_JOB_DEFINITION_RESOURCE_URL);
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class JobDefinitionRestServiceQueryTest method setUpMockDefinitionQuery.

private JobDefinitionQuery setUpMockDefinitionQuery(List<JobDefinition> mockedJobDefinitions) {
    JobDefinitionQuery query = mock(JobDefinitionQuery.class);
    when(query.list()).thenReturn(mockedJobDefinitions);
    when(query.count()).thenReturn((long) mockedJobDefinitions.size());
    when(processEngine.getManagementService().createJobDefinitionQuery()).thenReturn(query);
    return query;
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery)

Example 5 with JobDefinitionQuery

use of org.camunda.bpm.engine.management.JobDefinitionQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyJobDefinitionQueryTest method testQueryByDefinitionsWithoutTenantIds.

public void testQueryByDefinitionsWithoutTenantIds() {
    JobDefinitionQuery query = managementService.createJobDefinitionQuery().withoutTenantId();
    assertThat(query.count(), is(1L));
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery)

Aggregations

JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)163 Deployment (org.camunda.bpm.engine.test.Deployment)89 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)88 HashMap (java.util.HashMap)86 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)86 Job (org.camunda.bpm.engine.runtime.Job)78 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)54 Test (org.junit.Test)31 Date (java.util.Date)12 InputStream (java.io.InputStream)10 Deployment (org.camunda.bpm.engine.repository.Deployment)10 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 ArrayList (java.util.ArrayList)2 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 JobDefinitionDto (org.camunda.bpm.engine.rest.dto.management.JobDefinitionDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 Matchers.anyString (org.mockito.Matchers.anyString)1