@Test public void testDelete() { logger.info("delete"); String ruleName = "ccc"; String epl = Help.ExampleRules()[0]; EPStatement st = epService.getEPAdministrator().createEPL(epl, ruleName); assertNotNull(st); Result result = RulesManager.delete(epService, ruleName); assertEquals(200, result.getStatusCode()); EPStatement st2 = epService.getEPAdministrator().getStatement(ruleName); assertEquals(null, st2); }
public static synchronized Result delete(EPServiceProvider epService, String ruleName) { try { ruleName = ruleName == null ? "" : ruleName; logger.debug(String.format("delete rule: %s" ,ruleName)); EPAdministrator epa = epService.getEPAdministrator(); if (ruleName.length() != 0) { EPStatement st = epa.getStatement(ruleName); if (st != null) { logger.debug(String.format("deleted statement: %s", ruleName)); st.destroy(); return new Result(HttpServletResponse.SC_OK, Utils.Statement2JSONObject(st).toString()); } else { logger.debug(String.format("asked for deleting inexistent statement: %s",ruleName)); return new Result(HttpServletResponse.SC_OK, "{}"); } } else { return new Result(HttpServletResponse.SC_NOT_FOUND, "{\"error\":\"not rule specified for deleting\"}"); } } catch (EPException epe) { logger.error(String.format("deleting statement %s", epe)); return new Result(HttpServletResponse.SC_BAD_REQUEST, String.format("{\"error\":%s}%n", JSONObject.valueToString(epe.getMessage()))); } }
RulesManager { public static synchronized Result delete(EPServiceProvider epService, String ruleName) { try { ruleName = ruleName == null ? "" : ruleName; logger.debug(String.format("delete rule: %s" ,ruleName)); EPAdministrator epa = epService.getEPAdministrator(); if (ruleName.length() != 0) { EPStatement st = epa.getStatement(ruleName); if (st != null) { logger.debug(String.format("deleted statement: %s", ruleName)); st.destroy(); return new Result(HttpServletResponse.SC_OK, Utils.Statement2JSONObject(st).toString()); } else { logger.debug(String.format("asked for deleting inexistent statement: %s",ruleName)); return new Result(HttpServletResponse.SC_OK, "{}"); } } else { return new Result(HttpServletResponse.SC_NOT_FOUND, "{\"error\":\"not rule specified for deleting\"}"); } } catch (EPException epe) { logger.error(String.format("deleting statement %s", epe)); return new Result(HttpServletResponse.SC_BAD_REQUEST, String.format("{\"error\":%s}%n", JSONObject.valueToString(epe.getMessage()))); } } }
RulesManager { public static synchronized Result delete(EPServiceProvider epService, String ruleName) { try { ruleName = ruleName == null ? "" : ruleName; logger.debug(String.format("delete rule: %s" ,ruleName)); EPAdministrator epa = epService.getEPAdministrator(); if (ruleName.length() != 0) { EPStatement st = epa.getStatement(ruleName); if (st != null) { logger.debug(String.format("deleted statement: %s", ruleName)); st.destroy(); return new Result(HttpServletResponse.SC_OK, Utils.Statement2JSONObject(st).toString()); } else { logger.debug(String.format("asked for deleting inexistent statement: %s",ruleName)); return new Result(HttpServletResponse.SC_OK, "{}"); } } else { return new Result(HttpServletResponse.SC_NOT_FOUND, "{\"error\":\"not rule specified for deleting\"}"); } } catch (EPException epe) { logger.error(String.format("deleting statement %s", epe)); return new Result(HttpServletResponse.SC_BAD_REQUEST, String.format("{\"error\":%s}%n", JSONObject.valueToString(epe.getMessage()))); } }  }
RulesManager { public static synchronized Result delete(EPServiceProvider epService, String ruleName) { try { ruleName = ruleName == null ? "" : ruleName; logger.debug(String.format("delete rule: %s" ,ruleName)); EPAdministrator epa = epService.getEPAdministrator(); if (ruleName.length() != 0) { EPStatement st = epa.getStatement(ruleName); if (st != null) { logger.debug(String.format("deleted statement: %s", ruleName)); st.destroy(); return new Result(HttpServletResponse.SC_OK, Utils.Statement2JSONObject(st).toString()); } else { logger.debug(String.format("asked for deleting inexistent statement: %s",ruleName)); return new Result(HttpServletResponse.SC_OK, "{}"); } } else { return new Result(HttpServletResponse.SC_NOT_FOUND, "{\"error\":\"not rule specified for deleting\"}"); } } catch (EPException epe) { logger.error(String.format("deleting statement %s", epe)); return new Result(HttpServletResponse.SC_BAD_REQUEST, String.format("{\"error\":%s}%n", JSONObject.valueToString(epe.getMessage()))); } }  static synchronized Result get(EPServiceProvider epService, String ruleName); static synchronized Result make(EPServiceProvider epService, String text); static synchronized Result updateAll(EPServiceProvider epService, String text); static synchronized Result delete(EPServiceProvider epService, String ruleName); }
RulesManager { public static synchronized Result delete(EPServiceProvider epService, String ruleName) { try { ruleName = ruleName == null ? "" : ruleName; logger.debug(String.format("delete rule: %s" ,ruleName)); EPAdministrator epa = epService.getEPAdministrator(); if (ruleName.length() != 0) { EPStatement st = epa.getStatement(ruleName); if (st != null) { logger.debug(String.format("deleted statement: %s", ruleName)); st.destroy(); return new Result(HttpServletResponse.SC_OK, Utils.Statement2JSONObject(st).toString()); } else { logger.debug(String.format("asked for deleting inexistent statement: %s",ruleName)); return new Result(HttpServletResponse.SC_OK, "{}"); } } else { return new Result(HttpServletResponse.SC_NOT_FOUND, "{\"error\":\"not rule specified for deleting\"}"); } } catch (EPException epe) { logger.error(String.format("deleting statement %s", epe)); return new Result(HttpServletResponse.SC_BAD_REQUEST, String.format("{\"error\":%s}%n", JSONObject.valueToString(epe.getMessage()))); } }  static synchronized Result get(EPServiceProvider epService, String ruleName); static synchronized Result make(EPServiceProvider epService, String text); static synchronized Result updateAll(EPServiceProvider epService, String text); static synchronized Result delete(EPServiceProvider epService, String ruleName);  }