org.camunda.bpm.engine.runtime.JobQuery Java Examples

The following examples show how to use org.camunda.bpm.engine.runtime.JobQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryByDuedateLowerThenOrEqual() {
  JobQuery query = managementService.createJobQuery().duedateLowerThenOrEquals(testStartTime);
  verifyQueryResults(query, 0);

  query = managementService.createJobQuery().duedateLowerThenOrEquals(timerOneFireTime);
  verifyQueryResults(query, 1);

  query = managementService.createJobQuery().duedateLowerThenOrEquals(timerTwoFireTime);
  verifyQueryResults(query, 2);

  query = managementService.createJobQuery().duedateLowerThenOrEquals(timerThreeFireTime);
  verifyQueryResults(query, 3);

  if (ensureJobDueDateSet) {
    query = managementService.createJobQuery().duedateLowerThenOrEquals(messageDueDate);
    verifyQueryResults(query, 4);
  }
}
 
Example #2
Source File: IntermediateTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTimeCycle() {
  String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();

  JobQuery query = managementService.createJobQuery();
  assertEquals(1, query.count());

  String jobId = query.singleResult().getId();
  managementService.executeJob(jobId);

  assertEquals(0, query.count());

  String taskId = taskService.createTaskQuery().singleResult().getId();
  taskService.complete(taskId);

  assertProcessEnded(processInstanceId);
}
 
Example #3
Source File: CdiRetryConfigurationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@OperateOnDeployment("clientDeployment")
public void testResolveBean() {
  // given
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testRetry");

  JobQuery query = managementService
      .createJobQuery()
      .processInstanceId(processInstance.getId());

  Job job = query.singleResult();

  // when job fails
   try {
     managementService.executeJob(job.getId());
   } catch (Exception e) {
     // ignore
   }

   // then
   job = query.singleResult();
   Assert.assertEquals(6, job.getRetries());
}
 
Example #4
Source File: SuspendJobTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn"})
public void testSuspensionByIdUsingBuilder() {
  // given

  // a running process instance with a failed job
  runtimeService.startProcessInstanceByKey("suspensionProcess",
      Variables.createVariables().putValue("fail", true));

  // the failed job
  JobQuery jobQuery = managementService.createJobQuery();
  Job job = jobQuery.singleResult();
  assertFalse(job.isSuspended());

  // when
  // the job will be suspended
  managementService
    .updateJobSuspensionState()
    .byJobId(job.getId())
    .suspend();

  // then
  // the job should be suspended
  assertEquals(0, jobQuery.active().count());
  assertEquals(1, jobQuery.suspended().count());
}
 
Example #5
Source File: StartTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTimeCycle() {
  // given
  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(1, jobQuery.count());

  String jobId = jobQuery.singleResult().getId();

  // when
  managementService.executeJob(jobId);

  // then
  assertEquals(1, jobQuery.count());

  String anotherJobId = jobQuery.singleResult().getId();
  assertFalse(jobId.equals(anotherJobId));
}
 
Example #6
Source File: StartTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testNonInterruptingTimeCycleInEventSubProcess() {
  // given
  runtimeService.startProcessInstanceByKey("process");

  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(1, jobQuery.count());

  String jobId = jobQuery.singleResult().getId();

  // when
  managementService.executeJob(jobId);

  // then
  assertEquals(1, jobQuery.count());

  String anotherJobId = jobQuery.singleResult().getId();
  assertFalse(jobId.equals(anotherJobId));
}
 
Example #7
Source File: ExclusiveTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testCatchingTimerEvent() throws Exception {

  // Set the clock fixed
  Date startTime = new Date();

  // After process start, there should be 3 timers created
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveTimers");
  JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
  assertEquals(3, jobQuery.count());

  // After setting the clock to time '50minutes and 5 seconds', the timers should fire
  ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
  waitForJobExecutorToProcessAllJobs(5000L);

  assertEquals(0, jobQuery.count());
  assertProcessEnded(pi.getProcessInstanceId());


}
 
