private void RunAssertion()
        {
            string[] fields = "orderId,bookId,reviewId".Split(',');

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventOne());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] {
                new object[] { "PO200901", "10020", 1 }, new object[] { "PO200901", "10020", 2 }, new object[] { "PO200901", "10021", 10 }
            });
            _listener.Reset();

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { "PO200904", "10031", 201 } });
            _listener.Reset();
        }
        public void TestSimple()
        {
            string[] fields = "reviewId".Split(',');
            _epService.EPAdministrator.Configuration.AddEventType("OrderEvent", typeof(OrderBean));

            string         stmtText = "select reviewId from OrderEvent[books][reviews] bookReviews order by reviewId asc";
            EPStatementSPI stmt     = (EPStatementSPI)_epService.EPAdministrator.CreateEPL(stmtText);

            Assert.IsTrue(stmt.StatementContext.IsStatelessSelect);
            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventOne());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { 1 }, new object[] { 2 }, new object[] { 10 } });
            _listener.Reset();

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { 201 } });
            _listener.Reset();
        }
        public void TestNamedWindowFilter()
        {
            string[] fields = "reviewId".Split(',');
            _epService.EPAdministrator.Configuration.AddEventType("OrderEvent", typeof(OrderBean));

            _epService.EPAdministrator.CreateEPL("create window OrderWindow.std:lastevent() as OrderEvent");
            _epService.EPAdministrator.CreateEPL("insert into OrderWindow select * from OrderEvent");

            string      stmtText = "select reviewId from OrderWindow[books][reviews] bookReviews order by reviewId asc";
            EPStatement stmt     = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventOne());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { 1 }, new object[] { 2 }, new object[] { 10 } });
            _listener.Reset();

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { 201 } });
            _listener.Reset();
        }
        public void TestUnderlyingSelect()
        {
            string[] fields = "orderId,bookId,reviewId".Split(',');
            _epService.EPAdministrator.Configuration.AddEventType("OrderEvent", typeof(OrderBean));

            string stmtText = "select orderdetail.orderId as orderId, bookFrag.bookId as bookId, reviewFrag.reviewId as reviewId " +
                              //String stmtText = "select * " +
                              "from OrderEvent[books as book][select myorder.*, book.* as bookFrag, review.* as reviewFrag from reviews as review] as myorder";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventOne());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] {
                new object[] { "PO200901", "10020", 1 }, new object[] { "PO200901", "10020", 2 }, new object[] { "PO200901", "10021", 10 }
            });
            _listener.Reset();

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { "PO200904", "10031", 201 } });
            _listener.Reset();
        }
        public void TestSubSelect()
        {
            _epService.EPAdministrator.Configuration.AddEventType("OrderEvent", typeof(OrderBean));
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select theString from SupportBean s0 where " +
                                                                    "exists (select * from OrderEvent[books][reviews].std:unique(reviewId) where reviewId = s0.intPrimitive)");

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventOne());
            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.IsTrue(_listener.GetAndClearIsInvoked());

            _epService.EPRuntime.SendEvent(new SupportBean("E2", -1));
            Assert.IsFalse(_listener.GetAndClearIsInvoked());

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 201));
            Assert.IsTrue(_listener.GetAndClearIsInvoked());
        }
        public void TestPatternSelect()
        {
            _epService.EPAdministrator.Configuration.AddEventType("OrderEvent", typeof(OrderBean));
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from pattern [" +
                                                                    "every r=OrderEvent[books][reviews] -> SupportBean(intPrimitive = r[0].reviewId)]");

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventOne());
            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            Assert.IsTrue(_listener.GetAndClearIsInvoked());

            _epService.EPRuntime.SendEvent(new SupportBean("E2", -1));
            Assert.IsFalse(_listener.GetAndClearIsInvoked());

            _epService.EPRuntime.SendEvent(new SupportBean("E2", 201));
            Assert.IsTrue(_listener.GetAndClearIsInvoked());
        }
        public void TestNamedWindowSubquery()
        {
            string[] fields = "theString,totalPrice".Split(',');
            _epService.EPAdministrator.Configuration.AddEventType("OrderEvent", typeof(OrderBean));
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            _epService.EPAdministrator.CreateEPL("create window OrderWindow.std:lastevent() as OrderEvent");
            _epService.EPAdministrator.CreateEPL("insert into OrderWindow select * from OrderEvent");

            string      stmtText = "select *, (select sum(price) from OrderWindow[books]) as totalPrice from SupportBean";
            EPStatement stmt     = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventOne());
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { "E1", 24d + 35d + 27d } });
            _listener.Reset();

            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { "E2", 15d + 13d } });
            _listener.Reset();
        }
        public void TestNamedWindowOnTrigger()
        {
            string[] fields = "theString,intPrimitive".Split(',');
            _epService.EPAdministrator.Configuration.AddEventType("OrderEvent", typeof(OrderBean));
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean>();

            _epService.EPAdministrator.CreateEPL("create window SupportBeanWindow.std:lastevent() as SupportBean");
            _epService.EPAdministrator.CreateEPL("insert into SupportBeanWindow select * from SupportBean");
            _epService.EPAdministrator.CreateEPL("create window OrderWindow.std:lastevent() as OrderEvent");
            _epService.EPAdministrator.CreateEPL("insert into OrderWindow select * from OrderEvent");

            string      stmtText = "on OrderWindow[books] owb select sbw.* from SupportBeanWindow sbw where theString = title";
            EPStatement stmt     = _epService.EPAdministrator.CreateEPL(stmtText);

            stmt.AddListener(_listener);

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());
            Assert.IsFalse(_listener.IsInvoked);

            _epService.EPRuntime.SendEvent(new SupportBean("Foundation 2", 2));
            _epService.EPRuntime.SendEvent(TestContainedEventSimple.MakeEventFour());
            EPAssertionUtil.AssertPropsPerRow(_listener.LastNewData, fields, new object[][] { new object[] { "Foundation 2", 2 } });
        }