Beispiel #1
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1,c2,c3,c4".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.aggregate(0, (result, item) => result + item.P00)");
                builder.WithExpression(fields[1], "Contained.aggregate('', (result, item) => result || ', ' || item.Id)");
                builder.WithExpression(fields[2], "Contained.aggregate('', (result, item) => result || (case when result='' then '' else ',' end) || item.Id)");
                builder.WithExpression(fields[3], "Contained.aggregate(0, (result, item, i) => result + item.P00 + i*10)");
                builder.WithExpression(fields[4], "Contained.aggregate(0, (result, item, i, s) => result + item.P00 + i*10 + s*100)");

                builder.WithStatementConsumer(
                    stmt => LambdaAssertionUtil.AssertTypes(
                        stmt.EventType,
                        fields,
                        new[] { typeof(int?), typeof(string), typeof(string), typeof(int?), typeof(int?) }));

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2"))
                .Expect(fields, 25, ", E1, E2, E2", "E1,E2,E2", 12 + 21 + 22, 312 + 321 + 322);

                builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull())
                .Expect(fields, null, null, null, null, null);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value(new string[0]))
                .Expect(fields, 0, "", "", 0, 0);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,12"))
                .Expect(fields, 12, ", E1", "E1", 12, 112);

                builder.Run(env);
            }
Beispiel #2
0
        public void TestCountOfEvents()
        {
            var          fields      = new[] { "val0", "val1" };
            const string eplFragment = "select " +
                                       "contained.countof(x=> x.P00 = 9) as val0, " +
                                       "contained.countof() as val1 " +
                                       " from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(int), typeof(int) });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E2,9"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { 2, 3 });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { null, null });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(new String[0]));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { 0, 0 });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,9"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { 1, 1 });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { 0, 1 });
        }
Beispiel #3
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();
        }
Beispiel #4
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1,c2,c3".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.countof()");
                builder.WithExpression(fields[1], "Contained.countof(x => x.P00 = 9)");
                builder.WithExpression(fields[2], "Contained.countof((x, i) => x.P00 + i = 10)");
                builder.WithExpression(fields[3], "Contained.countof((x, i, s) => x.P00 + i + s = 100)");

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

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E2,9")).Expect(fields, 3, 2, 1, 0);

                builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()).Expect(fields, null, null, null, null);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value()).Expect(fields, 0, 0, 0, 0);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,9")).Expect(fields, 1, 1, 0, 0);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1")).Expect(fields, 1, 0, 0, 0);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,10", "E2,9")).Expect(fields, 2, 1, 2, 0);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,98", "E2,97")).Expect(fields, 2, 0, 0, 2);

                builder.Run(env);
            }
        private void RunAssertionAllOfAnyOfEvents(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1".Split(',');
            string   eplFragment = "select " +
                                   "Contained.allof(x => p00 = 12) as val0," +
                                   "Contained.anyof(x => p00 = 12) as val1 " +
                                   "from Bean";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,12", "E2,2"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { false, true });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { null, null });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,12", "E2,12", "E2,12"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { true, true });

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

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { true, false });

            stmtFragment.Dispose();
        }
Beispiel #6
0
        private void RunAssertionFirstLastNoPred(EPServiceProvider epService)
        {
            string eplFragment = "select " +
                                 "Contained.firstOf() as val0, " +
                                 "Contained.lastOf() as val1 " +
                                 " from Bean";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,9", "E2,9"));
            AssertId(listener, "val0", "E1");
            AssertId(listener, "val1", "E2");
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E2,2"));
            AssertId(listener, "val0", "E2");
            AssertId(listener, "val1", "E2");
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            Assert.IsNull(listener.AssertOneGetNew().Get("val0"));
            Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val1"));

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            Assert.IsNull(listener.AssertOneGetNew().Get("val0"));
            Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val1"));

            stmtFragment.Dispose();
        }