Example #8
Source File: MultiTenancyProcessInstanceSuspensionStateTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void suspendProcessInstanceIncludingJobForTenant() {
  // given activated jobs
  JobQuery query = engineRule.getManagementService().createJobQuery();
  assertThat(query.active().count(), is(3L));
  assertThat(query.suspended().count(), is(0L));

  engineRule.getRuntimeService()
    .updateProcessInstanceSuspensionState()
    .byProcessDefinitionKey(PROCESS_DEFINITION_KEY)
    .processDefinitionTenantId(TENANT_ONE)
    .suspend();

  assertThat(query.active().count(), is(2L));
  assertThat(query.suspended().count(), is(1L));
  assertThat(query.suspended().tenantIdIn(TENANT_ONE).count(), is(1L));
}
 
Example #9
Source File: JobAcquisitionBackoffIdleTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected  void cycleAcquisitionAndAssertAfterJobExecution(JobQuery jobQuery) {
  // another cycle of job acquisition after acuqisition idle was reseted
  // => 1 jobs are acquired
  triggerReconfigurationAndNextCycle();
  assertJobExecutorWaitEvent(0);

  // we have no timer to fire
  assertEquals(0, jobQuery.count());

  // and we are in the second state
  assertEquals(1L, engineRule.getTaskService().createTaskQuery().count());
  Task task = engineRule.getTaskService().createTaskQuery().orderByTaskName().desc().singleResult();
  assertEquals("Next Task", task.getName());
  // complete the task and end the execution
  engineRule.getTaskService().complete(task.getId());
}
 
