@Test public void testStatement2JSONObject() { final String epl = Help.ExampleRules()[1]; final String name = "rule name"; logger.info("Statement2JSONObject"); EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(); Map<String, Object> def = new HashMap<String, Object>(); def.put("id", String.class); def.put("type", String.class); def.put(Constants.SUBSERVICE_FIELD, String.class); def.put(Constants.SERVICE_FIELD, String.class); ConfigurationOperations cfg = epService.getEPAdministrator().getConfiguration(); cfg.addEventType("iotEvent", def); EPStatement st = epService.getEPAdministrator().createEPL(epl, name); JSONObject result = Utils.Statement2JSONObject(st); assertEquals(st.getName(), result.getString("name")); assertEquals(st.getText(), result.getString("text")); assertEquals(st.getState(), result.get("state")); assertEquals(st.getName(), result.getString("name")); assertEquals(st.getTimeLastStateChange(), result.getLong("timeLastStateChange")); }
public static JSONObject Statement2JSONObject(EPStatement st) { if (st == null) { return null; } JSONObject jo = new JSONObject() .put("name", st.getName()) .put("text", st.getText()) .put("state", st.getState()) .put("timeLastStateChange", st.getTimeLastStateChange()); return jo; }
Utils { public static JSONObject Statement2JSONObject(EPStatement st) { if (st == null) { return null; } JSONObject jo = new JSONObject() .put("name", st.getName()) .put("text", st.getText()) .put("state", st.getState()) .put("timeLastStateChange", st.getTimeLastStateChange()); return jo; } }
Utils { public static JSONObject Statement2JSONObject(EPStatement st) { if (st == null) { return null; } JSONObject jo = new JSONObject() .put("name", st.getName()) .put("text", st.getText()) .put("state", st.getState()) .put("timeLastStateChange", st.getTimeLastStateChange()); return jo; }  }
Utils { public static JSONObject Statement2JSONObject(EPStatement st) { if (st == null) { return null; } JSONObject jo = new JSONObject() .put("name", st.getName()) .put("text", st.getText()) .put("state", st.getState()) .put("timeLastStateChange", st.getTimeLastStateChange()); return jo; }  static synchronized EPServiceProvider initEPService(ServletContext sc); static synchronized void destroyEPService(ServletContext sc); static Map<String, Object> JSONObject2Map(JSONObject jo); static JSONObject Event2JSONObject(EventBean event); static JSONObject Statement2JSONObject(EPStatement st); static boolean DoHTTPPost(String urlStr, String content); static void putCorrelatorAndTrans(HttpServletRequest req); static String getBodyAsString(HttpServletRequest request); static void setTimerRuleHeaders(JSONObject rule); static Boolean isValidURL(String url); }
Utils { public static JSONObject Statement2JSONObject(EPStatement st) { if (st == null) { return null; } JSONObject jo = new JSONObject() .put("name", st.getName()) .put("text", st.getText()) .put("state", st.getState()) .put("timeLastStateChange", st.getTimeLastStateChange()); return jo; }  static synchronized EPServiceProvider initEPService(ServletContext sc); static synchronized void destroyEPService(ServletContext sc); static Map<String, Object> JSONObject2Map(JSONObject jo); static JSONObject Event2JSONObject(EventBean event); static JSONObject Statement2JSONObject(EPStatement st); static boolean DoHTTPPost(String urlStr, String content); static void putCorrelatorAndTrans(HttpServletRequest req); static String getBodyAsString(HttpServletRequest request); static void setTimerRuleHeaders(JSONObject rule); static Boolean isValidURL(String url);  }