Beispiel #7
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.reverse()");

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

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E3,1"))
                .Verify("c0", val => AssertST0Id(val, "E3,E2,E1"));

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E2,9", "E1,1"))
                .Verify("c0", val => AssertST0Id(val, "E1,E2"));

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1"))
                .Verify("c0", val => AssertST0Id(val, "E1"));

                builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull())
                .Verify("c0", val => AssertST0Id(val, null));

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value())
                .Verify("c0", val => AssertST0Id(val, ""));

                builder.Run(env);
            }
Beispiel #8
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][]);
        }
Beispiel #9
0
        public void Run(RegressionEnvironment env)
        {
            IList<SupportBean_ST0> list = new List<SupportBean_ST0>();
            for (var i = 0; i < 10000; i++) {
                list.Add(new SupportBean_ST0("E1", 1000));
            }

            var minEvent = new SupportBean_ST0("E2", 5);
            list.Add(minEvent);
            var theEvent = new SupportBean_ST0_Container(list);

            // the "Contained.min" inner lambda only depends on values within "contained" (a stream's value)
            // and not on the particular "x".
            var eplFragment =
                "@Name('s0') select Contained.where(x => x.P00 = Contained.min(y -> y.P00)) as val from SupportBean_ST0_Container";
            env.CompileDeploy(eplFragment).AddListener("s0");

            var start = PerformanceObserver.MilliTime;
            env.SendEventBean(theEvent);
            var delta = PerformanceObserver.MilliTime - start;
            Assert.That(delta, Is.LessThan(100), "delta=" + delta);

            var result = env.Listener("s0")
                .AssertOneGetNewAndReset()
                .Get("val")
                .UnwrapIntoArray<SupportBean_ST0>();
            EPAssertionUtil.AssertEqualsExactOrder(new object[] {minEvent}, result);

            env.UndeployAll();
        }
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1,c2,c3,c4,c5".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.mostFrequent(x => P00)");
                builder.WithExpression(fields[1], "Contained.leastFrequent(x => P00)");
                builder.WithExpression(fields[2], "Contained.mostFrequent( (x, i) => P00 + i*2)");
                builder.WithExpression(fields[3], "Contained.leastFrequent( (x, i) => P00 + i*2)");
                builder.WithExpression(fields[4], "Contained.mostFrequent( (x, i, s) => P00 + i*2 + s*4)");
                builder.WithExpression(fields[5], "Contained.leastFrequent( (x, i, s) => P00 + i*2 + s*4)");

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

                SupportBean_ST0_Container bean = SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2", "E3,12");

                builder.WithAssertion(bean).Expect(fields, 12, 11, 12, 12, 28, 28);

                bean = SupportBean_ST0_Container.Make2Value("E1,12");
                builder.WithAssertion(bean).Expect(fields, 12, 12, 12, 12, 16, 16);

                bean = SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2", "E3,12", "E1,12", "E2,11", "E3,11");
                builder.WithAssertion(bean).Expect(fields, 12, 2, 12, 12, 40, 40);

                bean = SupportBean_ST0_Container.Make2Value("E2,11", "E1,12", "E2,15", "E3,12", "E1,12", "E2,11", "E3,11");
                builder.WithAssertion(bean).Expect(fields, 11, 15, 11, 11, 39, 39);

                builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()).Expect(fields, null, null, null, null, null, null);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value()).Expect(fields, null, null, null, null, null, null);

                builder.Run(env);
            }
Beispiel #11
0
        public void TestAllOfAnyOfEvents()
        {
            String[] fields      = "val0,val1".Split(',');
            String   eplFragment = "select " +
                                   "contained.allof(x => p00 = 12) as val0," +
                                   "contained.anyof(x => p00 = 12) as val1 " +
                                   "from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

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

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,12", "E2,2"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { false, true });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, null });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,12", "E2,12", "E2,12"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { true, true });

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

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { true, false });
        }
