JobCallbackUtil { public static boolean isThereJobCallbackProperty(final Props props, final JobCallbackStatusEnum status) { if (props == null || status == null) { throw new NullPointerException("One of the argument is null"); } final String jobCallBackUrl = firstJobcallbackPropertyMap.get(status); return props.containsKey(jobCallBackUrl); }  static boolean isThereJobCallbackProperty(final Props props,
      final JobCallbackStatusEnum status); static boolean isThereJobCallbackProperty(final Props props,
      final JobCallbackStatusEnum... jobStatuses); static List<HttpRequestBase> parseJobCallbackProperties(final Props props,
      final JobCallbackStatusEnum status, final Map<String, String> contextInfo,
      final int maxNumCallback); static List<HttpRequestBase> parseJobCallbackProperties(final Props props,
      final JobCallbackStatusEnum status, final Map<String, String> contextInfo,
      final int maxNumCallback, final Logger privateLogger); static Header[] parseHttpHeaders(final String headers); static Map<String, String> buildJobContextInfoMap(final Event event,
      final String server); static String replaceTokens(final String value,
      final Map<String, String> contextInfo, final boolean withEncoding);  }
@Test public void noCallbackPropertiesTest() { final Props props = new Props(); props.put("abc", "def"); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED)); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.COMPLETED)); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.FAILURE)); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.SUCCESS)); }
@Test public void hasCallbackPropertiesTest() { final Props props = new Props(); for (final JobCallbackStatusEnum jobStatus : JobCallbackStatusEnum.values()) { props.put( "job.notification." + jobStatus.name().toLowerCase() + ".1.url", "def"); } System.out.println(props); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED)); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.COMPLETED)); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.FAILURE)); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.SUCCESS)); }
@Test public void multipleStatusWithNoJobCallbackTest() { final Props props = new Props(); props.put("abc", "def"); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED, JobCallbackStatusEnum.COMPLETED, JobCallbackStatusEnum.FAILURE, JobCallbackStatusEnum.SUCCESS)); }
@Test public void multipleStatusesWithJobCallbackTest() { Props props = new Props(); props.put("job.notification." + JobCallbackStatusEnum.STARTED.name().toLowerCase() + ".1.url", "def"); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED, JobCallbackStatusEnum.COMPLETED, JobCallbackStatusEnum.FAILURE, JobCallbackStatusEnum.SUCCESS)); props = new Props(); props.put("job.notification." + JobCallbackStatusEnum.COMPLETED.name().toLowerCase() + ".1.url", "def"); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED, JobCallbackStatusEnum.COMPLETED, JobCallbackStatusEnum.FAILURE, JobCallbackStatusEnum.SUCCESS)); props = new Props(); props.put("job.notification." + JobCallbackStatusEnum.FAILURE.name().toLowerCase() + ".1.url", "def"); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED, JobCallbackStatusEnum.COMPLETED, JobCallbackStatusEnum.FAILURE, JobCallbackStatusEnum.SUCCESS)); props = new Props(); props.put("job.notification." + JobCallbackStatusEnum.SUCCESS.name().toLowerCase() + ".1.url", "def"); Assert.assertTrue(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED, JobCallbackStatusEnum.COMPLETED, JobCallbackStatusEnum.FAILURE, JobCallbackStatusEnum.SUCCESS)); }
@Test public void hasCallbackPropertiesWithGapTest() { final Props props = new Props(); for (final JobCallbackStatusEnum jobStatus : JobCallbackStatusEnum.values()) { props.put( "job.notification." + jobStatus.name().toLowerCase() + ".2.url", "def"); } System.out.println(props); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.STARTED)); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.COMPLETED)); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.FAILURE)); Assert.assertFalse(JobCallbackUtil.isThereJobCallbackProperty(props, JobCallbackStatusEnum.SUCCESS)); }