SchedulerAdapter { public XmlBuilder getJobGroupNamesWithJobsToXml(Scheduler theScheduler, IbisManager ibisManager) { XmlBuilder xbRoot = new XmlBuilder("jobGroups"); try { List<String> jgnames = theScheduler.getJobGroupNames(); for (int i = 0; i < jgnames.size(); i++) { XmlBuilder el = new XmlBuilder("jobGroup"); String jobGroupName = jgnames.get(i); el.addAttribute("name", jobGroupName); XmlBuilder jb = new XmlBuilder("jobs"); Set<JobKey> jobKeys = theScheduler.getJobKeys(GroupMatcher.jobGroupEquals(jobGroupName)); for (JobKey jobKey : jobKeys) { XmlBuilder jn = new XmlBuilder("job"); String jobName = jobKey.getName(); jn.addAttribute("name", jobName); JobDetail jobDetail = theScheduler.getJobDetail(jobKey); XmlBuilder jd = jobDetailToXmlBuilder(jobDetail); jn.addSubElement(jd); List<? extends Trigger> triggers = theScheduler.getTriggersOfJob(jobKey); XmlBuilder tr = getJobTriggers(triggers); jn.addSubElement(tr); JobDataMap jobDataMap = jobDetail.getJobDataMap(); XmlBuilder datamap = jobDataMapToXmlBuilder(jobDataMap); jn.addSubElement(datamap); jb.addSubElement(jn); JobDef jobDef = null; if(ibisManager != null) { for (Configuration configuration : ibisManager.getConfigurations()) { jobDef = configuration.getScheduledJob(jobName); if (jobDef != null) { break; } } } XmlBuilder ms = getJobMessages(jobDef); jn.addSubElement(ms); XmlBuilder jrs= getJobRunStatistics(jobDef); jn.addSubElement(jrs); } el.addSubElement(jb); xbRoot.addSubElement(el); } } catch (SchedulerException se) { log.error(se); } return xbRoot; }  XmlBuilder getJobGroupNamesWithJobsToXml(Scheduler theScheduler, IbisManager ibisManager); XmlBuilder getJobTriggers(List<? extends Trigger> triggers); XmlBuilder getJobMessages(JobDef jobdef); XmlBuilder getJobRunStatistics(JobDef jobdef); XmlBuilder getSchedulerCalendarNamesToXml(Scheduler theScheduler); XmlBuilder getSchedulerMetaDataToXml(Scheduler theScheduler); XmlBuilder jobDataMapToXmlBuilder(JobDataMap jd); XmlBuilder jobDetailToXmlBuilder(JobDetail jobDetail); XmlBuilder triggerToXmlBuilder(Trigger trigger);  }
@Test public void testGetJobGroupNamesWithJobsToXml() throws SchedulerException, ParseException { scheduleDummyTrigger("DummyJob", "DummyGroup A"); scheduleDummyTrigger("DummyJob", "DummyGroup B"); String result = schedulerAdapter.getJobGroupNamesWithJobsToXml(schedulerHelper.getScheduler(), null).toXML(); assertTrue(result.contains("DummyGroup A") && result.contains("DummyGroup B")); }
@Test public void testGetJobGroupNamesWithJobsToXmlWithMocks() throws SchedulerException, ParseException { scheduleDummyTrigger("DummyJob", "DummyGroup A"); scheduleDummyTrigger("DummyJob", "DummyGroup B"); IbisManager ibisManager = mock(IbisManager.class); when(ibisManager.getConfigurations()).thenReturn(new LinkedList<Configuration>()); String result = schedulerAdapter.getJobGroupNamesWithJobsToXml(schedulerHelper.getScheduler(), ibisManager).toXML(); assertTrue(result.contains("DummyGroup A") && result.contains("DummyGroup B")); }