Beispiel #12
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1,c2".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.toMap(c => Id, d => P00)");
                builder.WithExpression(fields[1], "Contained.toMap((c, index) => Id || '_' || Convert.ToString(index), (d, index) => P00 + 10*index)");
                builder.WithExpression(
                    fields[2],
                    "Contained.toMap((c, index, size) => Id || '_' || Convert.ToString(index) || '_' || Convert.ToString(size), (d, index, size) => P00 + 10*index + 100*size)");

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

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,5"))
                .Verify("c0", val => CompareMap(val, "E1,E3,E2", 1, 12, 5))
                .Verify("c1", val => CompareMap(val, "E1_0,E3_1,E2_2", 1, 22, 25))
                .Verify("c2", val => CompareMap(val, "E1_0_3,E3_1_3,E2_2_3", 301, 322, 325));

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E3,4", "E2,7", "E1,2"))
                .Verify("c0", val => CompareMap(val, "E1,E3,E2", 2, 4, 7))
                .Verify("c1", val => CompareMap(val, "E1_0,E3_1,E2_2,E1_3", 1, 14, 27, 32))
                .Verify("c2", val => CompareMap(val, "E1_0_4,E3_1_4,E2_2_4,E1_3_4", 401, 414, 427, 432));

                builder.WithAssertion(new SupportBean_ST0_Container(Collections.SingletonList(new SupportBean_ST0(null, null))))
                .Verify("c0", val => CompareMap(val, "E1,E2,E3", null, null, null))
                .Verify("c1", val => CompareMap(val, "E1,E2,E3", null, null, null))
                .Verify("c2", val => CompareMap(val, "E1,E2,E3", null, null, null));

                builder.Run(env);
            }
Beispiel #13
0
        private void RunAssertionFirstLastProperty(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1".Split(',');
            string   eplFragment = "select " +
                                   "Contained.firstOf().p00 as val0, " +
                                   "Contained.lastOf().p00 as val1 " +
                                   " from Bean";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(int?), typeof(int?) });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E3,3"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1, 3 });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1, 1 });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { null, null });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { null, null });

            stmtFragment.Dispose();
        }
Beispiel #14
0
        private void RunAssertionAggregateEvents(EPServiceProvider epService)
        {
            var    fields      = new string[] { "val0", "val1", "val2" };
            string eplFragment = "select " +
                                 "Contained.aggregate(0, (result, item) => result + item.p00) as val0, " +
                                 "Contained.aggregate('', (result, item) => result || ', ' || item.id) as val1, " +
                                 "Contained.aggregate('', (result, item) => result || (case when result='' then '' else ',' end) || item.id) as val2 " +
                                 " from Bean";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(int?), typeof(string), typeof(string) });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 25, ", E1, E2, E2", "E1,E2,E2" });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { null, null, null });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(new string[0]));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 0, "", "" });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,12"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        new object[] { 12, ", E1", "E1" });

            stmtFragment.Dispose();
        }
Beispiel #15
0
        public void TestMostLeastEvents()
        {
            String[] fields      = "val0,val1".Split(',');
            String   eplFragment = "select " +
                                   "contained.MostFrequent(x => p00) as val0," +
                                   "contained.LeastFrequent(x => p00) as val1 " +
                                   "from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(int?), typeof(int?) });

            SupportBean_ST0_Container bean = SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2", "E3,12");

            _epService.EPRuntime.SendEvent(bean);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 12, 11 });

            bean = SupportBean_ST0_Container.Make2Value("E1,12");
            _epService.EPRuntime.SendEvent(bean);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 12, 12 });

            bean = SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2", "E3,12", "E1,12", "E2,11", "E3,11");
            _epService.EPRuntime.SendEvent(bean);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 12, 2 });

            bean = SupportBean_ST0_Container.Make2Value("E2,11", "E1,12", "E2,15", "E3,12", "E1,12", "E2,11", "E3,11");
            _epService.EPRuntime.SendEvent(bean);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 11, 15 });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, null });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, null });
        }
