@BeforeMethod(groups = "unit") public void init() { support = new EventSupportImpl(); eventDispatcher = EasyMock.createMock(EventDispatcher.class); messageSource = EasyMock.createMock(MessageSource.class); collection.add(eventDispatcher); collection.add(messageSource); support.setEventDispatcher(eventDispatcher); support.setMessageSource(messageSource); event = null; eventDispatcher.fireEvent( EasyMockUtils.record( new EasyMockUtils.Recorder<EventBase>() { public void record(final EventBase object) { event = object; } })); EasyMock.expect(messageSource.getMessage("code", null)).andStubReturn("message"); collection.replay(); final User user = new User(); user.setCagridId(userId); template = new EventBaseImpl(); template.setJobId(jobId); template.setUserId(userId); template.setJobName(jobName); template.setWorkflowId(workflowId); }
@Test(groups = "unit", timeOut = 1000) public void testGridStatus() { final Status status = new Status(); support.gridStatus(template, status); final GridStatusEvent statusEvent = (GridStatusEvent) this.event; assert statusEvent.getStatus() == status; }
@Test(groups = "unit", timeOut = 1000) public void testWorkflow() { final WorkflowEventImpl event = new WorkflowEventImpl(template); support.workflowUpdate(event, "code", null); final WorkflowEvent workflowEvent = (WorkflowEvent) this.event; assert workflowEvent.getStep().equals("message"); }
@Test(groups = "unit", timeOut = 1000) public void objectAdded() { final String destinationId = UUID.randomUUID().toString(); final String objectId = UUID.randomUUID().toString(); support.objectAdded(template, objectId, destinationId); final ObjectAddedEvent addedEvent = (ObjectAddedEvent) this.event; assert addedEvent.getDestinationId().equals(destinationId); assert addedEvent.getObjectId().equals(objectId); }