Beispiel #1
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy("@Name('s0') select P0('k1') as a from MyMappedPropertyMap");
                env.AddListener("s0");

                IDictionary<string, object> eventVal = new Dictionary<string, object>();
                eventVal.Put("k1", "v1");
                var theEvent = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"P0", eventVal}
                    });
                env.SendEventMap(theEvent, "MyMappedPropertyMap");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a" },
                    new object[] {"v1"});
                Assert.AreEqual(typeof(object), env.Statement("s0").EventType.GetPropertyType("a"));
                env.UndeployAll();

                env.CompileDeploy("@Name('s0') select outer.P0('k1') as a from MyMappedPropertyMapOuter");
                env.AddListener("s0");

                var eventOuter = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"outer", theEvent}
                    });
                env.SendEventMap(eventOuter, "MyMappedPropertyMapOuter");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a" },
                    new object[] {"v1"});
                Assert.AreEqual(typeof(object), env.Statement("s0").EventType.GetPropertyType("a"));
                env.UndeployModuleContaining("s0");

                // test map that contains a bean which has a map property
                env.CompileDeploy(
                    "@Name('s0') select outerTwo.MapProperty('xOne') as a from MyMappedPropertyMapOuterTwo");
                env.AddListener("s0");

                var eventOuterTwo = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"outerTwo", SupportBeanComplexProps.MakeDefaultBean()}
                    });
                env.SendEventMap(eventOuterTwo, "MyMappedPropertyMapOuterTwo");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a" },
                    new object[] {"yOne"});
                Assert.AreEqual(typeof(object), env.Statement("s0").EventType.GetPropertyType("a"));

                env.UndeployAll();
            }
Beispiel #2
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('s0') select outer.P0.n0 as a, outer.P1[0].n0 as b, outer.P1[1].n0 as c, outer.P0 as d, outer.P1 as e from MyArrayMapTwo");
                env.AddListener("s0");

                var n0Bean1 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 1}
                    });
                var n0Bean21 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 2}
                    });
                var n0Bean22 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 3}
                    });
                IDictionary<string, object>[] n0Bean2 = {n0Bean21, n0Bean22};
                var theEvent = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"P0", n0Bean1}, new object[] {"P1", n0Bean2}
                    });
                var eventOuter = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"outer", theEvent}
                    });
                env.SendEventMap(eventOuter, "MyArrayMapTwo");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 3, n0Bean1, n0Bean2});
                var eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(IDictionary<string, object>), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(IDictionary<string, object>[]), eventType.GetPropertyType("e"));

                env.UndeployAll();
                env.CompileDeploy(
                    "@Name('s0') select outer.P0.n0? as a, outer.P1[0].n0? as b, outer.P1[1]?.n0 as c, outer.P0? as d, outer.P1? as e from MyArrayMapTwo");
                env.AddListener("s0");

                env.SendEventMap(eventOuter, "MyArrayMapTwo");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 3, n0Bean1, n0Bean2});
                Assert.AreEqual(typeof(int?), env.Statement("s0").EventType.GetPropertyType("a"));

                env.UndeployAll();
            }
Beispiel #3
0
        private static IDictionary<string, object> GetTestData()
        {
            var levelThree = EventMapCore.MakeMap(
                new[] {
                    new object[] {"simpleThree", 4000L},
                    new object[] {"objectThree", new SupportBean_B("B1")}
                });

            var levelTwo = EventMapCore.MakeMap(
                new[] {
                    new object[] {"simpleTwo", 300},
                    new object[] {"objectTwo", SupportBeanCombinedProps.MakeDefaultBean()},
                    new object[] {
                        "nodefmapTwo", EventMapCore.MakeMap(
                            new[] {
                                new object[] {"key3", "val3"}
                            })
                    },
                    new object[] {"mapTwo", levelThree}
                });

            var levelOne = EventMapCore.MakeMap(
                new[] {
                    new object[] {"simpleOne", 10},
                    new object[] {"objectOne", SupportBeanComplexProps.MakeDefaultBean()},
                    new object[] {
                        "nodefmapOne", EventMapCore.MakeMap(
                            new[] {
                                new object[] {"key2", "val2"}
                            })
                    },
                    new object[] {"mapOne", levelTwo}
                });

            var levelZero = EventMapCore.MakeMap(
                new[] {
                    new object[] {"simple", "abc"},
                    new object[] {"object", new SupportBean_A("A1")},
                    new object[] {
                        "nodefmap", EventMapCore.MakeMap(
                            new[] {
                                new object[] {"key1", "val1"}
                            })
                    },
                    new object[] {"map", levelOne}
                });

            return levelZero;
        }
