MetadataMapperService { @VisibleForTesting Optional<WorkflowDef> lookupWorkflowDefinition(String workflowName, int workflowVersion) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowName), "Workflow name must be specified when searching for a definition"); return metadataDAO.getWorkflowDef(workflowName, workflowVersion); } @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 testLookupWorkflowDefinition() { try { String workflowName = "test"; when(metadataDAO.getWorkflowDef(workflowName, 0)).thenReturn(Optional.of(new WorkflowDef())); Optional<WorkflowDef> optionalWorkflowDef = metadataMapperService.lookupWorkflowDefinition(workflowName, 0); assertTrue(optionalWorkflowDef.isPresent()); metadataMapperService.lookupWorkflowDefinition(null, 0); } catch (ConstraintViolationException ex) { Assert.assertEquals(1, ex.getConstraintViolations().size()); Set<String> messages = getConstraintViolationMessages(ex.getConstraintViolations()); assertTrue(messages.contains("WorkflowIds list cannot be null.")); } }