Пример #1
0
 @Test(groups = "unit", timeOut = 1000)
 public void testResponseToActivityStart() {
   final MockEventDispatcherImpl dispatcher = new MockEventDispatcherImpl();
   final MessageSource messageSource = EasyMock.createMock(MessageSource.class);
   WorkflowListenerImpl workflowListener = new WorkflowListenerImpl(dispatcher, messageSource);
   final ActivityDescriptionWithMessage activity = new ActivityDescriptionWithMessage();
   activity.setJobDescription(jobDescription);
   EasyMock.expect(messageSource.getMessage("test_code")).andReturn("Test!");
   EasyMock.replay(messageSource);
   workflowListener.activityStarted(context, activity);
   EasyMock.verify(messageSource);
   assert ((WorkflowEvent) dispatcher.events.get(0)).getStep().equals("Test!");
 }
Пример #2
0
  @Test(groups = "unit", timeOut = 1000)
  public void testResponseToCompleteAndFailure() {
    final MockEventDispatcherImpl dispatcher = new MockEventDispatcherImpl();
    final MessageSource messageSource = EasyMock.createMock(MessageSource.class);
    WorkflowListenerImpl workflowListener = new WorkflowListenerImpl(dispatcher, messageSource);
    workflowListener.jobComplete(context, jobDescription, true);
    final CompletionEvent completeEvent = (CompletionEvent) dispatcher.events.get(0);
    verifyEvent(completeEvent);
    workflowListener.jobComplete(context, jobDescription, false);
    final FailureEvent failureEvent = (FailureEvent) dispatcher.events.get(1);
    verifyEvent(failureEvent);

    workflowListener.workflowComplete(context, true);
    workflowListener.workflowComplete(context, false);
  }
Пример #3
0
 @Test(groups = "unit", timeOut = 1000)
 public void testResponseToActivityStartNoMessage() {
   final MockEventDispatcherImpl dispatcher = new MockEventDispatcherImpl();
   final MessageSource messageSource = EasyMock.createMock(MessageSource.class);
   WorkflowListenerImpl workflowListener = new WorkflowListenerImpl(dispatcher, messageSource);
   // Both of these activities should not produce events, because there is no job description and
   // because
   // they are not annotated with message code (respectivly)
   final ActivityDescriptionWithMessage activityWithoutJobDescription =
       new ActivityDescriptionWithMessage();
   final ActivityDescriptionWithoutMessage activityWithoutMessage =
       new ActivityDescriptionWithoutMessage();
   activityWithoutMessage.setJobDescription(jobDescription);
   EasyMock.replay(messageSource);
   workflowListener.activityStarted(context, activityWithoutJobDescription);
   workflowListener.activityStarted(context, activityWithoutMessage);
   EasyMock.verify(messageSource);
   assert dispatcher.events.isEmpty();
 }