public void testQueryNoAuthenticatedTenants() {
    identityService.setAuthentication("user", null, null);

    HistoricCaseActivityInstanceQuery query =
        historyService.createHistoricCaseActivityInstanceQuery();
    assertThat(query.count(), is(0L));
  }
  public void testQueryDisabledTenantCheck() {
    processEngineConfiguration.setTenantCheckEnabled(false);
    identityService.setAuthentication("user", null, null);

    HistoricCaseActivityInstanceQuery query =
        historyService.createHistoricCaseActivityInstanceQuery();
    assertThat(query.count(), is(2L));
  }
  public void testQueryByTenantId() {
    HistoricCaseActivityInstanceQuery query =
        historyService.createHistoricCaseActivityInstanceQuery().tenantIdIn(TENANT_ONE);

    assertThat(query.count(), is(1L));

    query = historyService.createHistoricCaseActivityInstanceQuery().tenantIdIn(TENANT_TWO);

    assertThat(query.count(), is(1L));
  }
  public void testQueryAuthenticatedTenants() {
    identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO));

    HistoricCaseActivityInstanceQuery query =
        historyService.createHistoricCaseActivityInstanceQuery();

    assertThat(query.count(), is(2L));
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L));
  }
  public void testQueryByNonExistingTenantId() {
    HistoricCaseActivityInstanceQuery query =
        historyService.createHistoricCaseActivityInstanceQuery().tenantIdIn("nonExisting");

    assertThat(query.count(), is(0L));
  }
  public void testQueryWithoutTenantId() {
    HistoricCaseActivityInstanceQuery query =
        historyService.createHistoricCaseActivityInstanceQuery();

    assertThat(query.count(), is(2L));
  }