private void RunAssertionInsertInto(EPServiceProvider epService) { string statementText = "insert into MyStream select " + "map.mapOne as val1" + " from NestedMap#length(5)"; epService.EPAdministrator.CreateEPL(statementText); statementText = "select val1 as a from MyStream"; EPStatement statement = epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; IDictionary <string, Object> testdata = GetTestData(); epService.EPRuntime.SendEvent(testdata, "NestedMap"); // test all properties exist string[] fields = "a".Split(','); EventBean received = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(received, fields, new object[] { ExecEventMap.GetNestedKeyMap(testdata, "map", "mapOne") }); epService.EPAdministrator.DestroyAllStatements(); }
private IDictionary <string, Object> GetTestDef() { IDictionary <string, Object> levelThree = ExecEventMap.MakeMap(new object[][] { new object[] { "simpleThree", typeof(long) }, new object[] { "objectThree", typeof(SupportBean_B) }, }); IDictionary <string, Object> levelTwo = ExecEventMap.MakeMap(new object[][] { new object[] { "simpleTwo", typeof(int?) }, new object[] { "objectTwo", typeof(SupportBeanCombinedProps) }, new object[] { "nodefmapTwo", typeof(Map) }, new object[] { "mapTwo", levelThree }, }); IDictionary <string, Object> levelOne = ExecEventMap.MakeMap(new object[][] { new object[] { "simpleOne", typeof(int?) }, new object[] { "objectOne", typeof(SupportBeanComplexProps) }, new object[] { "nodefmapOne", typeof(Map) }, new object[] { "mapOne", levelTwo } }); IDictionary <string, Object> levelZero = ExecEventMap.MakeMap(new object[][] { new object[] { "simple", typeof(string) }, new object[] { "object", typeof(SupportBean_A) }, new object[] { "nodefmap", typeof(Map) }, new object[] { "map", levelOne } }); return(levelZero); }
private IDictionary <string, Object> GetTestDataThree() { IDictionary <string, Object> levelThree = ExecEventMap.MakeMap(new object[][] { new object[] { "simpleThree", 4000L }, }); IDictionary <string, Object> levelTwo = ExecEventMap.MakeMap(new object[][] { new object[] { "objectTwo", SupportBeanCombinedProps.MakeDefaultBean() }, new object[] { "nodefmapTwo", ExecEventMap.MakeMap(new object[][] { new object[] { "key3", "val3" } }) }, new object[] { "mapTwo", levelThree }, }); IDictionary <string, Object> levelOne = ExecEventMap.MakeMap(new object[][] { new object[] { "simpleOne", null }, new object[] { "objectOne", null }, new object[] { "mapOne", levelTwo } }); IDictionary <string, Object> levelZero = ExecEventMap.MakeMap(new object[][] { new object[] { "simple", "abc" }, new object[] { "object", new SupportBean_A("A1") }, new object[] { "nodefmap", ExecEventMap.MakeMap(new object[][] { new object[] { "key1", "val1" } }) }, new object[] { "map", levelOne } }); return(levelZero); }
public override void Configure(Configuration configuration) { IDictionary <string, Object> type = ExecEventMap.MakeMap(new object[][] { new object[] { "base1", typeof(string) }, new object[] { "base2", ExecEventMap.MakeMap(new object[][] { new object[] { "n1", typeof(int) } }) } }); configuration.AddEventType("MyEvent", type); }
private void RunAssertionNestedPojo(EPServiceProvider epService) { string statementText = "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)"; EPStatement statement = epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; IDictionary <string, Object> testdata = GetTestData(); epService.EPRuntime.SendEvent(testdata, "NestedMap"); // test all properties exist EventBean received = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(received, "simple,object,nodefmap,map".Split(','), new object[] { "abc", new SupportBean_A("A1"), testdata.Get("nodefmap"), testdata.Get("map") }); EPAssertionUtil.AssertProps(received, "a1,a2,a3,a4".Split(','), new object[] { "A1", "val1", null, null }); EPAssertionUtil.AssertProps(received, "b1,b2,b3,b4".Split(','), new object[] { ExecEventMap.GetNestedKeyMap(testdata, "map", "objectOne"), 10, "val2", 300 }); EPAssertionUtil.AssertProps(received, "c1,c2".Split(','), new object[] { 2, "NestedValue" }); EPAssertionUtil.AssertProps(received, "d1,d2,d3".Split(','), new object[] { 300, ExecEventMap.GetNestedKeyMap(testdata, "map", "mapOne", "objectTwo"), ExecEventMap.GetNestedKeyMap(testdata, "map", "mapOne", "nodefmapTwo") }); EPAssertionUtil.AssertProps(received, "e1,e2,e3".Split(','), new object[] { ExecEventMap.GetNestedKeyMap(testdata, "map", "mapOne", "mapTwo"), 4000L, new SupportBean_B("B1") }); EPAssertionUtil.AssertProps(received, "f1,f2".Split(','), new object[] { "1ma0", "B1" }); // test partial properties exist testdata = GetTestDataThree(); epService.EPRuntime.SendEvent(testdata, "NestedMap"); received = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(received, "simple,object,nodefmap,map".Split(','), new object[] { "abc", new SupportBean_A("A1"), testdata.Get("nodefmap"), testdata.Get("map") }); EPAssertionUtil.AssertProps(received, "a1,a2,a3,a4".Split(','), new object[] { "A1", "val1", null, null }); EPAssertionUtil.AssertProps(received, "b1,b2,b3,b4".Split(','), new object[] { ExecEventMap.GetNestedKeyMap(testdata, "map", "objectOne"), null, null, null }); EPAssertionUtil.AssertProps(received, "c1,c2".Split(','), new object[] { null, null }); EPAssertionUtil.AssertProps(received, "d1,d2,d3".Split(','), new object[] { null, ExecEventMap.GetNestedKeyMap(testdata, "map", "mapOne", "objectTwo"), ExecEventMap.GetNestedKeyMap(testdata, "map", "mapOne", "nodefmapTwo") }); EPAssertionUtil.AssertProps(received, "e1,e2,e3".Split(','), new object[] { ExecEventMap.GetNestedKeyMap(testdata, "map", "mapOne", "mapTwo"), 4000L, null }); EPAssertionUtil.AssertProps(received, "f1,f2".Split(','), new object[] { "1ma0", null }); }
private void RunAssertionMappedProperty(EPServiceProvider epService) { // test map containing first-level property that is an array of primitive or .GetType() IDictionary <string, Object> mappedDef = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", typeof(Map) } }); epService.EPAdministrator.Configuration.AddEventType("MyMappedPropertyMap", mappedDef); EPStatement stmt = epService.EPAdministrator.CreateEPL("select p0('k1') as a from MyMappedPropertyMap"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var eventVal = new Dictionary <string, Object>(); eventVal.Put("k1", "v1"); IDictionary <string, Object> theEvent = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", eventVal } }); epService.EPRuntime.SendEvent(theEvent, "MyMappedPropertyMap"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a".Split(','), new object[] { "v1" }); Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("a")); stmt.Dispose(); // test map at the second level of a nested map that is an array of primitive or .GetType() IDictionary <string, Object> mappedDefOuter = ExecEventMap.MakeMap(new object[][] { new object[] { "outer", mappedDef } }); epService.EPAdministrator.Configuration.AddEventType("MyMappedPropertyMapOuter", mappedDefOuter); stmt = epService.EPAdministrator.CreateEPL("select outer.p0('k1') as a from MyMappedPropertyMapOuter"); stmt.Events += listener.Update; IDictionary <string, Object> eventOuter = ExecEventMap.MakeMap(new object[][] { new object[] { "outer", theEvent } }); epService.EPRuntime.SendEvent(eventOuter, "MyMappedPropertyMapOuter"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a".Split(','), new object[] { "v1" }); Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("a")); // test map that contains a bean which has a map property IDictionary <string, Object> mappedDefOuterTwo = ExecEventMap.MakeMap(new object[][] { new object[] { "outerTwo", typeof(SupportBeanComplexProps) } }); epService.EPAdministrator.Configuration.AddEventType("MyMappedPropertyMapOuterTwo", mappedDefOuterTwo); stmt = epService.EPAdministrator.CreateEPL("select outerTwo.MapProperty('xOne') as a from MyMappedPropertyMapOuterTwo"); stmt.Events += listener.Update; IDictionary <string, Object> eventOuterTwo = ExecEventMap.MakeMap(new object[][] { new object[] { "outerTwo", SupportBeanComplexProps.MakeDefaultBean() } }); epService.EPRuntime.SendEvent(eventOuterTwo, "MyMappedPropertyMapOuterTwo"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a".Split(','), new object[] { "yOne" }); Assert.AreEqual(typeof(string), stmt.EventType.GetPropertyType("a")); stmt.Dispose(); }
public override void Configure(Configuration configuration) { IDictionary <string, Object> definition = ExecEventMap.MakeMap(new object[][] { new object[] { "a.b", typeof(int) }, new object[] { "a.b.c", typeof(int) }, new object[] { "nes.", typeof(int) }, new object[] { "nes.nes2", ExecEventMap.MakeMap(new object[][] { new object[] { "x.y", typeof(int) } }) } }); configuration.AddEventType("DotMap", definition); }
public override void Run(EPServiceProvider epService) { #if NOT_VALID_TEST var invalid = ExecEventMap.MakeMap(new object[][] { new object[] { new SupportBean(), null } }); TryInvalid(epService, invalid, typeof(SupportBean).FullName + " cannot be cast to System.String"); invalid = ExecEventMap.MakeMap(new object[][] { new object[] { "abc", new SupportBean() } }); TryInvalid(epService, invalid, "Nestable type configuration encountered an unexpected property type of 'SupportBean' for property 'abc', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type"); #endif }
private void RunAssertionsMapNamePropertyNested(EPServiceProvider epService) { // create a named map IDictionary <string, Object> namedDef = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", typeof(int) } }); epService.EPAdministrator.Configuration.AddEventType("MyNamedMap", namedDef); // create a map using the name IDictionary <string, Object> eventDef = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", "MyNamedMap" }, new object[] { "p1", "MyNamedMap[]" } }); epService.EPAdministrator.Configuration.AddEventType("MyMapWithAMap", eventDef); // test named-map at the second level of a nested map IDictionary <string, Object> arrayDefOuter = ExecEventMap.MakeMap(new object[][] { new object[] { "outer", eventDef } }); epService.EPAdministrator.Configuration.AddEventType("MyArrayMapTwo", arrayDefOuter); var listener = new SupportUpdateListener(); EPStatement stmt = epService.EPAdministrator.CreateEPL("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"); stmt.Events += listener.Update; IDictionary <string, Object> n0_1 = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", 1 } }); IDictionary <string, Object> n0_21 = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", 2 } }); IDictionary <string, Object> n0_22 = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", 3 } }); var n0_2 = new Map[] { n0_21, n0_22 }; IDictionary <string, Object> theEvent = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", n0_1 }, new object[] { "p1", n0_2 } }); IDictionary <string, Object> eventOuter = ExecEventMap.MakeMap(new object[][] { new object[] { "outer", theEvent } }); epService.EPRuntime.SendEvent(eventOuter, "MyArrayMapTwo"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a,b,c,d,e".Split(','), new object[] { 1, 2, 3, n0_1, n0_2 }); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("a")); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("b")); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("c")); Assert.AreEqual(typeof(Map), stmt.EventType.GetPropertyType("d")); Assert.AreEqual(typeof(Map[]), stmt.EventType.GetPropertyType("e")); stmt.Dispose(); stmt = epService.EPAdministrator.CreateEPL("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"); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(eventOuter, "MyArrayMapTwo"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a,b,c,d,e".Split(','), new object[] { 1, 2, 3, n0_1, n0_2 }); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("a")); stmt.Dispose(); }
public override void Run(EPServiceProvider epService) { IDictionary <string, Object> root = ExecEventMap.MakeMap(new object[][] { new object[] { "base", typeof(string) } }); IDictionary <string, Object> sub1 = ExecEventMap.MakeMap(new object[][] { new object[] { "sub1", typeof(string) } }); IDictionary <string, Object> sub2 = ExecEventMap.MakeMap(new object[][] { new object[] { "sub2", typeof(string) } }); IDictionary <string, Object> suba = ExecEventMap.MakeMap(new object[][] { new object[] { "suba", typeof(string) } }); IDictionary <string, Object> subb = ExecEventMap.MakeMap(new object[][] { new object[] { "subb", typeof(string) } }); epService.EPAdministrator.Configuration.AddEventType("RootEvent", root); epService.EPAdministrator.Configuration.AddEventType("Sub1Event", sub1, new string[] { "RootEvent" }); epService.EPAdministrator.Configuration.AddEventType("Sub2Event", sub2, new string[] { "RootEvent" }); epService.EPAdministrator.Configuration.AddEventType("SubAEvent", suba, new string[] { "Sub1Event" }); epService.EPAdministrator.Configuration.AddEventType("SubBEvent", subb, new string[] { "Sub1Event", "Sub2Event" }); ExecEventMapInheritanceInitTime.RunAssertionMapInheritance(epService); }
private void RunAssertionArrayProperty(EPServiceProvider epService) { // test map containing first-level property that is an array of primitive or .GetType() IDictionary <string, Object> arrayDef = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", typeof(int[]) }, new object[] { "p1", typeof(SupportBean[]) } }); epService.EPAdministrator.Configuration.AddEventType("MyArrayMap", arrayDef); EPStatement stmt = epService.EPAdministrator.CreateEPL("select p0[0] as a, p0[1] as b, p1[0].IntPrimitive as c, p1[1] as d, p0 as e from MyArrayMap"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var p0 = new int[] { 1, 2, 3 }; var beans = new SupportBean[] { new SupportBean("e1", 5), new SupportBean("e2", 6) }; IDictionary <string, Object> theEvent = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", p0 }, new object[] { "p1", beans } }); epService.EPRuntime.SendEvent(theEvent, "MyArrayMap"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a,b,c,d,e".Split(','), new object[] { 1, 2, 5, beans[1], p0 }); Assert.AreEqual(typeof(int), stmt.EventType.GetPropertyType("a")); Assert.AreEqual(typeof(int), stmt.EventType.GetPropertyType("b")); Assert.AreEqual(typeof(int), stmt.EventType.GetPropertyType("c")); Assert.AreEqual(typeof(SupportBean), stmt.EventType.GetPropertyType("d")); Assert.AreEqual(typeof(int[]), stmt.EventType.GetPropertyType("e")); stmt.Dispose(); // test map at the second level of a nested map that is an array of primitive or .GetType() IDictionary <string, Object> arrayDefOuter = ExecEventMap.MakeMap(new object[][] { new object[] { "outer", arrayDef } }); epService.EPAdministrator.Configuration.AddEventType("MyArrayMapOuter", arrayDefOuter); stmt = epService.EPAdministrator.CreateEPL("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"); stmt.Events += listener.Update; IDictionary <string, Object> eventOuter = ExecEventMap.MakeMap(new object[][] { new object[] { "outer", theEvent } }); epService.EPRuntime.SendEvent(eventOuter, "MyArrayMapOuter"); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a,b,c,d".Split(','), new object[] { 1, 2, 5, beans[1] }); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("a")); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("b")); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType("c")); Assert.AreEqual(typeof(SupportBean), stmt.EventType.GetPropertyType("d")); Assert.AreEqual(typeof(int[]), stmt.EventType.GetPropertyType("e")); stmt.Dispose(); }
public override void Run(EPServiceProvider epService) { IDictionary <string, Object> levelOne1 = ExecEventMap.MakeMap(new object[][] { new object[] { "simpleOne", typeof(int?) } }); IDictionary <string, Object> levelOne2 = ExecEventMap.MakeMap(new object[][] { new object[] { "simpleOne", typeof(long) } }); IDictionary <string, Object> levelZero1 = ExecEventMap.MakeMap(new object[][] { new object[] { "map", levelOne1 } }); IDictionary <string, Object> levelZero2 = ExecEventMap.MakeMap(new object[][] { new object[] { "map", levelOne2 } }); // can add the same nested type twice epService.EPAdministrator.Configuration.AddEventType("ABC", levelZero1); epService.EPAdministrator.Configuration.AddEventType("ABC", levelZero1); try { // changing the definition however stops the compatibility epService.EPAdministrator.Configuration.AddEventType("ABC", levelZero2); Assert.Fail(); } catch (ConfigurationException) { // expected } }
public override void Configure(Configuration configuration) { IDictionary <string, Object> root = ExecEventMap.MakeMap(new object[][] { new object[] { "base", typeof(string) } }); IDictionary <string, Object> sub1 = ExecEventMap.MakeMap(new object[][] { new object[] { "sub1", typeof(string) } }); IDictionary <string, Object> sub2 = ExecEventMap.MakeMap(new object[][] { new object[] { "sub2", typeof(string) } }); Properties suba = ExecEventMap.MakeProperties(new object[][] { new object[] { "suba", typeof(string) } }); IDictionary <string, Object> subb = ExecEventMap.MakeMap(new object[][] { new object[] { "subb", typeof(string) } }); configuration.AddEventType("RootEvent", root); configuration.AddEventType("Sub1Event", sub1); configuration.AddEventType("Sub2Event", sub2); configuration.AddEventType("SubAEvent", suba); configuration.AddEventType("SubBEvent", subb); configuration.AddMapSuperType("Sub1Event", "RootEvent"); configuration.AddMapSuperType("Sub2Event", "RootEvent"); configuration.AddMapSuperType("SubAEvent", "Sub1Event"); configuration.AddMapSuperType("SubBEvent", "Sub1Event"); configuration.AddMapSuperType("SubBEvent", "Sub2Event"); }
public override void Run(EPServiceProvider epService) { string statementText = "select a\\.b, a\\.b\\.c, nes\\., nes\\.nes2.x\\.y from DotMap"; EPStatement statement = epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; IDictionary <string, Object> data = ExecEventMap.MakeMap(new object[][] { new object[] { "a.b", 10 }, new object[] { "a.b.c", 20 }, new object[] { "nes.", 30 }, new object[] { "nes.nes2", ExecEventMap.MakeMap(new object[][] { new object[] { "x.y", 40 } }) } }); epService.EPRuntime.SendEvent(data, "DotMap"); string[] fields = "a.b,a.b.c,nes.,nes.nes2.x.y".Split(','); EventBean received = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(received, fields, new object[] { 10, 20, 30, 40 }); }
private void RunAssertionMapNameProperty(EPServiceProvider epService) { // create a named map IDictionary <string, Object> namedDef = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", typeof(int) } }); epService.EPAdministrator.Configuration.AddEventType("MyNamedMap", namedDef); // create a map using the name IDictionary <string, Object> eventDef = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", "MyNamedMap" }, new object[] { "p1", "MyNamedMap[]" } }); epService.EPAdministrator.Configuration.AddEventType("MyMapWithAMap", eventDef); EPStatement stmt = epService.EPAdministrator.CreateEPL("select p0.n0 as a, p1[0].n0 as b, p1[1].n0 as c, p0 as d, p1 as e from MyMapWithAMap"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; IDictionary <string, Object> n0_1 = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", 1 } }); IDictionary <string, Object> n0_21 = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", 2 } }); IDictionary <string, Object> n0_22 = ExecEventMap.MakeMap(new object[][] { new object[] { "n0", 3 } }); var n0_2 = new Map[] { n0_21, n0_22 }; IDictionary <string, Object> theEvent = ExecEventMap.MakeMap(new object[][] { new object[] { "p0", n0_1 }, new object[] { "p1", n0_2 } }); epService.EPRuntime.SendEvent(theEvent, "MyMapWithAMap"); EventBean eventResult = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(eventResult, "a,b,c,d".Split(','), new object[] { 1, 2, 3, n0_1 }); Map[] valueE = (Map[])eventResult.Get("e"); Assert.AreEqual(valueE[0], n0_2[0]); Assert.AreEqual(valueE[1], n0_2[1]); Assert.AreEqual(typeof(int), stmt.EventType.GetPropertyType("a")); Assert.AreEqual(typeof(int), stmt.EventType.GetPropertyType("b")); Assert.AreEqual(typeof(int), stmt.EventType.GetPropertyType("c")); Assert.AreEqual(typeof(Map), stmt.EventType.GetPropertyType("d")); Assert.AreEqual(typeof(Map[]), stmt.EventType.GetPropertyType("e")); }
public override void Run(EPServiceProvider epService) { EPStatement statementOne = epService.EPAdministrator.CreateEPL( "select base1 as v1, base2.n1 as v2, base3? as v3, base2.n2? as v4 from MyEvent"); EPStatement statementOneSelectAll = epService.EPAdministrator.CreateEPL("select * from MyEvent"); Assert.AreEqual("[base1, base2]", CompatExtensions.Render(statementOneSelectAll.EventType.PropertyNames)); var listenerOne = new SupportUpdateListener(); statementOne.Events += listenerOne.Update; string[] fields = "v1,v2,v3,v4".Split(','); epService.EPRuntime.SendEvent(ExecEventMap.MakeMap(new object[][] { new object[] { "base1", "abc" }, new object[] { "base2", ExecEventMap.MakeMap(new object[][] { new object[] { "n1", 10 } }) } }), "MyEvent"); EPAssertionUtil.AssertProps(listenerOne.AssertOneGetNewAndReset(), fields, new object[] { "abc", 10, null, null }); // update type IDictionary <string, Object> typeNew = ExecEventMap.MakeMap(new object[][] { new object[] { "base3", typeof(long) }, new object[] { "base2", ExecEventMap.MakeMap(new object[][] { new object[] { "n2", typeof(string) } }) } }); epService.EPAdministrator.Configuration.UpdateMapEventType("MyEvent", typeNew); EPStatement statementTwo = epService.EPAdministrator.CreateEPL("select base1 as v1, base2.n1 as v2, base3 as v3, base2.n2 as v4 from MyEvent"); EPStatement statementTwoSelectAll = epService.EPAdministrator.CreateEPL("select * from MyEvent"); var listenerTwo = new SupportUpdateListener(); statementTwo.Events += listenerTwo.Update; epService.EPRuntime.SendEvent(ExecEventMap.MakeMap(new object[][] { new object[] { "base1", "def" }, new object[] { "base2", ExecEventMap.MakeMap(new object[][] { new object[] { "n1", 9 }, new object[] { "n2", "xyz" } }) }, new object[] { "base3", 20L }, }), "MyEvent"); EPAssertionUtil.AssertProps(listenerOne.AssertOneGetNewAndReset(), fields, new object[] { "def", 9, 20L, "xyz" }); EPAssertionUtil.AssertProps(listenerTwo.AssertOneGetNewAndReset(), fields, new object[] { "def", 9, 20L, "xyz" }); // assert event type Assert.AreEqual("[base1, base2, base3]", CompatExtensions.Render(statementOneSelectAll.EventType.PropertyNames)); Assert.AreEqual("[base1, base2, base3]", CompatExtensions.Render(statementTwoSelectAll.EventType.PropertyNames)); EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] { new EventPropertyDescriptor("base3", typeof(long), null, false, false, false, false, false), new EventPropertyDescriptor("base2", typeof(IDictionary <string, object>), null, false, false, false, true, false), new EventPropertyDescriptor("base1", typeof(string), typeof(char), false, false, true, false, false), }, statementTwoSelectAll.EventType.PropertyDescriptors); try { epService.EPAdministrator.Configuration.UpdateMapEventType("dummy", typeNew); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual("Error updating Map event type: Event type named 'dummy' has not been declared", ex.Message); } epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); try { epService.EPAdministrator.Configuration.UpdateMapEventType("SupportBean", typeNew); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual("Error updating Map event type: Event type by name 'SupportBean' is not a Map event type", ex.Message); } }
internal static void RunAssertionMapInheritance(EPServiceProvider epService) { 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 (int i = 0; i < statements.Length; i++) { EPStatement statement = epService.EPAdministrator.CreateEPL(statements[i]); listeners[i] = new SupportUpdateListener(); statement.Events += listeners[i].Update; } string[] fields = "vbase,v1,v2,va,vb".Split(','); epService.EPRuntime.SendEvent(ExecEventMap.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" }); epService.EPRuntime.SendEvent(ExecEventMap.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" }); epService.EPRuntime.SendEvent(ExecEventMap.MakeMap("base=XBASE,sub1=X1,sub2=X2,subb=XY"), "SubBEvent"); var values = new object[] { "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); epService.EPRuntime.SendEvent(ExecEventMap.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); epService.EPRuntime.SendEvent(ExecEventMap.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); epService.EPRuntime.SendEvent(ExecEventMap.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 try { epService.EPAdministrator.CreateEPL("select suba from Sub1Event"); Assert.Fail(); } catch (EPStatementException ex) { Assert.AreEqual("Error starting statement: Failed to validate select-clause expression 'suba': Property named 'suba' is not valid in any stream (did you mean 'sub1'?) [select suba from Sub1Event]", ex.Message); } // try supertype not Exists try { epService.EPAdministrator.Configuration.AddEventType("Sub1Event", ExecEventMap.MakeMap(""), new string[] { "doodle" }); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual("Supertype by name 'doodle' could not be found", ex.Message); } }