MetadataMapperService { @VisibleForTesting Optional<WorkflowDef> lookupLatestWorkflowDefinition(String workflowName) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowName), "Workflow name must be specified when searching for a definition"); return metadataDAO.getLatestWorkflowDef(workflowName); } @Inject  MetadataMapperService(MetadataDAO metadataDAO); WorkflowDef lookupForWorkflowDefinition(String name, Integer version); Workflow populateWorkflowWithDefinitions(Workflow workflow); WorkflowDef populateTaskDefinitions(WorkflowDef workflowDefinition); Task populateTaskWithDefinition(Task task); static final Logger logger; }
@Test(expected = IllegalArgumentException.class) public void testLookupLatestWorkflowDefinition() { String workflowName = "test"; when(metadataDAO.getLatestWorkflowDef(workflowName)).thenReturn(Optional.of(new WorkflowDef())); Optional<WorkflowDef> optionalWorkflowDef = metadataMapperService.lookupLatestWorkflowDefinition(workflowName); assertTrue(optionalWorkflowDef.isPresent()); metadataMapperService.lookupLatestWorkflowDefinition(null); }