Example #10
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryByDuedateLowerThen() {
  JobQuery query = managementService.createJobQuery().duedateLowerThen(testStartTime);
  verifyQueryResults(query, 0);

  query = managementService.createJobQuery().duedateLowerThen(new Date(timerOneFireTime.getTime() + ONE_SECOND));
  verifyQueryResults(query, 1);

  query = managementService.createJobQuery().duedateLowerThen(new Date(timerTwoFireTime.getTime() + ONE_SECOND));
  verifyQueryResults(query, 2);

  query = managementService.createJobQuery().duedateLowerThen(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
  verifyQueryResults(query, 3);

  if (ensureJobDueDateSet) {
    query = managementService.createJobQuery().duedateLowerThen(new Date(messageDueDate.getTime() + ONE_SECOND));
    verifyQueryResults(query, 4);
  }
}
 
Example #11
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testQueryByExecutable() {
  long testTime = ensureJobDueDateSet? messageDueDate.getTime() : timerThreeFireTime.getTime();
  int expectedCount = ensureJobDueDateSet? 0 : 1;

  ClockUtil.setCurrentTime(new Date(testTime + ONE_SECOND)); // all jobs should be executable at t3 + 1hour.1second
  JobQuery query = managementService.createJobQuery().executable();
  verifyQueryResults(query, 4);

  // Setting retries of one job to 0, makes it non-executable
  setRetries(processInstanceIdOne, 0);
  verifyQueryResults(query, 3);

  // Setting the clock before the start of the process instance, makes none of the jobs executable
  ClockUtil.setCurrentTime(testStartTime);
  verifyQueryResults(query, expectedCount); // 1, since a message is always executable when retries > 0
}
 
Example #12
Source File: JobRestServiceImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public List<JobDto> queryJobs(JobQueryDto queryDto, Integer firstResult,
                              Integer maxResults) {
  ProcessEngine engine = getProcessEngine();
  queryDto.setObjectMapper(getObjectMapper());
  JobQuery query = queryDto.toQuery(engine);

  List<Job> matchingJobs;
  if (firstResult != null || maxResults != null) {
    matchingJobs = executePaginatedQuery(query, firstResult, maxResults);
  } else {
    matchingJobs = query.list();
  }

  List<JobDto> jobResults = new ArrayList<JobDto>();
  for (Job job : matchingJobs) {
    JobDto resultJob = JobDto.fromJob(job);
    jobResults.add(resultJob);
  }
  return jobResults;
}
 
Example #13
Source File: BoundaryTimerNonInterruptingEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/timer/BoundaryTimerNonInterruptingEventTest.testTimerWithCycle.bpmn20.xml"})
@Test
public void testTimeCycle() {
  // given
  runtimeService.startProcessInstanceByKey("nonInterruptingCycle");

  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(1, jobQuery.count());
  String jobId = jobQuery.singleResult().getId();

  // when
  managementService.executeJob(jobId);

  // then
  assertEquals(1, jobQuery.count());

  String anotherJobId = jobQuery.singleResult().getId();
  assertFalse(jobId.equals(anotherJobId));
}
 
Example #14
Source File: TaskListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@Deployment
public void testRecalculateTimeoutTaskListenerDuedateCreationDateBasedWithDefinedBoundaryEvent() {
  // given
  ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", Variables.putValue("duration", "PT1H"));

  JobQuery jobQuery = managementService.createJobQuery()
      .processInstanceId(pi.getId())
      .activityId("userTask");
  List<Job> jobs = jobQuery.list();
  assertEquals(1, jobs.size());
  Job job = jobs.get(0);
  Date oldDate = job.getDuedate();

  // when
  runtimeService.setVariable(pi.getId(), "duration", "PT15M");
  managementService.recalculateJobDuedate(job.getId(), true);

  // then
  Job jobUpdated = jobQuery.singleResult();
  assertEquals(job.getId(), jobUpdated.getId());
  assertNotEquals(oldDate, jobUpdated.getDuedate());
  assertTrue(oldDate.after(jobUpdated.getDuedate()));
  assertEquals(LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusMinutes(15).toDate(), jobUpdated.getDuedate());
}
 
Example #15
Source File: SetJobRetriesBatchAuthorizationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void setupAndExecuteJobsQueryBasedTest() {
  //given
  JobQuery jobQuery = managementService.createJobQuery();
  authRule
      .init(scenario)
      .withUser("userId")
      .bindResource("Process", sourceDefinition.getKey())
      .bindResource("processInstance1", processInstance.getId())
      .bindResource("processInstance2", processInstance2.getId())
      .start();

  // when

  batch = managementService.setJobRetriesAsync(
      jobQuery, RETRIES);

  executeSeedAndBatchJobs();
}
 
Example #16
Source File: ActivateJobDefinitionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testMultipleSuspensionByProcessDefinitionKeyAndActivateJobsFlag_shouldSuspendJobs() {
  // given
  String key = "suspensionProcess";

  // Deploy three processes and start for each deployment a process instance
  // with a failed job
  int nrOfProcessDefinitions = 3;
  for (int i=0; i<nrOfProcessDefinitions; i++) {
    repositoryService.createDeployment()
      .addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy();
    Map<String, Object> params = new HashMap<>();
    params.put("fail", Boolean.TRUE);
    runtimeService.startProcessInstanceByKey(key, params);
  }

  // a job definition (which was created for the asynchronous continuation)
  // ...which will be suspended with the corresponding jobs
  managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);

  // when
  // activate the job definition
  managementService.activateJobDefinitionByProcessDefinitionKey(key, true);

  // then
  // all job definitions are active
  JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery();
  assertEquals(0, jobDefinitionQuery.suspended().count());
  assertEquals(3, jobDefinitionQuery.active().count());

  // and the jobs too
  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(0, jobQuery.suspended().count());
  assertEquals(3, jobQuery.active().count());

  // Clean DB
  for (org.camunda.bpm.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) {
    repositoryService.deleteDeployment(deployment.getId(), true);
  }

}
 
