@Test public void testUIConfigMissingWorkflows() throws IOException { UIServlet uiServlet = new UIServlet(); String input = "{\n" + " \"groups\": [\n" + " {\n" + " \"name\": \"Group3\",\n" + " \"workflows\": [\n" + " \"Group3-1\",\n" + " \"Group3-2\"\n" + " ]\n" + " }\n" + " ]\n" + "}\n"; Set<WorkflowID> missingWfs = new HashSet<>(); HashSet<WorkflowID> expectedWorkflows = new HashSet<>(); expectedWorkflows.add(new WorkflowID("Group3-2")); WorkflowID wf1 = new WorkflowID("MissingWf1"); WorkflowID wf2 = new WorkflowID("MissingWf2"); WorkflowID wf3 = new WorkflowID("MissingWf3"); missingWfs.add(wf1); missingWfs.add(wf3); missingWfs.add(wf2); expectedWorkflows.addAll(missingWfs); List<WorkflowGroup> groups = uiServlet.getWorkflowGroups(new ByteArrayInputStream(input.getBytes()), expectedWorkflows); Assert.assertEquals(groups.size(), 2); WorkflowGroup group1 = groups.get(0); List<WorkflowID> exp1 = new ArrayList<>(); exp1.add(new WorkflowID("Group3-1")); exp1.add(new WorkflowID("Group3-2")); Assert.assertEquals(group1.getWorkflows(), exp1); Assert.assertEquals(group1.getName(), "Group3"); WorkflowGroup missingGroup = groups.get(1); exp1.add(new WorkflowID("Group3-1")); List<WorkflowID> missingWfsSortedList = new ArrayList<>(); missingWfsSortedList.add(wf1); missingWfsSortedList.add(wf2); missingWfsSortedList.add(wf3); Assert.assertEquals(missingGroup.getWorkflows(), missingWfsSortedList); Assert.assertEquals(missingGroup.getName(), "Unlisted workflows"); }
List<WorkflowGroup> getWorkflowGroups(InputStream configFileIS, Set<WorkflowID> expectedWfs) throws IOException { JsonNode mainNode = Util.JSON_READER.withType(JsonNode.class).readValue(configFileIS); List<WorkflowGroup> configWorkflowGroups = new ArrayList(); Set<WorkflowID> listedWfs = new TreeSet<>(); for(JsonNode workflowGroupNode: mainNode.get(GROUPS_TAG)) { String[] workflowNames = Util.JSON_READER.treeToValue(workflowGroupNode.get(WORKFLOWS_TAG), String[].class); List<WorkflowID> ids = new ArrayList<>(); for (String wfName : workflowNames) { ids.add(new WorkflowID(wfName)); } String name = workflowGroupNode.get(NAME_TAG).textValue(); configWorkflowGroups.add(new WorkflowGroup(name, ids)); listedWfs.addAll(ids); } TreeSet<WorkflowID> diff = new TreeSet<>(Sets.difference(expectedWfs, listedWfs)); if (!diff.isEmpty()) { configWorkflowGroups.add(new WorkflowGroup(UNLISTED_WORKFLOWS_CAPTION, new ArrayList<>(diff))); } return configWorkflowGroups; }
UIServlet extends HttpServlet { List<WorkflowGroup> getWorkflowGroups(InputStream configFileIS, Set<WorkflowID> expectedWfs) throws IOException { JsonNode mainNode = Util.JSON_READER.withType(JsonNode.class).readValue(configFileIS); List<WorkflowGroup> configWorkflowGroups = new ArrayList(); Set<WorkflowID> listedWfs = new TreeSet<>(); for(JsonNode workflowGroupNode: mainNode.get(GROUPS_TAG)) { String[] workflowNames = Util.JSON_READER.treeToValue(workflowGroupNode.get(WORKFLOWS_TAG), String[].class); List<WorkflowID> ids = new ArrayList<>(); for (String wfName : workflowNames) { ids.add(new WorkflowID(wfName)); } String name = workflowGroupNode.get(NAME_TAG).textValue(); configWorkflowGroups.add(new WorkflowGroup(name, ids)); listedWfs.addAll(ids); } TreeSet<WorkflowID> diff = new TreeSet<>(Sets.difference(expectedWfs, listedWfs)); if (!diff.isEmpty()) { configWorkflowGroups.add(new WorkflowGroup(UNLISTED_WORKFLOWS_CAPTION, new ArrayList<>(diff))); } return configWorkflowGroups; } }
UIServlet extends HttpServlet { List<WorkflowGroup> getWorkflowGroups(InputStream configFileIS, Set<WorkflowID> expectedWfs) throws IOException { JsonNode mainNode = Util.JSON_READER.withType(JsonNode.class).readValue(configFileIS); List<WorkflowGroup> configWorkflowGroups = new ArrayList(); Set<WorkflowID> listedWfs = new TreeSet<>(); for(JsonNode workflowGroupNode: mainNode.get(GROUPS_TAG)) { String[] workflowNames = Util.JSON_READER.treeToValue(workflowGroupNode.get(WORKFLOWS_TAG), String[].class); List<WorkflowID> ids = new ArrayList<>(); for (String wfName : workflowNames) { ids.add(new WorkflowID(wfName)); } String name = workflowGroupNode.get(NAME_TAG).textValue(); configWorkflowGroups.add(new WorkflowGroup(name, ids)); listedWfs.addAll(ids); } TreeSet<WorkflowID> diff = new TreeSet<>(Sets.difference(expectedWfs, listedWfs)); if (!diff.isEmpty()) { configWorkflowGroups.add(new WorkflowGroup(UNLISTED_WORKFLOWS_CAPTION, new ArrayList<>(diff))); } return configWorkflowGroups; }  }
UIServlet extends HttpServlet { List<WorkflowGroup> getWorkflowGroups(InputStream configFileIS, Set<WorkflowID> expectedWfs) throws IOException { JsonNode mainNode = Util.JSON_READER.withType(JsonNode.class).readValue(configFileIS); List<WorkflowGroup> configWorkflowGroups = new ArrayList(); Set<WorkflowID> listedWfs = new TreeSet<>(); for(JsonNode workflowGroupNode: mainNode.get(GROUPS_TAG)) { String[] workflowNames = Util.JSON_READER.treeToValue(workflowGroupNode.get(WORKFLOWS_TAG), String[].class); List<WorkflowID> ids = new ArrayList<>(); for (String wfName : workflowNames) { ids.add(new WorkflowID(wfName)); } String name = workflowGroupNode.get(NAME_TAG).textValue(); configWorkflowGroups.add(new WorkflowGroup(name, ids)); listedWfs.addAll(ids); } TreeSet<WorkflowID> diff = new TreeSet<>(Sets.difference(expectedWfs, listedWfs)); if (!diff.isEmpty()) { configWorkflowGroups.add(new WorkflowGroup(UNLISTED_WORKFLOWS_CAPTION, new ArrayList<>(diff))); } return configWorkflowGroups; }   }
UIServlet extends HttpServlet { List<WorkflowGroup> getWorkflowGroups(InputStream configFileIS, Set<WorkflowID> expectedWfs) throws IOException { JsonNode mainNode = Util.JSON_READER.withType(JsonNode.class).readValue(configFileIS); List<WorkflowGroup> configWorkflowGroups = new ArrayList(); Set<WorkflowID> listedWfs = new TreeSet<>(); for(JsonNode workflowGroupNode: mainNode.get(GROUPS_TAG)) { String[] workflowNames = Util.JSON_READER.treeToValue(workflowGroupNode.get(WORKFLOWS_TAG), String[].class); List<WorkflowID> ids = new ArrayList<>(); for (String wfName : workflowNames) { ids.add(new WorkflowID(wfName)); } String name = workflowGroupNode.get(NAME_TAG).textValue(); configWorkflowGroups.add(new WorkflowGroup(name, ids)); listedWfs.addAll(ids); } TreeSet<WorkflowID> diff = new TreeSet<>(Sets.difference(expectedWfs, listedWfs)); if (!diff.isEmpty()) { configWorkflowGroups.add(new WorkflowGroup(UNLISTED_WORKFLOWS_CAPTION, new ArrayList<>(diff))); } return configWorkflowGroups; }    }