Beispiel #16
0
        public void TestReverseEvents()
        {
            String      epl  = "select contained.reverse() as val from Bean";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

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

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E3,1"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val", "E3,E2,E1");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E2,9", "E1,1"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val", "E1,E2");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val", "E1");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            LambdaAssertionUtil.AssertST0Id(_listener, "val", null);
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            LambdaAssertionUtil.AssertST0Id(_listener, "val", "");
            _listener.Reset();
        }
Beispiel #17
0
        public void TestPerfNestedUncorrelated()
        {
            List <SupportBean_ST0> list = new List <SupportBean_ST0>();

            for (int i = 0; i < 10000; i++)
            {
                list.Add(new SupportBean_ST0("E1", 1000));
            }
            SupportBean_ST0 minEvent = new SupportBean_ST0("E2", 5);

            list.Add(minEvent);
            SupportBean_ST0_Container theEvent = new SupportBean_ST0_Container(list);

            // the "contained.min" inner lambda only depends on values within "contained" (a stream's value)
            // and not on the particular "x".
            String      eplFragment  = "select contained.Where(x => x.P00 = contained.min(y => y.P00)) as val from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;

            long start = Environment.TickCount;

            _epService.EPRuntime.SendEvent(theEvent);
            long delta = Environment.TickCount - start;

            Assert.IsTrue(delta < 100, "delta=" + delta);

            ICollection <object> result = (ICollection <object>)_listener.AssertOneGetNewAndReset().Get("val");

            EPAssertionUtil.AssertEqualsExactOrder(new Object[] { minEvent }, result.ToArray());
        }
Beispiel #18
0
        public void TestDistinctEvents()
        {
            String[] fields      = "val0".Split(',');
            String   eplFragment = "select " +
                                   "contained.DistinctOf(x => p00) as val0 " +
                                   " from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

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

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2", "E3,1"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", "E1,E2");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E3,1", "E2,2", "E4,1", "E1,2"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", "E3,E2");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            foreach (String field in fields)
            {
                LambdaAssertionUtil.AssertST0Id(_listener, field, null);
            }
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            foreach (String field in fields)
            {
                LambdaAssertionUtil.AssertST0Id(_listener, field, "");
            }
            _listener.Reset();
        }
Beispiel #19
0
        public void TestWhereEvents()
        {
            String epl = "select " +
                         "contained.Where(x => p00 = 9) as val0," +
                         "contained.Where((x, i) => x.P00 = 9 and i >= 1) as val1 from Bean";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

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

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E3,1"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", "E2");
            LambdaAssertionUtil.AssertST0Id(_listener, "val1", "E2");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,9", "E2,1", "E3,1"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", "E1");
            LambdaAssertionUtil.AssertST0Id(_listener, "val1", "");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,1", "E3,9"));
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", "E3");
            LambdaAssertionUtil.AssertST0Id(_listener, "val1", "E3");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", null);
            LambdaAssertionUtil.AssertST0Id(_listener, "val1", null);
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", "");
            LambdaAssertionUtil.AssertST0Id(_listener, "val1", "");
            _listener.Reset();
        }
Beispiel #20
0
        public void TestAggregateEvents()
        {
            String[] fields      = new String[] { "val0", "val1", "val2" };
            String   eplFragment = "select " +
                                   "contained.Aggregate(0, (result, item) => result + item.P00) as val0, " +
                                   "contained.Aggregate('', (result, item) => result || ', ' || item.id) as val1, " +
                                   "contained.Aggregate('', (result, item) => result || (case when result='' then '' else ',' end) || item.id) as val2 " +
                                   " from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(int?), typeof(string), typeof(string) });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { 25, ", E1, E2, E2", "E1,E2,E2" });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { null, null, null });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(new String[0]));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { 0, "", "" });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,12"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { 12, ", E1", "E1" });
        }