Beispiel #4
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('s0') select P0[0] as a, P0[1] as b, P1[0].IntPrimitive as c, P1[1] as d, P0 as e from MyArrayMap");
                env.AddListener("s0");

                int[] p0 = {1, 2, 3};
                SupportBean[] beans = {new SupportBean("e1", 5), new SupportBean("e2", 6)};
                var theEvent = EventMapCore.MakeMap(new[] {new object[] { "P0", p0}, new object[] {"P1", beans}});
                env.SendEventMap(theEvent, "MyArrayMap");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d","e" },
                    new object[] {1, 2, 5, beans[1], p0});
                var eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(SupportBean), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("e"));
                env.UndeployAll();

                env.CompileDeploy(
                    "@Name('s0') select" +
                    " outer.P0[0] as a," +
                    " outer.P0[1] as b," +
                    " outer.P1[0].IntPrimitive as c," +
                    " outer.P1[1] as d," +
                    " outer.P0 as e" +
                    " from MyArrayMapOuter");
                env.AddListener("s0");

                var eventOuter = EventMapCore.MakeMap(new[] {new object[] {"outer", theEvent}});
                env.SendEventMap(eventOuter, "MyArrayMapOuter");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "a","b","c","d" },
                    new object[] {1, 2, 5, beans[1]});
                eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(SupportBean), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("e"));

                env.UndeployAll();
            }
Beispiel #5
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('s0') select P0.n0 as a, P1[0].n0 as b, P1[1].n0 as c, P0 as d, P1 as e from MyMapWithAMap");
                env.AddListener("s0");

                var n0Bean1 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 1}
                    });
                var n0Bean21 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 2}
                    });
                var n0Bean22 = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"n0", 3}
                    });
                IDictionary<string, object>[] n0Bean2 = {n0Bean21, n0Bean22};
                var theEvent = EventMapCore.MakeMap(
                    new[] {
                        new object[] {"P0", n0Bean1}, new object[] {"P1", n0Bean2}
                    });
                env.SendEventMap(theEvent, "MyMapWithAMap");

                var eventResult = env.Listener("s0").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    eventResult,
                    new [] { "a","b","c","d" },
                    new object[] {1, 2, 3, n0Bean1});
                var valueE = (IDictionary<string, object>[]) eventResult.Get("e");
                Assert.AreEqual(valueE[0], n0Bean2[0]);
                Assert.AreEqual(valueE[1], n0Bean2[1]);

                var eventType = env.Statement("s0").EventType;
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("a"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("b"));
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType("c"));
                Assert.AreEqual(typeof(IDictionary<string, object>), eventType.GetPropertyType("d"));
                Assert.AreEqual(typeof(IDictionary<string, object>[]), eventType.GetPropertyType("e"));

                env.UndeployAll();
            }
Beispiel #6
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var statementText = "insert into MyStream select map.mapOne as val1 from NestedMap#length(5)";
                env.CompileDeploy(statementText, path);

                statementText = "@Name('s0') select val1 as a from MyStream";
                env.CompileDeploy(statementText, path).AddListener("s0");

                var testdata = GetTestData();
                env.SendEventMap(testdata, "NestedMap");

                // test all properties exist
                var fields = new [] { "a" };
                var received = env.Listener("s0").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    received,
                    fields,
                    new[] {EventMapCore.GetNestedKeyMap(testdata, "map", "mapOne")});

                env.UndeployAll();
            }
        public void Run(RegressionEnvironment env)
        {
            var statementText = "@Name('s0') select a\\.b, a\\.b\\.c, nes\\., nes\\.nes2.x\\.y from DotMap";
            env.CompileDeploy(statementText).AddListener("s0");

            var data = EventMapCore.MakeMap(
                new[] {
                    new object[] {"a.b", 10},
                    new object[] {"a.b.c", 20},
                    new object[] {"nes.", 30},
                    new object[] {"nes.nes2", EventMapCore.MakeMap(new[] {new object[] {"x.y", 40}})}
                });
            env.SendEventMap(data, "DotMap");

            var fields = new [] { "a.b","a.b.c","nes.","nes.nes2.x.y" };
            var received = env.Listener("s0").AssertOneGetNewAndReset();
            EPAssertionUtil.AssertProps(
                received,
                fields,
                new object[] {10, 20, 30, 40});

            env.UndeployAll();
        }
