private HistoricVariableInstanceQuery setUpMockHistoricVariableInstanceQuery(List<HistoricVariableInstance> mockedHistoricVariableInstances) { HistoricVariableInstanceQuery mockedHistoricVariableInstanceQuery = mock(HistoricVariableInstanceQuery.class); when(mockedHistoricVariableInstanceQuery.list()).thenReturn(mockedHistoricVariableInstances); when(mockedHistoricVariableInstanceQuery.count()).thenReturn((long) mockedHistoricVariableInstances.size()); when(processEngine.getHistoryService().createHistoricVariableInstanceQuery()).thenReturn(mockedHistoricVariableInstanceQuery); return mockedHistoricVariableInstanceQuery; }
@Override public CountResultDto queryHistoricVariableInstancesCount(HistoricVariableInstanceQueryDto queryDto) { queryDto.setObjectMapper(objectMapper); HistoricVariableInstanceQuery query = queryDto.toQuery(processEngine); long count = query.count(); CountResultDto result = new CountResultDto(); result.setCount(count); return result; } }
@Override public CountResultDto queryHistoricVariableInstancesCount(HistoricVariableInstanceQueryDto queryDto) { queryDto.setObjectMapper(objectMapper); HistoricVariableInstanceQuery query = queryDto.toQuery(processEngine); long count = query.count(); CountResultDto result = new CountResultDto(); result.setCount(count); return result; } }
public void testQueryWithoutTenantId() { HistoricVariableInstanceQuery query = historyService. createHistoricVariableInstanceQuery(); assertThat(query.count(), is(2L)); }
public void testQueryAuthenticatedTenant() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertThat(query.count(), is(1L)); 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 testQueryAuthenticatedTenants() { identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE, TENANT_TWO)); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertThat(query.count(), is(2L)); assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L)); assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L)); }
public void testQueryNoAuthenticatedTenants() { identityService.setAuthentication("user", null, null); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertThat(query.count(), is(0L)); }
public void testQueryByTenantIds() { HistoricVariableInstanceQuery query = historyService .createHistoricVariableInstanceQuery() .tenantIdIn(TENANT_ONE, TENANT_TWO); assertThat(query.count(), is(2L)); }
public void testQueryByNonExistingTenantId() { HistoricVariableInstanceQuery query = historyService .createHistoricVariableInstanceQuery() .tenantIdIn("nonExisting"); assertThat(query.count(), is(0L)); }
public void testQueryDisabledTenantCheck() { processEngineConfiguration.setTenantCheckEnabled(false); identityService.setAuthentication("user", null, null); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertThat(query.count(), is(2L)); }
@Test public void testQueryCount() { expect() .statusCode(Status.OK.getStatusCode()) .body("count", equalTo(1)) .when() .get(HISTORIC_VARIABLE_INSTANCE_COUNT_RESOURCE_URL); verify(mockedQuery).count(); }
public void testQueryByTenantId() { HistoricVariableInstanceQuery query = historyService .createHistoricVariableInstanceQuery() .tenantIdIn(TENANT_ONE); assertThat(query.count(), is(1L)); assertEquals(query.list().get(0).getValue(), TENANT_ONE_VAR); query = historyService .createHistoricVariableInstanceQuery() .tenantIdIn(TENANT_TWO); assertThat(query.count(), is(1L)); assertEquals(query.list().get(0).getValue(), TENANT_TWO_VAR); }
@Test public void deleteHistoricVariableInstanceWithAuthenticatedTenant() { testRule.deployForTenant(TENANT_ONE, BPMN_ONETASK_PROCESS); String processInstanceId = startProcessInstance(null); runtimeService.setVariable(processInstanceId, "myVariable", "testValue"); HistoricVariableInstanceQuery variableQuery = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId); assertThat(variableQuery.count(), is(1L)); String variableInstanceId = variableQuery.singleResult().getId(); identityService.setAuthentication("user", null, Arrays.asList(TENANT_ONE)); historyService.deleteHistoricVariableInstance(variableInstanceId); assertThat(variableQuery.count(), is(0L)); cleanUpAfterVariableInstanceTest(processInstanceId); }
@Test public void testQueryCountForPost() { given() .contentType(POST_JSON_CONTENT_TYPE) .body(EMPTY_JSON_OBJECT) .expect() .body("count", equalTo(1)) .when() .post(HISTORIC_VARIABLE_INSTANCE_COUNT_RESOURCE_URL); verify(mockedQuery).count(); }
@Deployment(resources={ "org/camunda/bpm/engine/test/history/HistoricVariableInstanceTest.testCallSubProcessSettingVariableOnStart.bpmn20.xml", "org/camunda/bpm/engine/test/history/subProcessSetVariableOnStart.bpmn20.xml" }) public void testCallSubProcessSettingVariableOnStart() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callSubProcess"); assertProcessEnded(processInstance.getId()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().count()); assertEquals(1, historyService.createHistoricVariableInstanceQuery().variableValueEquals("aVariable", "aValue").count()); }
@Deployment(resources={ "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testHistoricProcessVariableOnDeletion() { HashMap<String, Object> variables = new HashMap<String, Object>(); variables.put("testVar", "Hallo Christian"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables); runtimeService.deleteProcessInstance(processInstance.getId(), "deleted"); assertProcessEnded(processInstance.getId()); // check that process variable is set even if the process is canceled and not ended normally assertEquals(1, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableValueEquals("testVar", "Hallo Christian").count()); }
protected void verifyVariablesDeleted() { disableAuthorization(); assertEquals(0L, historyService.createHistoricVariableInstanceQuery().count()); assertEquals(0L, historyService.createHistoricDetailQuery().count()); enableAuthorization(); }
protected void verifyVariablesCreated() { disableAuthorization(); assertEquals(1L, historyService.createHistoricVariableInstanceQuery().count()); assertEquals(1L, historyService.createHistoricDetailQuery().count()); enableAuthorization(); }
@Deployment public void testSetVariableOnServiceTaskInsideSubProcess() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("process"); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertEquals(1, query.count()); HistoricVariableInstance variable = query.singleResult(); // the variable is in the process instance scope assertEquals(pi.getId(), variable.getActivityInstanceId()); assertProcessEnded(pi.getId()); }
@Deployment public void testSetVariableOnServiceTaskInsideParallelBranch() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("process"); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertEquals(1, query.count()); HistoricVariableInstance variable = query.singleResult(); // the variable is in the process instance scope assertEquals(pi.getId(), variable.getActivityInstanceId()); assertProcessEnded(pi.getId()); }