Beispiel #21
0
        public void TestSetLogicWithContained()
        {
            String epl = "select " + "contained.except(containedTwo) as val0,"
                         + "contained.intersect(containedTwo) as val1, "
                         + "contained.union(containedTwo) as val2 "
                         + " from SupportBean_ST0_Container";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl);

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

            List <SupportBean_ST0> first = SupportBean_ST0_Container.Make2ValueList(
                "E1,1", "E2,10", "E3,1", "E4,10", "E5,11");
            List <SupportBean_ST0> second = SupportBean_ST0_Container.Make2ValueList(
                "E1,1", "E3,1", "E4,10");

            _epService.EPRuntime.SendEvent(
                new SupportBean_ST0_Container(first, second));
            LambdaAssertionUtil.AssertST0Id(_listener, "val0", "E2,E5");
            LambdaAssertionUtil.AssertST0Id(_listener, "val1", "E1,E3,E4");
            LambdaAssertionUtil.AssertST0Id(_listener, "val2",
                                            "E1,E2,E3,E4,E5,E1,E3,E4");
            _listener.Reset();
        }
Beispiel #22
0
        public void TestFirstLastNoPred()
        {
            String eplFragment = "select " +
                                 "Contained.firstOf() as val0, " +
                                 "Contained.lastOf() as val1 " +
                                 " from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

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

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,9", "E2,9"));
            AssertId(_listener, "val0", "E1");
            AssertId(_listener, "val1", "E2");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E2,2"));
            AssertId(_listener, "val0", "E2");
            AssertId(_listener, "val1", "E2");
            _listener.Reset();

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            Assert.IsNull(_listener.AssertOneGetNew().Get("val0"));
            Assert.IsNull(_listener.AssertOneGetNewAndReset().Get("val1"));

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            Assert.IsNull(_listener.AssertOneGetNew().Get("val0"));
            Assert.IsNull(_listener.AssertOneGetNewAndReset().Get("val1"));
        }
Beispiel #23
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1,c2".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.arrayOf(x => x.P00)");
                builder.WithExpression(fields[1], "Contained.arrayOf((x, i) => x.P00 + i*10)");
                builder.WithExpression(fields[2], "Contained.arrayOf((x, i, s) => x.P00 + i*10 + s*100)");

                builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(int?[])));

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E2,2"))
                .Expect(fields, IntArray(1, 9, 2), IntArray(1, 19, 22), IntArray(301, 319, 322));

                builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull())
                .Expect(fields, null, null, null);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value())
                .Expect(fields, IntArray(), IntArray(), IntArray());

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,9"))
                .Expect(fields, IntArray(9), IntArray(9), IntArray(109));

                builder.Run(env);
            }
        public override void Run(EPServiceProvider epService)
        {
            var list = new List <SupportBean_ST0>();

            for (int i = 0; i < 10000; i++)
            {
                list.Add(new SupportBean_ST0("E1", 1000));
            }
            var minEvent = new SupportBean_ST0("E2", 5);

            list.Add(minEvent);
            var theEvent = new SupportBean_ST0_Container(list);

            // the "Contained.min" inner lambda only depends on values within "contained" (a stream's value)
            // and not on the particular "x".
            string      eplFragment  = "select Contained.where(x => x.p00 = Contained.min(y => y.p00)) as val from Bean";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;

            long start = PerformanceObserver.MilliTime;

            epService.EPRuntime.SendEvent(theEvent);
            long delta = PerformanceObserver.MilliTime - start;

            Assert.IsTrue(delta < 100, "delta=" + delta);

            var result = listener.AssertOneGetNewAndReset().Get("val")
                         .UnwrapIntoArray <SupportBean_ST0>();

            EPAssertionUtil.AssertEqualsExactOrder(new object[] { minEvent }, result);
        }
