@Test public void testRunMultiThreadWithRulePassing() throws Exception{ PowerMockito.mockStatic(ESUtils.class); PowerMockito.when(ESUtils.getEsUrl()).thenReturn(""); PowerMockito.when(ESUtils.publishMetrics(anyMap(),anyString())).thenReturn(Boolean.TRUE); final Class<?> ruleClass = TestPacRule.class; List<Map<String, String>> resources = new ArrayList<>(); Map<String, String> resource = new HashMap<>(); resource.put(PacmanSdkConstants.DOC_ID, "testId"); resource.put(PacmanSdkConstants.RESOURCE_ID,"testResId"); resources.add(resource); PowerMockito.when(ESUtils.getResourcesFromEs(anyString(), anyString(), anyMap(), anyList())).thenReturn(resources); JsonObject input = new JsonObject(); input.addProperty("ruleName", "test"); input.addProperty(PacmanSdkConstants.RUN_ON_MULTI_THREAD_KEY, "true"); input.addProperty(PacmanSdkConstants.RULE_KEY, TEST_KEY); input.addProperty(PacmanSdkConstants.DATA_SOURCE_KEY, "aws"); String[] args = {input.toString()}; 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);  }