Beispiel #8
0
            public void Run(RegressionEnvironment env)
            {
                var statementText = "@Name('s0') select " +
                                    "simple, object, " +
                                    "nodefmap, " +
                                    "map, " +
                                    "object.Id as a1, " +
                                    "nodefmap.key1? as a2, " +
                                    "nodefmap.key2? as a3, " +
                                    "nodefmap.key3?.key4 as a4, " +
                                    "map.objectOne as b1, " +
                                    "map.simpleOne as b2, " +
                                    "map.nodefmapOne.key2? as b3, " +
                                    "map.mapOne.simpleTwo? as b4, " +
                                    "map.objectOne.Indexed[1] as c1, " +
                                    "map.objectOne.Nested.NestedValue as c2," +
                                    "map.mapOne.simpleTwo as d1, " +
                                    "map.mapOne.objectTwo as d2, " +
                                    "map.mapOne.nodefmapTwo as d3, " +
                                    "map.mapOne.mapTwo as e1, " +
                                    "map.mapOne.mapTwo.simpleThree as e2, " +
                                    "map.mapOne.mapTwo.objectThree as e3, " +
                                    "map.mapOne.objectTwo.Array[1].Mapped('1ma').Value as f1, " +
                                    "map.mapOne.mapTwo.objectThree.Id as f2" +
                                    " from NestedMap#length(5)";
                env.CompileDeploy(statementText).AddListener("s0");

                var testdata = GetTestData();
                env.SendEventMap(testdata, "NestedMap");

                // test all properties exist
                var received = env.Listener("s0").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "simple","object","nodefmap","map" },
                    new[] {"abc", new SupportBean_A("A1"), testdata.Get("nodefmap"), testdata.Get("map")});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "a1","a2","a3","a4" },
                    new object[] {"A1", "val1", null, null});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "b1","b2","b3","b4" },
                    new[] {EventMapCore.GetNestedKeyMap(testdata, "map", "objectOne"), 10, "val2", 300});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "c1","c2" },
                    new object[] {2, "NestedValue"});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "d1","d2","d3" },
                    new[] {
                        300, EventMapCore.GetNestedKeyMap(testdata, "map", "mapOne", "objectTwo"),
                        EventMapCore.GetNestedKeyMap(testdata, "map", "mapOne", "nodefmapTwo")
                    });
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "e1","e2","e3" },
                    new[] {
                        EventMapCore.GetNestedKeyMap(testdata, "map", "mapOne", "mapTwo"), 4000L,
                        new SupportBean_B("B1")
                    });
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "f1","f2" },
                    new object[] {"1ma0", "B1"});

                // test partial properties exist
                testdata = GetTestDataThree();
                env.SendEventMap(testdata, "NestedMap");

                received = env.Listener("s0").AssertOneGetNewAndReset();
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "simple","object","nodefmap","map" },
                    new[] {"abc", new SupportBean_A("A1"), testdata.Get("nodefmap"), testdata.Get("map")});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "a1","a2","a3","a4" },
                    new object[] {"A1", "val1", null, null});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "b1","b2","b3","b4" },
                    new[] {EventMapCore.GetNestedKeyMap(testdata, "map", "objectOne"), null, null, null});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "c1","c2" },
                    new object[] {null, null});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "d1","d2","d3" },
                    new[] {
                        null, EventMapCore.GetNestedKeyMap(testdata, "map", "mapOne", "objectTwo"),
                        EventMapCore.GetNestedKeyMap(testdata, "map", "mapOne", "nodefmapTwo")
                    });
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "e1","e2","e3" },
                    new[] {EventMapCore.GetNestedKeyMap(testdata, "map", "mapOne", "mapTwo"), 4000L, null});
                EPAssertionUtil.AssertProps(
                    received,
                    new [] { "f1","f2" },
                    new object[] {"1ma0", null});

                env.UndeployAll();
            }
        internal static void RunAssertionMapInheritance(
            RegressionEnvironment env,
            RegressionPath path)
        {
            var listeners = new SupportUpdateListener[5];
            string[] statements = {
                "select base as vbase, sub1? as v1, sub2? as v2, suba? as va, subb? as vb from RootEvent", // 0
                "select base as vbase, sub1 as v1, sub2? as v2, suba? as va, subb? as vb from Sub1Event", // 1
                "select base as vbase, sub1? as v1, sub2 as v2, suba? as va, subb? as vb from Sub2Event", // 2
                "select base as vbase, sub1 as v1, sub2? as v2, suba as va, subb? as vb from SubAEvent", // 3
                "select base as vbase, sub1? as v1, sub2 as v2, suba? as va, subb as vb from SubBEvent" // 4
            };
            for (var i = 0; i < statements.Length; i++) {
                env.CompileDeploy("@Name('s" + i + "') " + statements[i], path);
                listeners[i] = new SupportUpdateListener();
                env.Statement("s" + i).AddListener(listeners[i]);
            }

            var fields = new [] { "vbase","v1","v2","va","vb" };

            env.SendEventMap(EventMapCore.MakeMap("base=a,sub1=b,sub2=x,suba=c,subb=y"), "SubAEvent");
            EPAssertionUtil.AssertProps(
                listeners[0].AssertOneGetNewAndReset(),
                fields,
                new object[] {"a", "b", "x", "c", "y"});
            Assert.IsFalse(listeners[2].IsInvoked || listeners[4].IsInvoked);
            EPAssertionUtil.AssertProps(
                listeners[1].AssertOneGetNewAndReset(),
                fields,
                new object[] {"a", "b", "x", "c", "y"});
            EPAssertionUtil.AssertProps(
                listeners[3].AssertOneGetNewAndReset(),
                fields,
                new object[] {"a", "b", "x", "c", "y"});

            env.SendEventMap(EventMapCore.MakeMap("base=f1,sub1=f2,sub2=f3,suba=f4,subb=f5"), "SubAEvent");
            EPAssertionUtil.AssertProps(
                listeners[0].AssertOneGetNewAndReset(),
                fields,
                new object[] {"f1", "f2", "f3", "f4", "f5"});
            Assert.IsFalse(listeners[2].IsInvoked || listeners[4].IsInvoked);
            EPAssertionUtil.AssertProps(
                listeners[1].AssertOneGetNewAndReset(),
                fields,
                new object[] {"f1", "f2", "f3", "f4", "f5"});
            EPAssertionUtil.AssertProps(
                listeners[3].AssertOneGetNewAndReset(),
                fields,
                new object[] {"f1", "f2", "f3", "f4", "f5"});

            env.SendEventMap(EventMapCore.MakeMap("base=XBASE,sub1=X1,sub2=X2,subb=XY"), "SubBEvent");
            object[] values = {"XBASE", "X1", "X2", null, "XY"};
            EPAssertionUtil.AssertProps(listeners[0].AssertOneGetNewAndReset(), fields, values);
            Assert.IsFalse(listeners[3].IsInvoked);
            EPAssertionUtil.AssertProps(listeners[1].AssertOneGetNewAndReset(), fields, values);
            EPAssertionUtil.AssertProps(listeners[2].AssertOneGetNewAndReset(), fields, values);
            EPAssertionUtil.AssertProps(listeners[4].AssertOneGetNewAndReset(), fields, values);

            env.SendEventMap(EventMapCore.MakeMap("base=YBASE,sub1=Y1"), "Sub1Event");
            values = new object[] {"YBASE", "Y1", null, null, null};
            EPAssertionUtil.AssertProps(listeners[0].AssertOneGetNewAndReset(), fields, values);
            Assert.IsFalse(listeners[2].IsInvoked || listeners[3].IsInvoked || listeners[4].IsInvoked);
            EPAssertionUtil.AssertProps(listeners[1].AssertOneGetNewAndReset(), fields, values);

            env.SendEventMap(EventMapCore.MakeMap("base=YBASE,sub2=Y2"), "Sub2Event");
            values = new object[] {"YBASE", null, "Y2", null, null};
            EPAssertionUtil.AssertProps(listeners[0].AssertOneGetNewAndReset(), fields, values);
            Assert.IsFalse(listeners[1].IsInvoked || listeners[3].IsInvoked || listeners[4].IsInvoked);
            EPAssertionUtil.AssertProps(listeners[2].AssertOneGetNewAndReset(), fields, values);

            env.SendEventMap(EventMapCore.MakeMap("base=ZBASE"), "RootEvent");
            values = new object[] {"ZBASE", null, null, null, null};
            EPAssertionUtil.AssertProps(listeners[0].AssertOneGetNewAndReset(), fields, values);
            Assert.IsFalse(
                listeners[1].IsInvoked || listeners[2].IsInvoked || listeners[3].IsInvoked || listeners[4].IsInvoked);

            // try property not available
            TryInvalidCompile(
                env,
                path,
                "select suba from Sub1Event",
                "Failed to validate select-clause expression 'suba': Property named 'suba' is not valid in any stream (did you mean 'sub1'?) [select suba from Sub1Event]");

            env.UndeployAll();
        }