/** @throws java.lang.Exception */ @Before public void setUp() throws Exception { job = new NotificationEventCreationJob(); job.setConfig(config); job.setEndPoint(END_POINT); job.setIdBuilder(idBuilder); job.setIssuer(issuer); job.setProducer(producer); exception = new RuntimeException("Nuts!"); inOrder = inOrder(config, idBuilder, issuer, producer, context, jobDataMap); when(context.getMergedJobDataMap()).thenReturn(jobDataMap); when(jobDataMap.getString(NotificationEventCreationJob.JOB_DATA_KEY_CONTACT_INSTANCE_ID)) .thenReturn(EVENT_INSTANCE_ID); when(jobDataMap.getLong(NotificationEventCreationJob.JOB_DATA_KEY_EVENT_TIME)).thenReturn(NOW); when(jobDataMap.getString(NotificationEventCreationJob.JOB_DATA_KEY_EVENT_TYPE)) .thenReturn(TYPE); when(jobDataMap.getString(NotificationEventCreationJob.JOB_DATA_KEY_GROUND_STATION_NAME)) .thenReturn(GS); when(jobDataMap.getString(NotificationEventCreationJob.JOB_DATA_KEY_SATELLITE_NAME)) .thenReturn(SAT); when(config.getEventNameSpace()).thenReturn(NAME_SPACE); when(idBuilder.buildID(NAME_SPACE, TYPE)).thenReturn(EVENT_ID); when(issuer.getID()).thenReturn(ISSUER); }
@Override protected void doConfigure() { String name = entity.getName(); TrackingDriverConfiguration config = entity.getConfiguration(); CamelContext context = entity.getContext(); EntityCache<GroundStation> groundStationCache = EntityCache.forType(dao, GroundStation.class); EntityCache<Satellite> satelliteCache = EntityCache.forType(dao, Satellite.class); EntityCache<TleOrbitalParameters> tleCache = EntityCache.forType(dao, TleOrbitalParameters.class); ProducerTemplate producer = context.createProducerTemplate(); Scheduler scheduler; try { scheduler = StdSchedulerFactory.getDefaultScheduler(); JobFactory factory = new TrackComponentJobFactory( entity, dao, producer, TRACK_COMMAND_INJECTOR, satelliteCache, tleCache, idBuilder, config); scheduler.setJobFactory(factory); scheduler.start(); } catch (Exception e) { throw new RuntimeException("Failed to start Quartz sceduler", e); } SchedulingSupport support = new SchedulingSupport(); ArchivePoller archivePoller = new ArchivePoller(config, dao); TrackCommandScheduler trackCommandScheduler = new TrackCommandScheduler(config, scheduler, support); TrackCommandUnscheduler contactUnscheduler = new TrackCommandUnscheduler(scheduler, support); EventAnalyzer analyzer = new EventAnalyzer(scheduler, support); ScheduleDeltaCheck deltaCheck = new ScheduleDeltaCheck(config, support); NotificationEventScheduler notificationScheduler = new NotificationEventScheduler(scheduler, support, groundStationCache, satelliteCache); // @formatter:off from(TRACK_COMMAND_INJECTOR) .choice() .when(body().isInstanceOf(Track.class)) .bean(notificationScheduler) .end() .bean(publisher); from("direct:scheduleContact") .filter(deltaCheck) .bean(trackCommandScheduler) .to("log:scheduledContact-log?level=DEBUG"); from("direct:rescheduleContact") .choice() .when(deltaCheck) .bean(contactUnscheduler) .to("log:RescheduleContact-log?level=DEBUG") .to("direct:scheduleContact") .otherwise() .to("log:ReschedulingImpossible?level=WARN"); from("seda:eventHandler") .to("log:handler-log?level=DEBUG") .process(analyzer) .choice() .when( header(EventAnalyzer.HEADER_KEY_EVENT_TYPE) .isEqualTo(EventAnalyzer.HEADER_VALUE_NEW_EVENT)) .to("direct:scheduleContact") .when( header(EventAnalyzer.HEADER_KEY_EVENT_TYPE) .isEqualTo(EventAnalyzer.HEADER_VALUE_UPDATED_EVENT)) .to("direct:rescheduleContact") .otherwise() .log("LocationContacEvent already scheduled"); from(addTimer(name, config.getArchivePollInterval())) .bean(archivePoller) .split(body()) .to("seda:eventHandler"); // @formatter:on }