Example #17
Source File: StartTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/timer/StartTimerEventTest.testRecalculateExpressionStartTimerEvent.bpmn20.xml")
public void testRecalculateUnchangedExpressionStartTimerEventCreationDateBased() throws Exception {
  // given
  JobQuery jobQuery = managementService.createJobQuery();
  ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
  assertEquals(1, jobQuery.count());
  assertEquals(0, processInstanceQuery.count());
  
  // when
  moveByMinutes(1);
  managementService.recalculateJobDuedate(jobQuery.singleResult().getId(), true);
  
  // then due date should be based on the creation time
  assertEquals(1, jobQuery.count());
  assertEquals(0, processInstanceQuery.count());
  
  Job jobUpdated = jobQuery.singleResult();
  Date expectedDate = LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusHours(2).toDate();
  assertEquals(expectedDate, jobUpdated.getDuedate());

  // move the clock forward 2 hours and 1 minute
  moveByMinutes(121);
  executeAllJobs();

  List<ProcessInstance> pi = processInstanceQuery.list();
  assertEquals(1, pi.size());

  assertEquals(0, jobQuery.count());
}
 
Example #18
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryByJobIdsWithOneId() {
  // given
  String id = managementService.createJobQuery().processInstanceId(processInstanceIdOne).singleResult().getId();
  // when
  JobQuery query = managementService.createJobQuery().jobIds(Collections.singleton(id));
  // then
  verifyQueryResults(query, 1);
}
 
Example #19
Source File: MultiTenancyJobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByJobsWithoutTenantId() {
  JobQuery query = managementService
      .createJobQuery()
      .withoutTenantId();

  assertThat(query.count(), is(1L));
}
 
Example #20
Source File: MultiTenancyJobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByTenantIds() {
  JobQuery query = managementService
      .createJobQuery()
      .tenantIdIn(TENANT_ONE, TENANT_TWO);

  assertThat(query.count(), is(2L));
}
 
Example #21
Source File: MultiTenancyJobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testQueryByNonExistingTenantId() {
  JobQuery query = managementService
      .createJobQuery()
      .tenantIdIn("nonExisting");

  assertThat(query.count(), is(0L));
}
 
Example #22
Source File: StartTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * test scenario: - start process instance with multiInstance parallel -
 * execute interrupting timer job of event subprocess - execute interrupting
 * timer boundary event of subprocess
 */
@Deployment
public void testStartTimerEventSubProcessInParallelMultiInstanceSubProcessWithInterruptingBoundaryTimerEvent() {
  // start process instance
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");

  // execute multiInstance loop number 1
  // check if execution exists
  ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
  assertEquals(6, executionQuery.count());

  // check if user task exists
  TaskQuery taskQuery = taskService.createTaskQuery();
  assertEquals(2, taskQuery.count());

  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(3, jobQuery.count());

  // execute interrupting timer job
  managementService.executeJob(jobQuery.orderByJobDuedate().asc().list().get(1).getId());

  // after interrupting timer job execution
  assertEquals(2, jobQuery.count());
  assertEquals(1, taskQuery.count());
  assertEquals(5, executionQuery.count());

  // execute interrupting boundary timer job
  managementService.executeJob(jobQuery.orderByJobDuedate().asc().list().get(0).getId());

  // after interrupting boundary timer job execution
  assertEquals(0, jobQuery.count());
  assertEquals(0, taskQuery.count());
  assertEquals(0, executionQuery.count());

  assertProcessEnded(processInstance.getId());

}
 
