### Question:
WorkflowConfigurationParser { void parseFile(File f, StateDatabaseConnection connection) throws Exception { LOGGER.info("Loading file: " + f); FileReader fileReader = new FileReader(f); String fileName = f.toString(); evaluateReader(fileReader, fileName, connection); } WorkflowConfigurationParser(File defaultsDir, Map<String, String> additionalJsVariables); WorkflowConfigurationParser parseConfiguration(File workflowsDir, StateDatabaseConnection connection); WorkflowConfiguration getWorkflowConfiguration(); void importDefaultsIntoScope(String label, Global scope); void addWorkflow(Workflow wf); static final String WORKFLOW_FILE_EXTENSION; }### Answer:
@Test public void workflowInfoWFNoName() throws Exception { WorkflowConfiguration cfg = parseFile("workflow-info-test"); WorkflowInfo workflowInfo = cfg.findWorkflow(new WorkflowID("workflow-3")).getWorkflowInfo(); Assert.assertEquals(new URL("http: Assert.assertEquals(1, workflowInfo.getContacts().size()); Assert.assertNull(workflowInfo.getContacts().get(0).getName()); Assert.assertEquals(URI.create("john.doe@collective.com"), workflowInfo.getContacts().get(0).getEmail()); }
@Test public void workflowInfoNoEmail() throws Exception { WorkflowConfiguration cfg = parseFile("workflow-info-test"); WorkflowInfo workflowInfo = cfg.findWorkflow(new WorkflowID("workflow-4")).getWorkflowInfo(); Assert.assertEquals(new URL("http: Assert.assertEquals(1, workflowInfo.getContacts().size()); Assert.assertEquals("John Doe", workflowInfo.getContacts().get(0).getName()); Assert.assertNull(workflowInfo.getContacts().get(0).getEmail()); }
@Test public void workflowInfoNoContacts() throws Exception { WorkflowConfiguration cfg = parseFile("workflow-info-test"); WorkflowInfo workflowInfo = cfg.findWorkflow(new WorkflowID("workflow-5")).getWorkflowInfo(); Assert.assertEquals(new URL("http: Assert.assertTrue(workflowInfo.getContacts().isEmpty()); }
@Test public void doesntAllowDuplicateIDs() throws Exception { WorkflowConfiguration cfg = parseFile("duplicate-ids"); Assert.assertEquals(1, cfg.getWorkflows().size()); }
@Test public void propertiesAreCorrectlySet() throws Exception { WorkflowConfiguration cfg = parseFile("properties-test"); Workflow wf1 = cfg.findWorkflow(new WorkflowID("workflow-1")); Assert.assertEquals("workflow-1", wf1.getID().toString()); Assert.assertEquals(55, wf1.getMaxRetryCount()); Assert.assertEquals(Workflow.DEFAULT_START_TIME, wf1.getStartTime()); Assert.assertEquals(Workflow.DEFAULT_WAIT_TIMEOUT_SECONDS, wf1.getWaitTimeoutSeconds()); Workflow wf2 = cfg.findWorkflow(new WorkflowID("workflow-2")); Assert.assertEquals("workflow-2", wf2.getID().toString()); Assert.assertEquals(66, wf2.getMaxRetryCount()); Assert.assertEquals(new ScheduledTime("2014-03-10T12:34:56.789Z"), wf2.getStartTime()); Assert.assertEquals(23, wf2.getWaitTimeoutSeconds()); }
@Test public void workflowInfoWF1() throws Exception { WorkflowConfiguration cfg = parseFile("workflow-info-test"); WorkflowInfo workflowInfo = cfg.findWorkflow(new WorkflowID("workflow-1")).getWorkflowInfo(); Assert.assertNull(workflowInfo.getUrl()); Assert.assertTrue(workflowInfo.getContacts().isEmpty()); }
@Test public void workflowInfoWF2() throws Exception { WorkflowConfiguration cfg = parseFile("workflow-info-test"); WorkflowInfo workflowInfo = cfg.findWorkflow(new WorkflowID("workflow-2")).getWorkflowInfo(); Assert.assertEquals(new URL("http: Assert.assertEquals(1, workflowInfo.getContacts().size()); Assert.assertEquals("John Doe", workflowInfo.getContacts().get(0).getName()); Assert.assertEquals(URI.create("john.doe@collective.com"), workflowInfo.getContacts().get(0).getEmail()); }