WorkflowDefinitionResultRowSplitter implements ResultRowSplitter { @Override public List<ResultRowSplitterEntry> split(List<ResultRow> resultRows) { List<ResultRowSplitterEntry> resultRowSplitterEntries = new ArrayList<>(); List<ResultRow> workflowDefinitionPublishedResultRows = new ArrayList<>(); List<ResultRow> workflowDefinitionNotPublishedResultRows = new ArrayList<>(); for (ResultRow resultRow : resultRows) { WorkflowDefinition workflowDefinition = (WorkflowDefinition)resultRow.getObject(); if (workflowDefinition.isActive()) { workflowDefinitionPublishedResultRows.add(resultRow); } else { workflowDefinitionNotPublishedResultRows.add(resultRow); } } if (!workflowDefinitionPublishedResultRows.isEmpty()) { resultRowSplitterEntries.add( new ResultRowSplitterEntry( "published", workflowDefinitionPublishedResultRows)); } if (!workflowDefinitionNotPublishedResultRows.isEmpty()) { resultRowSplitterEntries.add( new ResultRowSplitterEntry( "not-published", workflowDefinitionNotPublishedResultRows)); } return resultRowSplitterEntries; }  @Override List<ResultRowSplitterEntry> split(List<ResultRow> resultRows);  }
@Test public void testSplitDefinitions() { addWorkflowDefinition(true); addWorkflowDefinition(false); List<ResultRowSplitterEntry> resultRowSplitterEntryList = _resultRowSplitter.split(_resultRows); Assert.assertEquals( resultRowSplitterEntryList.toString(), 2, resultRowSplitterEntryList.size()); ResultRowSplitterEntry resultRowSplitterEntry = resultRowSplitterEntryList.get(0); Assert.assertEquals("published", resultRowSplitterEntry.getTitle()); List<ResultRow> resultRows = resultRowSplitterEntry.getResultRows(); Assert.assertEquals(resultRows.toString(), 1, resultRows.size()); resultRowSplitterEntry = resultRowSplitterEntryList.get(1); Assert.assertEquals("not-published", resultRowSplitterEntry.getTitle()); resultRows = resultRowSplitterEntry.getResultRows(); Assert.assertEquals(resultRows.toString(), 1, resultRows.size()); }
@Test public void testSplitNoDefinitions() { List<ResultRowSplitterEntry> resultRowSplitterEntryList = _resultRowSplitter.split(_resultRows); Assert.assertEquals( resultRowSplitterEntryList.toString(), 0, resultRowSplitterEntryList.size()); }
@Test public void testSplitNotPublishedDefinitions() { addWorkflowDefinition(false); List<ResultRowSplitterEntry> resultRowSplitterEntryList = _resultRowSplitter.split(_resultRows); Assert.assertEquals( resultRowSplitterEntryList.toString(), 1, resultRowSplitterEntryList.size()); ResultRowSplitterEntry resultRowSplitterEntry = resultRowSplitterEntryList.get(0); Assert.assertEquals("not-published", resultRowSplitterEntry.getTitle()); List<ResultRow> resultRows = resultRowSplitterEntry.getResultRows(); Assert.assertEquals(resultRows.toString(), 1, resultRows.size()); }
@Test public void testSplitPublishedDefinitions() { addWorkflowDefinition(true); List<ResultRowSplitterEntry> resultRowSplitterEntryList = _resultRowSplitter.split(_resultRows); Assert.assertEquals( resultRowSplitterEntryList.toString(), 1, resultRowSplitterEntryList.size()); ResultRowSplitterEntry resultRowSplitterEntry = resultRowSplitterEntryList.get(0); Assert.assertEquals("published", resultRowSplitterEntry.getTitle()); List<ResultRow> resultRows = resultRowSplitterEntry.getResultRows(); Assert.assertEquals(resultRows.toString(), 1, resultRows.size()); }