Example #1
0
  public void testOnDelete() {
    EPStatement consumerOne =
        epService.getEPAdministrator().createEPL("select irstream * from RevQuote");
    consumerOne.addListener(listenerOne);

    epService
        .getEPAdministrator()
        .createEPL("on SupportBean(intPrimitive=2) as sb delete from RevQuote where string = p2");

    log("a00");
    epService
        .getEPRuntime()
        .sendEvent(new SupportRevisionFull("a", "a00", "a10", "a20", "a30", "a40", "a50"));
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(),
        fields,
        new Object[] {"a", "a00", "a10", "a20", "a30", "a40", "a50"});

    epService.getEPRuntime().sendEvent(new SupportDeltaThree("x", "03", "41"));
    assertFalse(listenerOne.isInvoked());

    epService
        .getEPAdministrator()
        .createEPL("on SupportBean(intPrimitive=3) as sb delete from RevQuote where string = p3");

    log("b00");
    epService
        .getEPRuntime()
        .sendEvent(new SupportRevisionFull("b", "b00", "b10", "b20", "b30", "b40", "b50"));
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(),
        fields,
        new Object[] {"b", "b00", "b10", "b20", "b30", "b40", "b50"});

    log("a01");
    epService.getEPRuntime().sendEvent(new SupportDeltaThree("a", "a01", "a41"));
    ArrayAssertionUtil.assertProps(
        listenerOne.getLastNewData()[0],
        fields,
        new Object[] {"a", "a01", "a10", "a20", "a30", "a41", "a50"});
    ArrayAssertionUtil.assertProps(
        listenerOne.getLastOldData()[0],
        fields,
        new Object[] {"a", "a00", "a10", "a20", "a30", "a40", "a50"});
    listenerOne.reset();

    log("c00");
    epService
        .getEPRuntime()
        .sendEvent(new SupportRevisionFull("c", "c00", "c10", "c20", "c30", "c40", "c50"));
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(),
        fields,
        new Object[] {"c", "c00", "c10", "c20", "c30", "c40", "c50"});

    epService
        .getEPAdministrator()
        .createEPL("on SupportBean(intPrimitive=0) as sb delete from RevQuote where string = p0");

    log("c11");
    epService.getEPRuntime().sendEvent(new SupportDeltaFive("c", "c11", "c51"));
    ArrayAssertionUtil.assertProps(
        listenerOne.getLastNewData()[0],
        fields,
        new Object[] {"c", "c00", "c11", "c20", "c30", "c40", "c51"});
    ArrayAssertionUtil.assertProps(
        listenerOne.getLastOldData()[0],
        fields,
        new Object[] {"c", "c00", "c10", "c20", "c30", "c40", "c50"});
    listenerOne.reset();

    epService
        .getEPAdministrator()
        .createEPL("on SupportBean(intPrimitive=1) as sb delete from RevQuote where string = p1");

    log("d00");
    epService
        .getEPRuntime()
        .sendEvent(new SupportRevisionFull("d", "d00", "d10", "d20", "d30", "d40", "d50"));
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(),
        fields,
        new Object[] {"d", "d00", "d10", "d20", "d30", "d40", "d50"});

    log("d01");
    epService.getEPRuntime().sendEvent(new SupportDeltaFour("d", "d01", "d21", "d51"));
    ArrayAssertionUtil.assertProps(
        listenerOne.getLastNewData()[0],
        fields,
        new Object[] {"d", "d01", "d10", "d21", "d30", "d40", "d51"});
    ArrayAssertionUtil.assertProps(
        listenerOne.getLastOldData()[0],
        fields,
        new Object[] {"d", "d00", "d10", "d20", "d30", "d40", "d50"});
    listenerOne.reset();

    ArrayAssertionUtil.assertEqualsExactOrder(
        stmtCreateWin.iterator(),
        fields,
        new Object[][] {
          {"b", "b00", "b10", "b20", "b30", "b40", "b50"},
          {"a", "a01", "a10", "a20", "a30", "a41", "a50"},
          {"c", "c00", "c11", "c20", "c30", "c40", "c51"},
          {"d", "d01", "d10", "d21", "d30", "d40", "d51"}
        });

    epService
        .getEPAdministrator()
        .createEPL("on SupportBean(intPrimitive=4) as sb delete from RevQuote where string = p4");

    epService.getEPRuntime().sendEvent(new SupportBean("abc", 1));
    assertFalse(listenerOne.isInvoked());

    log("delete b");
    epService.getEPRuntime().sendEvent(new SupportBean("b40", 4)); // delete b
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetOldAndReset(),
        fields,
        new Object[] {"b", "b00", "b10", "b20", "b30", "b40", "b50"});
    ArrayAssertionUtil.assertEqualsExactOrder(
        stmtCreateWin.iterator(),
        fields,
        new Object[][] {
          {"a", "a01", "a10", "a20", "a30", "a41", "a50"},
          {"c", "c00", "c11", "c20", "c30", "c40", "c51"},
          {"d", "d01", "d10", "d21", "d30", "d40", "d51"}
        });

    log("delete d");
    epService.getEPRuntime().sendEvent(new SupportBean("d21", 2)); // delete d
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetOldAndReset(),
        fields,
        new Object[] {"d", "d01", "d10", "d21", "d30", "d40", "d51"});
    ArrayAssertionUtil.assertEqualsExactOrder(
        stmtCreateWin.iterator(),
        fields,
        new Object[][] {
          {"a", "a01", "a10", "a20", "a30", "a41", "a50"},
          {"c", "c00", "c11", "c20", "c30", "c40", "c51"}
        });

    log("delete a");
    epService.getEPRuntime().sendEvent(new SupportBean("a30", 3)); // delete a
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetOldAndReset(),
        fields,
        new Object[] {"a", "a01", "a10", "a20", "a30", "a41", "a50"});
    ArrayAssertionUtil.assertEqualsExactOrder(
        stmtCreateWin.iterator(),
        fields,
        new Object[][] {{"c", "c00", "c11", "c20", "c30", "c40", "c51"}});

    log("delete c");
    epService.getEPRuntime().sendEvent(new SupportBean("c11", 1)); // delete c
    ArrayAssertionUtil.assertProps(
        listenerOne.assertOneGetOldAndReset(),
        fields,
        new Object[] {"c", "c00", "c11", "c20", "c30", "c40", "c51"});
    ArrayAssertionUtil.assertEqualsExactOrder(stmtCreateWin.iterator(), fields, null);

    epService.getEPRuntime().sendEvent(new SupportBean("c11", 1));
    assertFalse(listenerOne.isInvoked());
  }