Пример #1
0
        public void TestNew()
        {
            String eplFragment = "select " +
                                 "contained.selectFrom(x => new {c0 = id||'x', c1 = key0||'y'}) as val0 " +
                                 "from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, "val0".Split(','), new Type[] { typeof(ICollection <object>) });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("E1,12,0", "E2,11,0", "E3,2,0"));
            EPAssertionUtil.AssertPropsPerRow(
                ToMapArray(_listener.AssertOneGetNewAndReset().Get("val0")), "c0,c1".Split(','),
                new Object[][] { new Object[] { "E1x", "12y" }, new Object[] { "E2x", "11y" }, new Object[] { "E3x", "2y" } });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("E4,0,1"));
            EPAssertionUtil.AssertPropsPerRow(
                ToMapArray(_listener.AssertOneGetNewAndReset().Get("val0")), "c0,c1".Split(','),
                new Object[][] { new Object[] { "E4x", "0y" } });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value(null));
            EPAssertionUtil.AssertPropsPerRow(
                ToMapArray(_listener.AssertOneGetNewAndReset().Get("val0")), "c0,c1".Split(','), null);

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value());
            EPAssertionUtil.AssertPropsPerRow(
                ToMapArray(_listener.AssertOneGetNewAndReset().Get("val0")), "c0,c1".Split(','),
                new Object[0][]);
        }
Пример #2
0
        private void RunAssertionSelectFrom(EPServiceProvider epService)
        {
            string[] fields      = "val0".Split(',');
            string   eplFragment = "select Contained.selectFrom(x => key0).sequenceEqual(Contained.selectFrom(y => id)) as val0 " +
                                   "from SupportBean_ST0_Container";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, "val0".Split(','), new Type[] {
                typeof(bool)
            });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I1,E1,0", "I2,E2,0"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { false });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I3,I3,0", "X4,X4,0"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { true });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I3,I3,0", "X4,Y4,0"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { false });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I3,I3,0", "Y4,X4,0"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { false });

            stmtFragment.Dispose();
        }
Пример #3
0
        private void RunAssertionProperty(EPServiceProvider epService)
        {
            // test fragment type - collection inside
            var eplFragment = "select Contained.allOf(x => x.p00 < 5) as allOfX from SupportBean_ST0_Container#keepall";
            var stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var listener = new SupportUpdateListener();
            stmtFragment.Events += listener.Update;

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("ID1,KEY1,1"));
            Assert.AreEqual(true, listener.AssertOneGetNewAndReset().Get("allOfX"));

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("ID1,KEY1,10"));
            Assert.AreEqual(false, listener.AssertOneGetNewAndReset().Get("allOfX"));
            stmtFragment.Dispose();

            // test array and iterable
            var fields = "val0,val1".Split(',');
            eplFragment = "select Intarray.sumof() as val0, " +
                          "Intiterable.sumOf() as val1 " +
                          " from SupportCollection#keepall";
            stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            stmtFragment.Events += listener.Update;

            epService.EPRuntime.SendEvent(SupportCollection.MakeNumeric("5,6,7"));
            EPAssertionUtil.AssertProps(
                listener.AssertOneGetNewAndReset(), fields, new object[] {5 + 6 + 7, 5 + 6 + 7});

            // test map event type with object-array prop
            epService.EPAdministrator.Configuration.AddEventType(typeof(BookDesc));
            epService.EPAdministrator.CreateEPL("create schema MySchema (books BookDesc[])");

            var stmt = epService.EPAdministrator.CreateEPL("select books.max(i => i.price) as mymax from MySchema");
            stmt.Events += listener.Update;

            var @event = Collections.SingletonDataMap(
                "books", new[] {new BookDesc("1", "book1", "dave", 1.00, null)});
            epService.EPRuntime.SendEvent(@event, "MySchema");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "mymax".Split(','), new object[] {1.0});

            // test method invocation variations returning list/array of string and test UDF +property as well
            RunAssertionMethodInvoke(epService, "select e.TheList.anyOf(v => v = selector) as flag from MyEvent e");
            epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction(
                "convertToArray", typeof(MyEvent), "ConvertToArray");
            RunAssertionMethodInvoke(
                epService, "select convertToArray(theList).anyOf(v => v = selector) as flag from MyEvent e");
            RunAssertionMethodInvoke(epService, "select TheArray.anyOf(v => v = selector) as flag from MyEvent e");
            RunAssertionMethodInvoke(epService, "select e.TheArray.anyOf(v => v = selector) as flag from MyEvent e");
            RunAssertionMethodInvoke(
                epService, "select e.TheList.anyOf(v => v = e.selector) as flag from pattern[every e=MyEvent]");
            RunAssertionMethodInvoke(
                epService,
                "select e.NestedMyEvent.MyNestedList.anyOf(v => v = e.selector) as flag from pattern[every e=MyEvent]");
            RunAssertionMethodInvoke(
                epService,
                "select " + TypeHelper.MaskTypeName<MyEvent>() +
                ".ConvertToArray(TheList).anyOf(v => v = selector) as flag from MyEvent e");

            stmt.Dispose();
        }