Beispiel #25
0
        private void RunAssertionFirstLastPredicate(EPServiceProvider epService)
        {
            string      eplFragment  = "select Contained.firstOf(x => p00 = 9) as val from Bean";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

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

            SupportBean_ST0_Container bean = SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E2,9");

            epService.EPRuntime.SendEvent(bean);
            SupportBean_ST0 result = (SupportBean_ST0)listener.AssertOneGetNewAndReset().Get("val");

            Assert.AreSame(result, bean.Contained[1]);

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val"));

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val"));

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,1", "E2,1"));
            Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val"));

            stmtFragment.Dispose();
        }
Beispiel #26
0
        private void RunAssertionReverseEvents(EPServiceProvider epService)
        {
            string      epl      = "select Contained.Reverse() as val from Bean";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmt.EventType, "val".Split(','), new Type[] {
                typeof(ICollection <SupportBean_ST0>)
            });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E3,1"));
            LambdaAssertionUtil.AssertST0Id(listener, "val", "E3,E2,E1");
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E2,9", "E1,1"));
            LambdaAssertionUtil.AssertST0Id(listener, "val", "E1,E2");
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1"));
            LambdaAssertionUtil.AssertST0Id(listener, "val", "E1");
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            LambdaAssertionUtil.AssertST0Id(listener, "val", null);
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            LambdaAssertionUtil.AssertST0Id(listener, "val", "");
            listener.Reset();

            stmt.Dispose();
        }
Beispiel #27
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1,c2,c3".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.orderBy( (x, i) => case when i <= 2 then P00 else i-10 end)");
                builder.WithExpression(fields[1], "Contained.orderByDesc( (x, i) => case when i <= 2 then P00 else i-10 end)");
                builder.WithExpression(fields[2], "Contained.orderBy( (x, i, s) => case when s <= 2 then P00 else i-10 end)");
                builder.WithExpression(fields[3], "Contained.orderByDesc( (x, i, s) => case when s <= 2 then P00 else i-10 end)");

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

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2"))
                .Verify("c0", val => AssertST0Id(val, "E1,E2"))
                .Verify("c1", val => AssertST0Id(val, "E2,E1"))
                .Verify("c2", val => AssertST0Id(val, "E1,E2"))
                .Verify("c3", val => AssertST0Id(val, "E2,E1"));

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2", "E3,3", "E4,4"))
                .Verify("c0", val => AssertST0Id(val, "E4,E1,E2,E3"))
                .Verify("c1", val => AssertST0Id(val, "E3,E2,E1,E4"))
                .Verify("c2", val => AssertST0Id(val, "E1,E2,E3,E4"))
                .Verify("c3", val => AssertST0Id(val, "E4,E3,E2,E1"));

                builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()).Expect(fields, null, null, null, null);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value())
                .Verify("c0", val => AssertST0Id(val, ""))
                .Verify("c1", val => AssertST0Id(val, ""))
                .Verify("c2", val => AssertST0Id(val, ""))
                .Verify("c3", val => AssertST0Id(val, ""));

                builder.Run(env);
            }
Beispiel #28
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();
        }
