BarBuilderJob implements Job { public void execute(JobExecutionContext jec) throws JobExecutionException { IBarBuilder builder = (IBarBuilder) jec.getJobDetail().getJobDataMap().get(RealtimeBarUtil.BAR_BUILDER_DATA); if( builder != null ) { builder.buildBarAndFireEvents(); } }  void execute(JobExecutionContext jec);  }
@Test public void testExecute() throws Exception { final JobExecutionContext mockContext = mockery.mock( JobExecutionContext.class); final JobDetail mockJobDetail = mockery.mock( JobDetail.class ); final JobDataMap dataMap = new JobDataMap(); final IBarBuilder mockBarBuilder = mockery.mock( IBarBuilder.class ); dataMap.put( RealtimeBarUtil.BAR_BUILDER_DATA, mockBarBuilder ); mockery.checking( new Expectations() {{ one(mockContext).getJobDetail(); will(returnValue(mockJobDetail)); one(mockJobDetail).getJobDataMap(); will(returnValue( dataMap ) ); one(mockBarBuilder).buildBarAndFireEvents(); }} ); new BarBuilderJob().execute(mockContext); mockery.assertIsSatisfied(); }