public void testFailQueryByTenantIdNull() { try { runtimeService.createExecutionQuery() .tenantIdIn((String) null); fail("expected exception"); } catch (NullValueException e) { } }
public void testQueryByTenantIds() { ExecutionQuery query = runtimeService .createExecutionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO); assertThat(query.count(), is(2L)); }
public void testQueryAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); ExecutionQuery query = runtimeService.createExecutionQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).count(), is(1L)); }
public void testQueryByNonExistingTenantId() { ExecutionQuery query = runtimeService .createExecutionQuery() .tenantIdIn("nonExisting"); assertThat(query.count(), is(0L)); }
public void testQueryByTenantId() { ExecutionQuery query = runtimeService .createExecutionQuery() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); query = runtimeService .createExecutionQuery() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); }
public void testQuerySortingAsc() { // exclude executions without tenant id because of database-specific ordering List<Execution> executions = runtimeService.createExecutionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .asc() .list(); assertThat(executions.size(), is(2)); assertThat(executions.get(0).getTenantId(), is(TENANT_ONE)); assertThat(executions.get(1).getTenantId(), is(TENANT_TWO)); }
public void testQuerySortingDesc() { // exclude executions without tenant id because of database-specific ordering List<Execution> executions = runtimeService.createExecutionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .desc() .list(); assertThat(executions.size(), is(2)); assertThat(executions.get(0).getTenantId(), is(TENANT_TWO)); assertThat(executions.get(1).getTenantId(), is(TENANT_ONE)); }
public void testQueryAuthenticatedTenants() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); ExecutionQuery query = runtimeService.createExecutionQuery(); assertThat(query.count(), is(3L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); assertThat(query.withoutTenantId().count(), is(1L)); }
query.tenantIdIn(tenantIdIn.toArray(new String[tenantIdIn.size()]));
query.tenantIdIn(tenantIdIn.toArray(new String[tenantIdIn.size()]));
@Test public void testTenantIdListPostParameter() { mockedQuery = setUpMockExecutionQuery(createMockExecutionsTwoTenants()); Map<String, Object> queryParameters = new HashMap<String, Object>(); queryParameters.put("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST.split(",")); Response response = given() .contentType(POST_JSON_CONTENT_TYPE) .body(queryParameters) .expect() .statusCode(Status.OK.getStatusCode()) .when() .post(EXECUTION_QUERY_URL); verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID); verify(mockedQuery).list(); String content = response.asString(); List<String> executions = from(content).getList(""); assertThat(executions).hasSize(2); String returnedTenantId1 = from(content).getString("[0].tenantId"); String returnedTenantId2 = from(content).getString("[1].tenantId"); assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID); assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID); }
@Test public void testTenantIdListParameter() { mockedQuery = setUpMockExecutionQuery(createMockExecutionsTwoTenants()); Response response = given() .queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID_LIST) .then().expect() .statusCode(Status.OK.getStatusCode()) .when() .get(EXECUTION_QUERY_URL); verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID); verify(mockedQuery).list(); String content = response.asString(); List<String> executions = from(content).getList(""); assertThat(executions).hasSize(2); String returnedTenantId1 = from(content).getString("[0].tenantId"); String returnedTenantId2 = from(content).getString("[1].tenantId"); assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID); assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID); }
@Test public void signalIntermediateCatchEventDisabledTenantCheck() { testRule.deployForTenant(TENANT_ONE, SIGNAL_CATCH_PROCESS); testRule.deployForTenant(TENANT_TWO, SIGNAL_CATCH_PROCESS); engineRule.getRuntimeService().createProcessInstanceByKey("signalCatch").processDefinitionTenantId(TENANT_ONE).execute(); engineRule.getRuntimeService().createProcessInstanceByKey("signalCatch").processDefinitionTenantId(TENANT_TWO).execute(); Execution execution = engineRule.getRuntimeService().createExecutionQuery() .processDefinitionKey("signalCatch") .signalEventSubscriptionName("signal") .tenantIdIn(TENANT_ONE) .singleResult(); engineRule.getProcessEngineConfiguration().setTenantCheckEnabled(false); engineRule.getIdentityService().setAuthentication("user", null, null); engineRule.getRuntimeService().signal(execution.getId(), "signal", null, null); TaskQuery query = engineRule.getTaskService().createTaskQuery(); assertThat(query.count(), is(1L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); }
@Test public void correlateReceivedMessageToIntermediateCatchEventDisabledTenantCheck() { testRule.deployForTenant(TENANT_ONE, MESSAGE_CATCH_PROCESS); testRule.deployForTenant(TENANT_TWO, MESSAGE_CATCH_PROCESS); engineRule.getProcessEngineConfiguration().setTenantCheckEnabled(false); engineRule.getIdentityService().setAuthentication("user", null, null); engineRule.getRuntimeService().createProcessInstanceByKey("messageCatch").processDefinitionTenantId(TENANT_ONE).execute(); engineRule.getRuntimeService().createProcessInstanceByKey("messageCatch").processDefinitionTenantId(TENANT_TWO).execute(); Execution execution = engineRule.getRuntimeService().createExecutionQuery() .processDefinitionKey("messageCatch") .messageEventSubscriptionName("message") .tenantIdIn(TENANT_ONE) .singleResult(); engineRule.getRuntimeService().messageEventReceived("message", execution.getId()); TaskQuery query = engineRule.getTaskService().createTaskQuery(); assertThat(query.count(), is(1L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); }
@Test public void failToCorrelateReceivedMessageToIntermediateCatchEventNoAuthenticatedTenants() { testRule.deployForTenant(TENANT_ONE, MESSAGE_CATCH_PROCESS); engineRule.getRuntimeService().createProcessInstanceByKey("messageCatch").processDefinitionTenantId(TENANT_ONE).execute(); Execution execution = engineRule.getRuntimeService().createExecutionQuery() .processDefinitionKey("messageCatch") .messageEventSubscriptionName("message") .tenantIdIn(TENANT_ONE) .singleResult(); // declare expected exception thrown.expect(ProcessEngineException.class); thrown.expectMessage("Cannot update the process instance"); engineRule.getIdentityService().setAuthentication("user", null, null); engineRule.getRuntimeService().messageEventReceived("message", execution.getId()); }
public void testQueryByTenantIds() { ExecutionQuery query = runtimeService .createExecutionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO); assertThat(query.count(), is(2L)); }
public void testQueryAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); ExecutionQuery query = runtimeService.createExecutionQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(0L)); assertThat(query.tenantIdIn(TENANT_ONE, TENANT_TWO).count(), is(1L)); }
public void testQueryByNonExistingTenantId() { ExecutionQuery query = runtimeService .createExecutionQuery() .tenantIdIn("nonExisting"); assertThat(query.count(), is(0L)); }
public void testQuerySortingDesc() { // exclude executions without tenant id because of database-specific ordering List<Execution> executions = runtimeService.createExecutionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .desc() .list(); assertThat(executions.size(), is(2)); assertThat(executions.get(0).getTenantId(), is(TENANT_TWO)); assertThat(executions.get(1).getTenantId(), is(TENANT_ONE)); }
public void testQuerySortingAsc() { // exclude executions without tenant id because of database-specific ordering List<Execution> executions = runtimeService.createExecutionQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO) .orderByTenantId() .asc() .list(); assertThat(executions.size(), is(2)); assertThat(executions.get(0).getTenantId(), is(TENANT_ONE)); assertThat(executions.get(1).getTenantId(), is(TENANT_TWO)); }