RemoteProcessVariablesServiceImpl extends AbstractKieServerService implements ProcessVariablesService { @Override public PageResponse<ProcessVariableSummary> getData(QueryFilter filter) { PageResponse<ProcessVariableSummary> response = new PageResponse<ProcessVariableSummary>(); List<ProcessVariableSummary> processVariablesSums = getProcessVariables(filter); response.setStartRowIndex(filter.getOffset()); response.setTotalRowSize(processVariablesSums.size()); response.setTotalRowSizeExact(true); if (!processVariablesSums.isEmpty()) { if (processVariablesSums.size() > (filter.getCount() + filter.getOffset())) { response.setPageRowList(new ArrayList<ProcessVariableSummary>(processVariablesSums.subList(filter.getOffset(), filter.getOffset() + filter.getCount()))); response.setLastPage(false); } else { response.setPageRowList(new ArrayList<ProcessVariableSummary>(processVariablesSums.subList(filter.getOffset(), processVariablesSums.size()))); response.setLastPage(true); } } else { response.setPageRowList(new ArrayList<ProcessVariableSummary>(processVariablesSums)); response.setLastPage(true); } return response; }  @Override PageResponse<ProcessVariableSummary> getData(QueryFilter filter); @Override List<ProcessVariableSummary> getProcessVariables(QueryFilter filter); @Override List<ProcessVariableSummary> getVariableHistory(ProcessInstanceKey processInstance,
                                                           String variableName);  }
@Test public void testGetData() { VariablesDefinition variablesDefinition = new VariablesDefinition(singletonMap(var1, "")); when(processServicesClient.getProcessVariableDefinitions(containerId, processId)).thenReturn(variablesDefinition); VariableInstance variableInstance = VariableInstance.builder() .name(var1) .value(var1_value) .processInstanceId(Long.valueOf(processInstanceId)) .date(new Date()) .build(); when(queryServicesClient.findVariablesCurrentState(any())).thenReturn(singletonList(variableInstance)); final PageResponse<ProcessVariableSummary> response = processVariablesService.getData(queryFilter); assertEquals(1, response.getTotalRowSize()); assertEquals(0, response.getStartRowIndex()); assertTrue(response.isTotalRowSizeExact()); assertTrue(response.isFirstPage()); assertTrue(response.isLastPage()); }
@Test public void testGetDataPaginated() { int totalItems = 12; final HashMap<String, String> variables = new HashMap<>(); IntStream.range(0, totalItems).forEach(i -> variables.put("var_" + i, "")); VariablesDefinition variablesDefinition = new VariablesDefinition(variables); when(processServicesClient.getProcessVariableDefinitions(containerId, processId)).thenReturn(variablesDefinition); final PageResponse<ProcessVariableSummary> response = processVariablesService.getData(queryFilter); assertEquals(totalItems, response.getTotalRowSize()); assertEquals(0, response.getStartRowIndex()); assertTrue(response.isTotalRowSizeExact()); assertTrue(response.isFirstPage()); assertFalse(response.isLastPage()); }