@Before public void setUp() { registrationApprovedAutomatedWorkflowTemplateJob = new RegistrationApprovedAutomatedWorkflowTemplateJob(); registrationApprovedAutomatedWorkflowTemplateJob.setModelService( modelService = mock(ModelService.class)); registrationApprovedAutomatedWorkflowTemplateJob.setWorkflowAttachmentService( workflowAttachmentService = mock(WorkflowAttachmentService.class)); registrationApprovedAutomatedWorkflowTemplateJob.setUserService( userService = mock(UserService.class)); customer = createCustomerModel(); b2BCustomer = createB2BCustomerModel(customer); b2BRegistrationModel = createB2BRegistrationModel(); b2bUnitModel = createB2BUnit(); customers = Arrays.asList(customer); workflowActionModel = new WorkflowActionModel(); workflowDecisionModel = new WorkflowDecisionModel(); workflowDecisionModel.setName(DECISION_NAME, Locale.getDefault()); workflowActionModel.setDecisions(Arrays.asList(workflowDecisionModel)); }
/** Checks if actions of test workflow has correct status. */ @Test public void testWorkflowCreate() { // test action 1 final WorkflowActionModel action1 = getAction(ACTIONCODES.ACTION1.name()); assertEquals("Expected number of decisions of action 1", 2, action1.getDecisions().size()); assertFalse("Is the action 1 disabled?", workflowActionService.isDisabled(action1)); assertTrue("Is the action 1 active?", workflowActionService.isActive(action1)); for (final WorkflowDecisionModel decision : action1.getDecisions()) { assertEquals( "Expected number of actions of decisions of action 1", 1, decision.getToActions().size()); } // test action 2 final WorkflowActionModel action2 = getAction(ACTIONCODES.ACTION2.name()); assertEquals("Expected number of decisions of action 2", 2, action2.getDecisions().size()); assertFalse("Is the action 2 disabled?", workflowActionService.isDisabled(action2)); assertTrue("Is the action 2 active?", workflowActionService.isActive(action2)); for (final WorkflowDecisionModel decision : action2.getDecisions()) { if (decision.getCode().equals(DECISIONCODES.DECISION4.name())) { assertEquals( "Expected number of actions of decisions of action 2", 2, decision.getToActions().size()); } else { assertEquals( "Expected number of actions of decisions of action 2", 1, decision.getToActions().size()); } } // test action 3 final WorkflowActionModel action3 = getAction(ACTIONCODES.ACTION3.name()); assertEquals("Expected number of decisions of action 3", 1, action3.getDecisions().size()); assertFalse("Is the action 3 disabled?", workflowActionService.isDisabled(action3)); assertFalse("Is the action 3 active?", workflowActionService.isActive(action3)); for (final WorkflowDecisionModel decision : action3.getDecisions()) { assertEquals( "Expected number of actions of decisions of action 3", 1, decision.getToActions().size()); } // test action 4 final WorkflowActionModel action4 = getAction(ACTIONCODES.ACTION4.name()); assertEquals("Expected number of decisions of action 4", 1, action4.getDecisions().size()); assertFalse("Is the action 4 disabled?", workflowActionService.isDisabled(action4)); assertFalse("Is the action 4 active?", workflowActionService.isActive(action4)); for (final WorkflowDecisionModel decision : action4.getDecisions()) { assertEquals( "Expected number of actions of decisions of action 4", 1, decision.getToActions().size()); } // test action 5 final WorkflowActionModel action5 = getAction(ACTIONCODES.ACTION5.name()); assertEquals("Expected number of decisions of action 5", 1, action5.getDecisions().size()); assertFalse("Is the action 5 disabled?", workflowActionService.isDisabled(action5)); assertFalse("Is the action 5 active?", workflowActionService.isActive(action5)); for (final WorkflowDecisionModel decision : action5.getDecisions()) { assertEquals( "Expected number of actions of decisions of action 5", 1, decision.getToActions().size()); } // test action 6 final WorkflowActionModel action6 = getAction(ACTIONCODES.ACTION6.name()); assertEquals("Expected number of decisions of action 6", 0, action5.getPredecessors().size()); assertFalse("Is the action 6 disabled?", workflowActionService.isDisabled(action6)); assertFalse("Is the action 6 active?", workflowActionService.isActive(action6)); }