@Test public void testRunWithEmptyDS() throws Exception{ PowerMockito.mockStatic(ESUtils.class); PowerMockito.when(ESUtils.getEsUrl()).thenReturn(""); PowerMockito.when(ESUtils.publishMetrics(anyMap(),anyString())).thenReturn(Boolean.TRUE); JsonObject input = new JsonObject(); PowerMockito.mockStatic(CommonUtils.class); input.addProperty("ruleName", "test"); input.addProperty(PacmanSdkConstants.DATA_SOURCE_KEY, ""); String[] args = {input.toString()}; PowerMockito.mockStatic(RuleExecutor.class); RuleExecutor.main(args); }
public static void main(String[] args) { String executionId = UUID.randomUUID().toString(); logger.debug("received input-->" + args[0]); if(PacEventHandler.isInvocationSourceAnEvent(args[0])) { logger.info("input source detected as event, will process event now."); new PacEventHandler().handleEvent(executionId,args[0]); }else { try { logger.info("input source detected as rule, will process rule now."); new RuleExecutor().run(args, executionId); } catch (Exception e) { logger.error("error while in run method for executionId ->" + executionId, e); } } }
RuleExecutor { public static void main(String[] args) { String executionId = UUID.randomUUID().toString(); logger.debug("received input-->" + args[0]); if(PacEventHandler.isInvocationSourceAnEvent(args[0])) { logger.info("input source detected as event, will process event now."); new PacEventHandler().handleEvent(executionId,args[0]); }else { try { logger.info("input source detected as rule, will process rule now."); new RuleExecutor().run(args, executionId); } catch (Exception e) { logger.error("error while in run method for executionId ->" + executionId, e); } } } }
RuleExecutor { public static void main(String[] args) { String executionId = UUID.randomUUID().toString(); logger.debug("received input-->" + args[0]); if(PacEventHandler.isInvocationSourceAnEvent(args[0])) { logger.info("input source detected as event, will process event now."); new PacEventHandler().handleEvent(executionId,args[0]); }else { try { logger.info("input source detected as rule, will process rule now."); new RuleExecutor().run(args, executionId); } catch (Exception e) { logger.error("error while in run method for executionId ->" + executionId, e); } } }  }
RuleExecutor { public static void main(String[] args) { String executionId = UUID.randomUUID().toString(); logger.debug("received input-->" + args[0]); if(PacEventHandler.isInvocationSourceAnEvent(args[0])) { logger.info("input source detected as event, will process event now."); new PacEventHandler().handleEvent(executionId,args[0]); }else { try { logger.info("input source detected as rule, will process rule now."); new RuleExecutor().run(args, executionId); } catch (Exception e) { logger.error("error while in run method for executionId ->" + executionId, e); } } }  static void main(String[] args); }
RuleExecutor { public static void main(String[] args) { String executionId = UUID.randomUUID().toString(); logger.debug("received input-->" + args[0]); if(PacEventHandler.isInvocationSourceAnEvent(args[0])) { logger.info("input source detected as event, will process event now."); new PacEventHandler().handleEvent(executionId,args[0]); }else { try { logger.info("input source detected as rule, will process rule now."); new RuleExecutor().run(args, executionId); } catch (Exception e) { logger.error("error while in run method for executionId ->" + executionId, e); } } }  static void main(String[] args);  }