Beispiel #29
0
            public void Run(RegressionEnvironment env)
            {
                string[]           fields  = "c0,c1,c2,c3,c4,c5".SplitCsv();
                SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container");

                builder.WithExpression(fields[0], "Contained.firstOf(x => P00 = 9)");
                builder.WithExpression(fields[1], "Contained.lastOf(x => P00 = 9)");
                builder.WithExpression(fields[2], "Contained.firstOf( (x, i) => P00 = 9 and i >= 1)");
                builder.WithExpression(fields[3], "Contained.lastOf( (x, i) => P00 = 9 and i >= 1)");
                builder.WithExpression(fields[4], "Contained.firstOf( (x, i, s) => P00 = 9 and i >= 1 and s > 2)");
                builder.WithExpression(fields[5], "Contained.lastOf((x, i, s) => P00 = 9 and i >= 1 and s > 2)");

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

                SupportBean_ST0_Container beanOne = SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E2,9");

                builder.WithAssertion(beanOne)
                .Expect(
                    fields,
                    beanOne.Contained[1],
                    beanOne.Contained[2],
                    beanOne.Contained[1],
                    beanOne.Contained[2],
                    beanOne.Contained[1],
                    beanOne.Contained[2]);

                builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()).Expect(fields, null, null, null, null, null, null);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value()).Expect(fields, null, null, null, null, null, null);

                builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,1", "E2,1")).Expect(fields, null, null, null, null, null, null);

                SupportBean_ST0_Container beanTwo = SupportBean_ST0_Container.Make2Value("E1,1", "E2,9");

                builder.WithAssertion(beanTwo)
                .Expect(
                    fields,
                    beanTwo.Contained[1],
                    beanTwo.Contained[1],
                    beanTwo.Contained[1],
                    beanTwo.Contained[1],
                    null,
                    null);

                SupportBean_ST0_Container beanThree = SupportBean_ST0_Container.Make2Value("E2,9", "E1,1");

                builder.WithAssertion(beanThree)
                .Expect(
                    fields,
                    beanThree.Contained[0],
                    beanThree.Contained[0],
                    null,
                    null,
                    null,
                    null);

                builder.Run(env);
            }
Beispiel #30
0
        private void RunAssertionOrderByEvents(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2,val3,val4,val5".Split(',');
            string   eplFragment = "select " +
                                   "Contained.orderBy(x => p00) as val0," +
                                   "Contained.orderBy(x => 10 - p00) as val1," +
                                   "Contained.orderBy(x => 0) as val2," +
                                   "Contained.OrderByDesc(x => p00) as val3," +
                                   "Contained.OrderByDesc(x => 10 - p00) as val4," +
                                   "Contained.OrderByDesc(x => 0) as val5" +
                                   " from Bean";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(ICollection <SupportBean_ST0>),
                typeof(ICollection <SupportBean_ST0>),
                typeof(ICollection <SupportBean_ST0>),
                typeof(ICollection <SupportBean_ST0>),
                typeof(ICollection <SupportBean_ST0>),
                typeof(ICollection <SupportBean_ST0>)
            });

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2"));
            LambdaAssertionUtil.AssertST0Id(listener, "val0", "E1,E2");
            LambdaAssertionUtil.AssertST0Id(listener, "val1", "E2,E1");
            LambdaAssertionUtil.AssertST0Id(listener, "val2", "E1,E2");
            LambdaAssertionUtil.AssertST0Id(listener, "val3", "E2,E1");
            LambdaAssertionUtil.AssertST0Id(listener, "val4", "E1,E2");
            LambdaAssertionUtil.AssertST0Id(listener, "val5", "E1,E2");
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E3,1", "E2,2", "E4,1", "E1,2"));
            LambdaAssertionUtil.AssertST0Id(listener, "val0", "E3,E4,E2,E1");
            LambdaAssertionUtil.AssertST0Id(listener, "val1", "E2,E1,E3,E4");
            LambdaAssertionUtil.AssertST0Id(listener, "val2", "E3,E2,E4,E1");
            LambdaAssertionUtil.AssertST0Id(listener, "val3", "E2,E1,E3,E4");
            LambdaAssertionUtil.AssertST0Id(listener, "val4", "E3,E4,E2,E1");
            LambdaAssertionUtil.AssertST0Id(listener, "val5", "E3,E2,E4,E1");
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            foreach (string field in fields)
            {
                LambdaAssertionUtil.AssertST0Id(listener, field, null);
            }
            listener.Reset();

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            foreach (string field in fields)
            {
                LambdaAssertionUtil.AssertST0Id(listener, field, "");
            }
            listener.Reset();

            stmtFragment.Dispose();
        }