Пример #4
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.selectFrom( (v, i) => new {v0=v.Id,v1=i})");
                builder.WithExpression(fields[1], "Contained.selectFrom( (v, i, s) => new {v0=v.Id,v1=i + 100*s})");

                builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>)));

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("E1,12,0", "E2,11,0", "E3,2,0"))
                .Verify(
                    fields[0],
                    value => AssertRows(
                        value,
                        new object[][] {
                    new object[] { "E1", 0 },
                    new object[] { "E2", 1 },
                    new object[] { "E3", 2 }
                }))
                .Verify(
                    fields[1],
                    value => AssertRows(
                        value,
                        new object[][] {
                    new object[] { "E1", 300 },
                    new object[] { "E2", 301 },
                    new object[] { "E3", 302 }
                }));

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("E4,0,1"))
                .Verify(
                    fields[0],
                    value => AssertRows(
                        value,
                        new object[][] {
                    new object[] { "E4", 0 }
                }))
                .Verify(
                    fields[1],
                    value => AssertRows(
                        value,
                        new object[][] {
                    new object[] { "E4", 100 }
                }));

                builder.WithAssertion(SupportBean_ST0_Container.Make3ValueNull())
                .Verify(fields[0], value => AssertRows(value, null))
                .Verify(fields[1], value => AssertRows(value, null));

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value())
                .Verify(fields[0], value => AssertRows(value, new object[0][]))
                .Verify(fields[1], value => AssertRows(value, new object[0][]));

                builder.Run(env);
            }
Пример #5
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.selectFrom(x => Key0).sequenceEqual(Contained.selectFrom(y => Id))");

                builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(bool?)));

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("I1,E1,0", "I2,E2,0")).Expect(fields, false);

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("I3,I3,0", "X4,X4,0")).Expect(fields, true);

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("I3,I3,0", "X4,Y4,0")).Expect(fields, false);

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("I3,I3,0", "Y4,X4,0")).Expect(fields, false);

                builder.Run(env);
            }
Пример #6
0
        private void RunAssertionOneParameterLambdaReturn(string epl)
        {
            var stmt = _epService.EPAdministrator.CreateEPL(epl);

            stmt.AddListener(_listener);
            LambdaAssertionUtil.AssertTypes(stmt.EventType, "val1,val2".Split(','), new Type[] { typeof(ICollection <object>), typeof(ICollection <object>) });

            var theEvent = SupportBean_ST0_Container.Make3Value("E1,K1,1", "E2,K2,2", "E20,K20,20");

            _epService.EPRuntime.SendEvent(theEvent);
            var resultVal1 = ((ICollection <object>)_listener.LastNewData[0].Get("val1")).ToArray();

            EPAssertionUtil.AssertEqualsExactOrder(new object[] { theEvent.Contained[0], theEvent.Contained[1] }, resultVal1
                                                   );
            var resultVal2 = ((ICollection <object>)_listener.LastNewData[0].Get("val2")).ToArray();

            EPAssertionUtil.AssertEqualsExactOrder(new object[] { theEvent.Contained[1] }, resultVal2
                                                   );

            _epService.EPAdministrator.DestroyAllStatements();
        }
Пример #7
0
        public void TestSelectFrom()
        {
            String[] fields      = "val0".Split(',');
            String   eplFragment = "select contained.SelectFrom(x => key0).sequenceEqual(contained.SelectFrom(y => id)) as val0 " +
                                   "from SupportBean_ST0_Container";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, "val0".Split(','), new Type[] { typeof(bool) });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I1,E1,0", "I2,E2,0"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { false });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I3,I3,0", "X4,X4,0"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { true });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I3,I3,0", "X4,Y4,0"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { false });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make3Value("I3,I3,0", "Y4,X4,0"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { false });
        }
Пример #8
0
            public void Run(RegressionEnvironment env)
            {
                string             field   = "c0";
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(field, "Contained.selectFrom(x => new {c0 = Id||'x', c1 = Key0||'y'})");

                builder.WithStatementConsumer(stmt => AssertTypes(stmt.EventType, field, typeof(ICollection <object>)));

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("E1,12,0", "E2,11,0", "E3,2,0"))
                .Verify(
                    field,
                    value => AssertRows(
                        value,
                        new object[][] {
                    new object[] { "E1x", "12y" },
                    new object[] { "E2x", "11y" },
                    new object[] { "E3x", "2y" }
                }));

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value("E4,0,1"))
                .Verify(
                    field,
                    value => AssertRows(
                        value,
                        new object[][] {
                    new object[] { "E4x", "0y" }
                }));

                builder.WithAssertion(SupportBean_ST0_Container.Make3ValueNull())
                .Verify(field, value => AssertRows(value, null));

                builder.WithAssertion(SupportBean_ST0_Container.Make3Value())
                .Verify(field, value => AssertRows(value, new object[0][]));

                builder.Run(env);
            }