Example #23
Source File: IntermediateTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/timer/IntermediateTimerEventTest.testRecalculateTimeCycleExpressionCurrentDateBased.bpmn20.xml")
public void testRecalculateTimeCycleExpressionCreationDateBased() {
  // given
  Map<String, Object> variables = new HashMap<>();
  variables.put("cycle", "R/PT15M");
  String processInstanceId = runtimeService.startProcessInstanceByKey("process", variables).getId();

  JobQuery query = managementService.createJobQuery();
  assertEquals(1, query.count());
  Job job = query.singleResult();
  Date oldDuedate = job.getDuedate();
  String jobId = job.getId();

  // when
  runtimeService.setVariable(processInstanceId, "cycle", "R/PT10M");
  managementService.recalculateJobDuedate(jobId, true);

  // then
  assertEquals(1, query.count());
  Date newDuedate = query.singleResult().getDuedate();
  assertTrue(oldDuedate.after(newDuedate));
  Date expectedDate = LocalDateTime.fromDateFields(job.getCreateTime()).plusMinutes(10).toDate();
  assertEquals(expectedDate, newDuedate);

  managementService.executeJob(jobId);
  String taskId = taskService.createTaskQuery().singleResult().getId();
  taskService.complete(taskId);

  assertProcessEnded(processInstanceId);
}
 
Example #24
Source File: StartTimerEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testExpressionStartTimerEvent() throws Exception {
  // ACT-1415: fixed start-date is an expression
  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(1, jobQuery.count());

  ClockUtil.setCurrentTime(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("15/11/2036 11:12:30"));
  executeAllJobs();

  List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
  assertEquals(1, pi.size());

  assertEquals(0, jobQuery.count());
}
 
Example #25
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryByProcessInstanceIdsWithOneId() {
  // when
  JobQuery query = managementService.createJobQuery().processInstanceIds(Collections.singleton(processInstanceIdOne));
  // then
  verifyQueryResults(query, 1);
}
 
Example #26
Source File: ActivateJobDefinitionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn"})
public void testActivationJobDefinitionIncludingJobsUsingBuilder() {
  // given
  // a deployed process definition with asynchronous continuation

  // a running process instance with a failed job
  runtimeService.startProcessInstanceByKey("suspensionProcess",
      Variables.createVariables().putValue("fail", true));

  // a job definition (which was created for the asynchronous continuation)
  // ...which will be suspended with the corresponding jobs
  managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);

  JobDefinitionQuery query = managementService.createJobDefinitionQuery();
  JobDefinition jobDefinition = query.singleResult();

  JobQuery jobQuery = managementService.createJobQuery();
  assertEquals(0, jobQuery.active().count());
  assertEquals(1, jobQuery.suspended().count());

  // when
  // activate the job definition
  managementService
    .updateJobDefinitionSuspensionState()
    .byJobDefinitionId(jobDefinition.getId())
    .includeJobs(true)
    .activate();

  // then
  // there exists a active job definition
  assertEquals(1, jobQuery.active().count());
  assertEquals(0, jobQuery.suspended().count());
}
 
Example #27
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testByJobDefinitionId() {
  JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();

  JobQuery query = managementService.createJobQuery().jobDefinitionId(jobDefinition.getId());
  verifyQueryResults(query, 3);
}
 
Example #28
Source File: JobExecutorCmdExceptionTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void testJobCommandsWith2Exceptions() {
  // create a job
  createJob(TweetExceptionHandler.TYPE);

  // execute the existing job
  executeAvailableJobs();

  // the job was successfully executed
  JobQuery query = managementService.createJobQuery().noRetriesLeft();
  assertEquals(0, query.count());
}
 
Example #29
Source File: JobQueryTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testQueryByJobIdsWithMultipleIdsIncludingFakeIds() {
  // given
  Set<String> ids = new HashSet<>();
  ids.addAll(managementService.createJobQuery().list().stream().map(Job::getId).collect(Collectors.toSet()));
  Collections.addAll(ids, "fakeIdOne", "fakeIdTwo");
  // when
  JobQuery query = managementService.createJobQuery().jobIds(ids);
  // then
  verifyQueryResults(query, 4);
}
 
Example #30
Source File: MultiTenancyTimerStartEventTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void dontCreateNewJobsWhileReDeployment() {

  testRule.deployForTenant(TENANT_ONE, PROCESS);
  testRule.deployForTenant(TENANT_TWO, PROCESS);
  testRule.deployForTenant(TENANT_ONE, PROCESS);

  JobQuery query = managementService.createJobQuery();
  assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
  assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L));
}