@Test public void testUIConfig() throws IOException { UIServlet uiServlet = new UIServlet(); String input = "{\n" + " \"groups\": [\n" + " {\n" + " \"name\": \"Group1\",\n" + " \"workflows\": [\n" + " \"Group1-1\",\n" + " \"Group1-2\",\n" + " \"Group1-3\"\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"Group2\",\n" + " \"workflows\": [\n" + " \"Group2-1\"\n" + " ]\n" + " },\n" + " {\n" + " \"name\": \"Group3\",\n" + " \"workflows\": [\n" + " ]\n" + " }\n" + " ]\n" + "}\n"; List<WorkflowGroup> groups = uiServlet.getWorkflowGroups(new ByteArrayInputStream(input.getBytes()), new HashSet<>()); Assert.assertEquals(groups.size(), 3); WorkflowGroup group1 = groups.get(0); List<WorkflowID> exp1 = new ArrayList<>(); exp1.add(new WorkflowID("Group1-1")); exp1.add(new WorkflowID("Group1-2")); exp1.add(new WorkflowID("Group1-3")); Assert.assertEquals(group1.getWorkflows(), exp1); Assert.assertEquals(group1.getName(), "Group1"); WorkflowGroup group2 = groups.get(1); List<WorkflowID> exp2 = new ArrayList<>(); exp2.add(new WorkflowID("Group2-1")); Assert.assertEquals(group2.getWorkflows(), exp2); Assert.assertEquals(group2.getName(), "Group2"); WorkflowGroup group3 = groups.get(2); List<WorkflowID> exp3 = new ArrayList<>(); Assert.assertEquals(group3.getWorkflows(), exp3); Assert.assertEquals(group3.getName(), "Group3"); }
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; }    }