public void RunAssertionFragment(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema InnerSchema as (key string)"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema MySchema as (inside InnerSchema, insidearr InnerSchema[])"); var fields = new String[] { "t0", "t1" }; String stmtText = eventRepresentationEnum.GetAnnotationText() + " select Typeof(s0.inside) as t0, Typeof(s0.insidearr) as t1 from MySchema as s0"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.Events += _listener.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[2], "MySchema"); } else { _epService.EPRuntime.SendEvent(new Dictionary <String, Object>(), "MySchema"); } EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, null }); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { new Object[2], null }, "MySchema"); } else { var theEvent = new Dictionary <String, Object>(); theEvent["inside"] = new Dictionary <String, Object>(); _epService.EPRuntime.SendEvent(theEvent, "MySchema"); } EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "InnerSchema", null }); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { null, new Object[2][] }, "MySchema"); } else { var theEvent = new Dictionary <String, Object>(); theEvent["insidearr"] = new IDictionary <string, object> [0]; _epService.EPRuntime.SendEvent(theEvent, "MySchema"); } EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { null, "InnerSchema[]" }); _epService.EPAdministrator.DestroyAllStatements(); _epService.EPAdministrator.Configuration.RemoveEventType("InnerSchema", true); _epService.EPAdministrator.Configuration.RemoveEventType("MySchema", true); }
public void RunAssertionEventTypeColumnDef(EventRepresentationEnum eventRepresentationEnum) { var stmtSchema = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema SchemaOne(col1 int, col2 int)"); Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtSchema.EventType.UnderlyingType); var stmt = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window SchemaWindow.std:lastevent() as (s1 SchemaOne)"); Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType); stmt.AddListener(_listenerWindow); _epService.EPAdministrator.CreateEPL("insert into SchemaWindow (s1) select sone from SchemaOne as sone"); IDictionary <String, object> theEvent = new LinkedHashMap <string, object>(); theEvent.Put("col1", 10); theEvent.Put("col2", 11); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), "SchemaOne"); } else { _epService.EPRuntime.SendEvent(theEvent, "SchemaOne"); } EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), "s1.col1,s1.col2".Split(','), new object[] { 10, 11 }); _epService.EPAdministrator.DestroyAllStatements(); _epService.EPAdministrator.Configuration.RemoveEventType("SchemaOne", true); _epService.EPAdministrator.Configuration.RemoveEventType("SchemaWindow", true); }
public void RunAssertionCreateSchemaModelAfter(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema EventTypeOne (hsi int)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema EventTypeTwo (event EventTypeOne)"); var stmt = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window NamedWindow.std:unique(event.hsi) as EventTypeTwo"); _epService.EPAdministrator.CreateEPL("on EventTypeOne as ev insert into NamedWindow select ev as event"); IDictionary <String, object> theEvent = new LinkedHashMap <string, object>(); theEvent.Put("hsi", 10); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), "EventTypeOne"); } else { _epService.EPRuntime.SendEvent(theEvent, "EventTypeOne"); } var result = stmt.First(); var getter = result.EventType.GetGetter("event.hsi"); Assert.AreEqual(10, getter.Get(result)); _epService.Initialize(); }
public void RunAssertionSplitPremptiveNamedWindow(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema TypeTwo(col2 int)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema TypeTrigger(trigger int)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window WinTwo.win:keepall() as TypeTwo"); var stmtOrigText = "on TypeTrigger " + "insert into OtherStream select 1 " + "insert into WinTwo(col2) select 2 " + "output all"; _epService.EPAdministrator.CreateEPL(stmtOrigText); var stmt = _epService.EPAdministrator.CreateEPL("on OtherStream select col2 from WinTwo"); stmt.Events += _listener.Update; // populate WinOne _epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); // fire trigger if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.GetEventSender("TypeTrigger").SendEvent(new Object[] { null }); } else { _epService.EPRuntime.GetEventSender("TypeTrigger").SendEvent(new DataMapImpl()); } Assert.AreEqual(2, _listener.AssertOneGetNewAndReset().Get("col2")); _epService.Initialize(); }
public void RunAssertionDispatchBackQueue(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema StartValueEvent as (dummy string)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema TestForwardEvent as (prop1 string)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema TestInputEvent as (dummy string)"); _epService.EPAdministrator.CreateEPL("insert into TestForwardEvent select'V1' as prop1 from TestInputEvent"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window NamedWin.std:unique(prop1) (prop1 string, prop2 string)"); _epService.EPAdministrator.CreateEPL("insert into NamedWin select 'V1' as prop1, 'O1' as prop2 from StartValueEvent"); _epService.EPAdministrator.CreateEPL("on TestForwardEvent update NamedWin as work set prop2 = 'U1' where work.prop1 = 'V1'"); string[] fields = "prop1,prop2".Split(','); string eplSelect = "select irstream prop1, prop2 from NamedWin"; _epService.EPAdministrator.CreateEPL(eplSelect).AddListener(_listener); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new object[] { "dummyValue" }, "StartValueEvent"); } else { _epService.EPRuntime.SendEvent(new Dictionary <string, object>(), "StartValueEvent"); } EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "V1", "O1" }); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new object[] { "dummyValue" }, "TestInputEvent"); } else { _epService.EPRuntime.SendEvent(new Dictionary <string, object>(), "TestInputEvent"); } EPAssertionUtil.AssertProps(_listener.LastOldData[0], fields, new object[] { "V1", "O1" }); EPAssertionUtil.AssertProps(_listener.GetAndResetLastNewData()[0], fields, new object[] { "V1", "U1" }); _epService.Initialize(); }
private void SendMyEvent(EventRepresentationEnum eventRepresentationEnum, string in1, int in2) { IDictionary<String, object> theEvent = new LinkedHashMap<string, object>(); theEvent.Put("in1", in1); theEvent.Put("in2", in2); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), "MyEvent"); } else { _epService.EPRuntime.SendEvent(theEvent, "MyEvent"); } }
private void RunAssertionFields(EventRepresentationEnum representationEnum, bool eventbean) { EPDataFlowInstantiationOptions options; _epService.EPAdministrator.CreateEPL("create " + representationEnum.GetOutputTypeCreateSchemaName() + " schema MyEvent(p0 string, p1 long, p2 double)"); var stmtGraph = _epService.EPAdministrator.CreateEPL("create dataflow MyDataFlowOne " + "" + "BeaconSource -> BeaconStream<" + (eventbean ? "EventBean<MyEvent>" : "MyEvent") + "> {" + " iterations : 3," + " p0 : 'abc'," + " p1 : MyMath.Round(MyMath.Random() * 10) + 1," + " p2 : 1d," + "}" + "DefaultSupportCaptureOp(BeaconStream) {}"); var future = new DefaultSupportCaptureOp(3); options = new EPDataFlowInstantiationOptions().OperatorProvider(new DefaultSupportGraphOpProvider(future)); var df = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlowOne", options); df.Start(); Object[] output = future.GetValue(TimeSpan.FromSeconds(2)); Assert.AreEqual(3, output.Length); for (var i = 0; i < 3; i++) { if (!eventbean) { if (representationEnum.IsObjectArrayEvent()) { var row = (Object[])output[i]; Assert.AreEqual("abc", row[0]); long val = row[1].AsLong(); Assert.IsTrue(val >= 0 && val <= 11, "val=" + val); Assert.AreEqual(1d, row[2]); } else { var row = (DataMap)output[i]; Assert.AreEqual("abc", row.Get("p0")); long val = row.Get("p1").AsLong(); Assert.IsTrue(val >= 0 && val <= 11, "val=" + val); Assert.AreEqual(1d, row.Get("p2")); } } else { var row = (EventBean)output[i]; Assert.AreEqual("abc", row.Get("p0")); } } stmtGraph.Dispose(); _epService.EPAdministrator.Configuration.RemoveEventType("MyEvent", true); }
private void SendSentenceEvent(EventRepresentationEnum eventRepresentationEnum, string sentence) { if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new object[] { sentence }, "SentenceEvent"); } else { _epService.EPRuntime.SendEvent( Collections.SingletonDataMap("sentence", sentence), "SentenceEvent"); } }
private void RunAssertionCreateStreamTwo(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema MyEvent(myId int)"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema AllMyEvent as (myEvent MyEvent, class String, reverse boolean)"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema SuspectMyEvent as (myEvent MyEvent, class String)"); var stmtOne = _epService.EPAdministrator.CreateEPL( "insert into AllMyEvent " + "select c as myEvent, 'test' as class, false as reverse " + "from MyEvent(myId=1) c"); stmtOne.Events += _listener.Update; Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtOne.EventType.UnderlyingType); var stmtTwo = _epService.EPAdministrator.CreateEPL( "insert into SuspectMyEvent " + "select c.myEvent as myEvent, class " + "from AllMyEvent(not reverse) c"); var listenerTwo = new SupportUpdateListener(); stmtTwo.Events += listenerTwo.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(MakeEvent(1).Values.ToArray(), "MyEvent"); } else { _epService.EPRuntime.SendEvent(MakeEvent(1), "MyEvent"); } var resultOne = _listener.AssertOneGetNewAndReset(); Assert.IsTrue(resultOne.Get("myEvent") is EventBean); Assert.AreEqual(1, ((EventBean)resultOne.Get("myEvent")).Get("myId")); Assert.NotNull(stmtOne.EventType.GetFragmentType("myEvent")); var resultTwo = listenerTwo.AssertOneGetNewAndReset(); Assert.IsTrue(resultTwo.Get("myEvent") is EventBean); Assert.AreEqual(1, ((EventBean)resultTwo.Get("myEvent")).Get("myId")); Assert.NotNull(stmtTwo.EventType.GetFragmentType("myEvent")); _epService.Initialize(); }
private void SendOrderEvent(EventRepresentationEnum eventRepresentationEnum, string orderId, string productId, double price, int quantity, bool deletedFlag) { IDictionary<String, object> theEvent = new LinkedHashMap<string, object>(); theEvent.Put("orderId", orderId); theEvent.Put("productId", productId); theEvent.Put("price", price); theEvent.Put("quantity", quantity); theEvent.Put("deletedFlag", deletedFlag); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), "OrderEvent"); } else { _epService.EPRuntime.SendEvent(theEvent, "OrderEvent"); } }
private void SendEventOne(EPServiceProvider epService, EventRepresentationEnum eventRepresentationEnum, String id) { IDictionary <String, Object> theEvent = new LinkedHashMap <String, Object>(); theEvent.Put("id", id); if (eventRepresentationEnum.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), "EventOne"); } else { epService.EPRuntime.SendEvent(theEvent, "EventOne"); } }
public void RunAssertionNestableMapArray(EventRepresentationEnum eventRepresentationEnum) { EPStatement stmtInner = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyInnerType as (col1 string[], col2 int[])"); EventType inner = stmtInner.EventType; Assert.AreEqual(typeof(string[]), inner.GetPropertyType("col1")); Assert.IsTrue(inner.GetPropertyDescriptor("col1").IsIndexed); Assert.AreEqual(typeof(int[]), inner.GetPropertyType("col2")); Assert.IsTrue(inner.GetPropertyDescriptor("col2").IsIndexed); Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), inner.UnderlyingType); EPStatement stmtOuter = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyOuterType as (col1 MyInnerType, col2 MyInnerType[])"); FragmentEventType type = stmtOuter.EventType.GetFragmentType("col1"); Assert.AreEqual("MyInnerType", type.FragmentType.Name); Assert.IsFalse(type.IsIndexed); Assert.IsFalse(type.IsNative); type = stmtOuter.EventType.GetFragmentType("col2"); Assert.AreEqual("MyInnerType", type.FragmentType.Name); Assert.IsTrue(type.IsIndexed); Assert.IsFalse(type.IsNative); EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL("select * from MyOuterType"); stmtSelect.Events += _listener.Update; Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtSelect.EventType.UnderlyingType); if (eventRepresentationEnum.IsObjectArrayEvent()) { Object[] innerData = { "abc,def".Split(','), new int[] { 1, 2 } }; Object[] outerData = { innerData, new Object[] { innerData, innerData } }; _epService.EPRuntime.SendEvent(outerData, "MyOuterType"); } else { IDictionary <String, Object> innerData = new Dictionary <String, Object>(); innerData.Put("col1", "abc,def".Split(',')); innerData.Put("col2", new int[] { 1, 2 }); IDictionary <String, Object> outerData = new Dictionary <String, Object>(); outerData.Put("col1", innerData); outerData.Put("col2", new DataMap[] { innerData, innerData }); _epService.EPRuntime.SendEvent(outerData, "MyOuterType"); } EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "col1.col1[1],col2[1].col2[1]".Split(','), new Object[] { "def", 2 }); _epService.EPAdministrator.Configuration.RemoveEventType("MyInnerType", true); _epService.EPAdministrator.Configuration.RemoveEventType("MyOuterType", true); _epService.EPAdministrator.DestroyAllStatements(); }
private void SendPortfolio(EventRepresentationEnum eventRepresentationEnum, string portfolio, string product) { IDictionary <String, object> theEvent = new LinkedHashMap <string, object>(); theEvent.Put("portfolio", portfolio); theEvent.Put("product", product); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), "Portfolio"); } else { _epService.EPRuntime.SendEvent(theEvent, "Portfolio"); } }
private void MakeSendScoreEvent(String typeName, EventRepresentationEnum eventRepresentationEnum, String userId, String keyword, String productId, long score) { IDictionary <String, Object> theEvent = new LinkedHashMap <String, Object>(); theEvent.Put("userId", userId); theEvent.Put("keyword", keyword); theEvent.Put("productId", productId); theEvent.Put("score", score); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(theEvent.Values.ToArray(), typeName); } else { _epService.EPRuntime.SendEvent(theEvent, typeName); } }
private void RunAssertionGetDynamicWObjectArr(EventRepresentationEnum eventRepresentationEnum) { String stmtText = eventRepresentationEnum.GetAnnotationText() + " select item.id? as myid from " + typeof (SupportBeanDynRoot).FullName; using (var stmt = _epService.EPAdministrator.CreateEPL(stmtText)) { stmt.Events += _listener.Update; // check type Assert.AreEqual(typeof (object), stmt.EventType.GetPropertyType("myid")); // check value with an object that has the property as an int var runtime = _epService.EPRuntime; runtime.SendEvent( new SupportBeanDynRoot(new SupportBean_S0(101))); Assert.AreEqual(101, _listener.AssertOneGetNewAndReset().Get("myid")); // check value with an object that doesn't have the property runtime.SendEvent(new SupportBeanDynRoot("abc")); Assert.AreEqual(null, _listener.AssertOneGetNewAndReset().Get("myid")); // check value with an object that has the property as a string runtime.SendEvent( new SupportBeanDynRoot(new SupportBean_A("e1"))); Assert.AreEqual("e1", _listener.AssertOneGetNewAndReset().Get("myid")); runtime.SendEvent( new SupportBeanDynRoot(new SupportBean_B("e2"))); Assert.AreEqual("e2", _listener.AssertOneGetNewAndReset().Get("myid")); runtime.SendEvent( new SupportBeanDynRoot(new SupportBean_S1(102))); Assert.AreEqual(102, _listener.AssertOneGetNewAndReset().Get("myid")); if (eventRepresentationEnum.IsObjectArrayEvent()) { Assert.AreEqual(typeof (object[]), stmt.EventType.UnderlyingType); } else { Assert.AreEqual(typeof (IDictionary<string, object>), stmt.EventType.UnderlyingType); } } }
public void RunAssertionInheritance(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema BaseEvent as (b1 string)"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema SubEvent as (s1 string) inherits BaseEvent"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema OuterEvent as (bases BaseEvent[], subs SubEvent[])"); EPStatement stmt = _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " select bases.union(subs) as val from OuterEvent"); stmt.Events += _listener.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent( new Object[] { new Object[][] { new Object[] { "b10" } }, new Object[][] { new Object[] { "b10", "s10" } } }, "OuterEvent"); } else { IDictionary <String, Object> baseEvent = MakeMap("b1", "b10"); IDictionary <String, Object> subEvent = MakeMap("s1", "s10"); IDictionary <String, Object> outerEvent = MakeMap( "bases", new Map[] { baseEvent }, "subs", new Map[] { subEvent }); _epService.EPRuntime.SendEvent(outerEvent, "OuterEvent"); } var result = (ICollection <object>)_listener.AssertOneGetNewAndReset().Get("val"); Assert.AreEqual(2, result.Count); _epService.Initialize(); }
private void RunAssertionCreateStream(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema MyEvent(myId int)"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema CompositeEvent(c1 MyEvent, c2 MyEvent, rule string)"); _epService.EPAdministrator.CreateEPL( "insert into MyStream select c, 'additionalValue' as value from MyEvent c"); _epService.EPAdministrator.CreateEPL( "insert into CompositeEvent select e1.c as c1, e2.c as c2, '4' as rule " + "from pattern [e1=MyStream -> e2=MyStream]"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " @Name('Target') select * from CompositeEvent"); _epService.EPAdministrator.GetStatement("Target").Events += _listener.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(MakeEvent(10).Values.ToArray(), "MyEvent"); _epService.EPRuntime.SendEvent(MakeEvent(11).Values.ToArray(), "MyEvent"); } else { _epService.EPRuntime.SendEvent(MakeEvent(10), "MyEvent"); _epService.EPRuntime.SendEvent(MakeEvent(11), "MyEvent"); } var theEvent = _listener.AssertOneGetNewAndReset(); Assert.AreEqual(10, theEvent.Get("c1.myId")); Assert.AreEqual(11, theEvent.Get("c2.myId")); Assert.AreEqual("4", theEvent.Get("rule")); _epService.Initialize(); }
private void RunAssertionSchemaCopyProperties(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema BaseOne (prop1 String, prop2 int)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema BaseTwo (prop3 long)"); // test define and send _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema E1 () copyfrom BaseOne"); EPStatement stmtOne = _epService.EPAdministrator.CreateEPL("select * from E1"); stmtOne.Events += _listener.Update; Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtOne.EventType.UnderlyingType); Assert.AreEqual(typeof(string), stmtOne.EventType.GetPropertyType("prop1")); Assert.AreEqual(typeof(int), stmtOne.EventType.GetPropertyType("prop2")); IDictionary <String, Object> eventE1 = new LinkedHashMap <String, Object>(); eventE1.Put("prop1", "v1"); eventE1.Put("prop2", 2); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(eventE1.Values.ToArray(), "E1"); } else { _epService.EPRuntime.SendEvent(eventE1, "E1"); } EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "prop1,prop2".Split(','), new Object[] { "v1", 2 }); // test two copy-from types _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema E2 () copyfrom BaseOne, BaseTwo"); EPStatement stmtTwo = _epService.EPAdministrator.CreateEPL("select * from E2"); Assert.AreEqual(typeof(string), stmtTwo.EventType.GetPropertyType("prop1")); Assert.AreEqual(typeof(int), stmtTwo.EventType.GetPropertyType("prop2")); Assert.AreEqual(typeof(long), stmtTwo.EventType.GetPropertyType("prop3")); // test API-defined type IDictionary <String, Object> def = new Dictionary <String, Object>(); def.Put("a", "string"); def.Put("b", typeof(String)); def.Put("c", "BaseOne"); def.Put("d", "BaseTwo[]"); _epService.EPAdministrator.Configuration.AddEventType("MyType", def); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema E3(e long, f BaseOne) copyfrom MyType"); EPStatement stmtThree = _epService.EPAdministrator.CreateEPL("select * from E3"); Assert.AreEqual(typeof(String), stmtThree.EventType.GetPropertyType("a")); Assert.AreEqual(typeof(String), stmtThree.EventType.GetPropertyType("b")); if (eventRepresentationEnum.IsObjectArrayEvent()) { Assert.AreEqual(typeof(Object[]), stmtThree.EventType.GetPropertyType("c")); Assert.AreEqual(typeof(Object[][]), stmtThree.EventType.GetPropertyType("d")); Assert.AreEqual(typeof(Object[]), stmtThree.EventType.GetPropertyType("f")); } else { Assert.AreEqual(typeof(DataMap), stmtThree.EventType.GetPropertyType("c")); Assert.AreEqual(typeof(DataMap[]), stmtThree.EventType.GetPropertyType("d")); Assert.AreEqual(typeof(DataMap), stmtThree.EventType.GetPropertyType("f")); } Assert.AreEqual(typeof(long), stmtThree.EventType.GetPropertyType("e")); // invalid tests TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4(a long) copyFrom MyType", "Error starting statement: Type by name 'MyType' contributes property 'a' defined as 'System.String' which overides the same property of type '" + typeof(long).FullName + "' ["); TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4(c BaseTwo) copyFrom MyType", "Error starting statement: Property by name 'c' is defined twice by adding type 'MyType' ["); TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4(c BaseTwo) copyFrom XYZ", "Error starting statement: Type by name 'XYZ' could not be located ["); TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create schema E4 as " + typeof(SupportBean).FullName + " copyFrom XYZ", "Error starting statement: Copy-from types are not allowed with class-provided types ["); TryInvalid(eventRepresentationEnum.GetAnnotationText() + " create variant schema E4(c BaseTwo) copyFrom XYZ", "Error starting statement: Copy-from types are not allowed with variant types ["); // test SODA String createEPL = eventRepresentationEnum.GetAnnotationText() + " create schema EX as () copyFrom BaseOne, BaseTwo"; EPStatementObjectModel model = _epService.EPAdministrator.CompileEPL(createEPL); Assert.AreEqual(createEPL.Trim(), model.ToEPL()); EPStatement stmt = _epService.EPAdministrator.Create(model); Assert.AreEqual(createEPL.Trim(), stmt.Text); _epService.Initialize(); }
private void RunAssertionColDefPlain(EventRepresentationEnum eventRepresentationEnum) { EPStatement stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col1 string, col2 int, sbean " + typeof(SupportBean).FullName + ", col3.col4 int)"); AssertTypeColDef(stmtCreate.EventType); EPStatement stmtSelect = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType"); AssertTypeColDef(stmtSelect.EventType); stmtSelect.Dispose(); stmtCreate.Dispose(); // destroy and create differently stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col3 string, col4 int)"); Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("col4")); Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count); stmtCreate.Stop(); // destroy and create differently stmtCreate = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyEventType as (col5 string, col6 int)"); Assert.AreEqual(stmtCreate.EventType.UnderlyingType, eventRepresentationEnum.GetOutputClass()); Assert.AreEqual(typeof(int), stmtCreate.EventType.GetPropertyType("col6")); Assert.AreEqual(2, stmtCreate.EventType.PropertyDescriptors.Count); stmtSelect = _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " select * from MyEventType"); stmtSelect.Events += _listener.Update; Assert.AreEqual(stmtSelect.EventType.UnderlyingType, eventRepresentationEnum.GetOutputClass()); // send event IDictionary <String, Object> data = new LinkedHashMap <String, Object>(); data.Put("col5", "abc"); data.Put("col6", 1); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(data.Values.ToArray(), "MyEventType"); } else { _epService.EPRuntime.SendEvent(data, "MyEventType"); } EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "col5,col6".Split(','), new Object[] { "abc", 1 }); // assert type information EventTypeSPI typeSPI = (EventTypeSPI)stmtSelect.EventType; Assert.AreEqual(TypeClass.APPLICATION, typeSPI.Metadata.TypeClass); Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PublicName); Assert.IsTrue(typeSPI.Metadata.IsApplicationConfigured); Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfigured); Assert.IsFalse(typeSPI.Metadata.IsApplicationPreConfiguredStatic); Assert.AreEqual(typeSPI.Name, typeSPI.Metadata.PrimaryName); // test non-enum create-schema String epl = "create" + eventRepresentationEnum.GetOutputTypeCreateSchemaName() + " schema MyEventTypeTwo as (col1 string, col2 int, sbean " + typeof(SupportBean).FullName + ", col3.col4 int)"; EPStatement stmtCreateTwo = _epService.EPAdministrator.CreateEPL(epl); AssertTypeColDef(stmtCreateTwo.EventType); Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreateTwo.EventType.UnderlyingType); stmtCreateTwo.Dispose(); _epService.EPAdministrator.Configuration.RemoveEventType("MyEventTypeTwo", true); EPStatementObjectModel model = _epService.EPAdministrator.CompileEPL(epl); Assert.AreEqual(model.ToEPL(), epl); stmtCreateTwo = _epService.EPAdministrator.Create(model); AssertTypeColDef(stmtCreateTwo.EventType); Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreateTwo.EventType.UnderlyingType); _epService.Initialize(); }
private void RunAssertionVariantStream(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.Configuration.AddEventType( "SupportBean", typeof(SupportBean)); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema EventOne as (key string)"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema EventTwo as (key string)"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema S0 as " + typeof(SupportBean_S0).FullName); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create variant schema VarSchema as *"); _epService.EPAdministrator.CreateEPL( "insert into VarSchema select * from EventOne"); _epService.EPAdministrator.CreateEPL( "insert into VarSchema select * from EventTwo"); _epService.EPAdministrator.CreateEPL( "insert into VarSchema select * from S0"); _epService.EPAdministrator.CreateEPL( "insert into VarSchema select * from SupportBean"); String stmtText = "select Typeof(A) as t0 from VarSchema as A"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.Events += _listener.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { "value" }, "EventOne"); } else { _epService.EPRuntime.SendEvent( Collections.SingletonMap <string, object>("key", "value"), "EventOne"); } Assert.AreEqual("EventOne", _listener.AssertOneGetNewAndReset().Get("t0")); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { "value" }, "EventTwo"); } else { _epService.EPRuntime.SendEvent( Collections.SingletonMap <string, object>("key", "value"), "EventTwo"); } Assert.AreEqual("EventTwo", _listener.AssertOneGetNewAndReset().Get("t0")); _epService.EPRuntime.SendEvent(new SupportBean_S0(1)); Assert.AreEqual("S0", _listener.AssertOneGetNewAndReset().Get("t0")); _epService.EPRuntime.SendEvent(new SupportBean()); Assert.AreEqual("SupportBean", _listener.AssertOneGetNewAndReset().Get("t0")); stmt.Dispose(); _listener.Reset(); stmt = _epService.EPAdministrator.CreateEPL( "select * from VarSchema Match_recognize(\n" + " measures A as a, B as b\n" + " pattern (A B)\n" + " define A as Typeof(A) = \"EventOne\",\n" + " B as Typeof(B) = \"EventTwo\"\n" + " )"); stmt.Events += _listener.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { "value" } , "EventOne"); _epService.EPRuntime.SendEvent(new Object[] { "value" } , "EventTwo"); } else { _epService.EPRuntime.SendEvent( Collections.SingletonMap <string, object>("key", "value"), "EventOne"); _epService.EPRuntime.SendEvent( Collections.SingletonMap <string, object>("key", "value"), "EventTwo"); } Assert.IsTrue(_listener.GetAndClearIsInvoked()); _listener.Reset(); _epService.Initialize(); }
private void RunAssertionSingleRowSplitAndType(EventRepresentationEnum eventRepresentationEnum) { if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentence", GetType().FullName, "SplitSentenceMethodReturnObjectArray"); _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentenceBean", GetType().FullName, "SplitSentenceBeanMethodReturnObjectArray"); _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitWord", GetType().FullName, "SplitWordMethodReturnObjectArray"); } else { _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentence", GetType().FullName, "SplitSentenceMethodReturnMap"); _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitSentenceBean", GetType().FullName, "SplitSentenceBeanMethodReturnMap"); _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("splitWord", GetType().FullName, "SplitWordMethodReturnMap"); } _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("invalidSentence", GetType().FullName, "InvalidSentenceMethod"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema SentenceEvent(sentence String)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema WordEvent(word String)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema CharacterEvent(char String)"); string stmtText; EPStatement stmt; var fields = "word".Split(','); // test single-row method stmtText = "select * from SentenceEvent[splitSentence(sentence)@type(WordEvent)]"; stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.AddListener(_listener); Assert.AreEqual("WordEvent", stmt.EventType.Name); Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType); SendSentenceEvent(eventRepresentationEnum, "I am testing this code"); EPAssertionUtil.AssertPropsPerRow( _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { "I" }, new object[] { "am" }, new object[] { "testing" }, new object[] { "this" }, new object[] { "code" } }); SendSentenceEvent(eventRepresentationEnum, "the second event"); EPAssertionUtil.AssertPropsPerRow( _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { "the" }, new object[] { "second" }, new object[] { "event" } }); stmt.Dispose(); // test SODA var model = _epService.EPAdministrator.CompileEPL(stmtText); Assert.AreEqual(stmtText, model.ToEPL()); stmt = _epService.EPAdministrator.Create(model); Assert.AreEqual(stmtText, stmt.Text); stmt.AddListener(_listener); SendSentenceEvent(eventRepresentationEnum, "the third event"); EPAssertionUtil.AssertPropsPerRow( _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { "the" }, new object[] { "third" }, new object[] { "event" } }); stmt.Dispose(); // test script if (!eventRepresentationEnum.IsObjectArrayEvent()) { stmtText = "expression com.espertech.esper.support.collections.ISupportDataMapCollection js:splitSentenceJS(sentence) [" + " var words = clr.New('com.espertech.esper.support.collections.SupportDataMapList',[]);" + " var factory = clr.New('com.espertech.esper.support.collections.SupportDataMapFactory',[]);" + " words.Add(factory.Create('word', 'wordOne'));" + " words.Add(factory.Create('word', 'wordTwo'));" + " words;" + "]" + "select * from SentenceEvent[splitSentenceJS(sentence)@type(WordEvent)]"; stmt = _epService.EPAdministrator.CreateEPL(stmtText).AddListener(_listener); Assert.AreEqual("WordEvent", stmt.EventType.Name); _epService.EPRuntime.SendEvent(Collections.EmptyDataMap, "SentenceEvent"); EPAssertionUtil.AssertPropsPerRowAnyOrder( _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { "wordOne" }, new object[] { "wordTwo" } }); stmt.Dispose(); } // test multiple splitters stmtText = "select * from SentenceEvent[splitSentence(sentence)@type(WordEvent)][splitWord(word)@type(CharacterEvent)]"; stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.AddListener(_listener); Assert.AreEqual("CharacterEvent", stmt.EventType.Name); SendSentenceEvent(eventRepresentationEnum, "I am"); EPAssertionUtil.AssertPropsPerRowAnyOrder( _listener.GetAndResetLastNewData(), "char".Split(','), new object[][] { new object[] { "I" }, new object[] { "a" }, new object[] { "m" } }); stmt.Dispose(); // test wildcard parameter stmtText = "select * from SentenceEvent[splitSentenceBean(*)@type(WordEvent)]"; stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.AddListener(_listener); Assert.AreEqual("WordEvent", stmt.EventType.Name); SendSentenceEvent(eventRepresentationEnum, "another test sentence"); EPAssertionUtil.AssertPropsPerRowAnyOrder( _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { "another" }, new object[] { "test" }, new object[] { "sentence" } }); stmt.Dispose(); // test property returning untyped collection if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPAdministrator.Configuration.AddEventType(typeof(ObjectArrayEvent)); stmtText = eventRepresentationEnum.GetAnnotationText() + " select * from ObjectArrayEvent[someObjectArray@type(WordEvent)]"; stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.AddListener(_listener); Assert.AreEqual("WordEvent", stmt.EventType.Name); var rows = new object[][] { new object[] { "this" }, new object[] { "is" }, new object[] { "collection" } }; _epService.EPRuntime.SendEvent(new ObjectArrayEvent(rows)); EPAssertionUtil.AssertPropsPerRow( _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { "this" }, new object[] { "is" }, new object[] { "collection" } }); } else { _epService.EPAdministrator.Configuration.AddEventType <CollectionEvent <IDictionary <string, object> > >("CollectionEvent"); stmtText = eventRepresentationEnum.GetAnnotationText() + " select * from CollectionEvent[someCollection@type(WordEvent)]"; stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.AddListener(_listener); Assert.AreEqual("WordEvent", stmt.EventType.Name); var coll = new List <IDictionary <string, object> >(); coll.Add(Collections.SingletonDataMap("word", "this")); coll.Add(Collections.SingletonDataMap("word", "is")); coll.Add(Collections.SingletonDataMap("word", "collection")); _epService.EPRuntime.SendEvent(new CollectionEvent <IDictionary <string, object> >(coll)); EPAssertionUtil.AssertPropsPerRowAnyOrder( _listener.GetAndResetLastNewData(), fields, new object[][] { new object[] { "this" }, new object[] { "is" }, new object[] { "collection" } }); } // invalid: event type not found TryInvalid("select * from SentenceEvent[splitSentence(sentence)@type(XYZ)]", "Event type by name 'XYZ' could not be found [select * from SentenceEvent[splitSentence(sentence)@type(XYZ)]]"); // invalid lib-function annotation TryInvalid("select * from SentenceEvent[splitSentence(sentence)@dummy(WordEvent)]", "Invalid annotation for property selection, expected 'type' but found 'dummy' in text '[splitSentence(sentence)@dummy(WordEvent)]' [select * from SentenceEvent[splitSentence(sentence)@dummy(WordEvent)]]"); // invalid type assignment to event type if (eventRepresentationEnum.IsObjectArrayEvent()) { TryInvalid("select * from SentenceEvent[invalidSentence(sentence)@type(WordEvent)]", "Event type 'WordEvent' underlying type System.Object[] cannot be assigned a value of type"); } else { TryInvalid("select * from SentenceEvent[invalidSentence(sentence)@type(WordEvent)]", "Event type 'WordEvent' underlying type " + Name.Of <IDictionary <string, object> >() + " cannot be assigned a value of type"); } // invalid subquery TryInvalid("select * from SentenceEvent[splitSentence((select * from SupportBean.win:keepall()))@type(WordEvent)]", "Invalid contained-event expression 'splitSentence(subselect_0)': Aggregation, sub-select, previous or prior functions are not supported in this context [select * from SentenceEvent[splitSentence((select * from SupportBean.win:keepall()))@type(WordEvent)]]"); _epService.Initialize(); }
private void RunAssertionArrayMapInsert(EventRepresentationEnum eventRepresentationEnum) { _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema EventOne(id string)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema EventTwo(id string, val int)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema FinalEventValid (startEvent EventOne, endEvent EventTwo[])"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema FinalEventInvalidNonArray (startEvent EventOne, endEvent EventTwo)"); _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema FinalEventInvalidArray (startEvent EventOne, endEvent EventTwo)"); _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0)); // Test valid case of array insert var validEpl = "INSERT INTO FinalEventValid SELECT s as startEvent, e as endEvent FROM PATTERN [" + "every s=EventOne -> e=EventTwo(id=s.id) until timer:interval(10 sec)]"; var stmt = _epService.EPAdministrator.CreateEPL(validEpl); stmt.Events += _listener.Update; SendEventOne(_epService, eventRepresentationEnum, "G1"); SendEventTwo(_epService, eventRepresentationEnum, "G1", 2); SendEventTwo(_epService, eventRepresentationEnum, "G1", 3); _epService.EPRuntime.SendEvent(new CurrentTimeEvent(10000)); EventBean startEventOne; EventBean endEventOne; EventBean endEventTwo; if (eventRepresentationEnum.IsObjectArrayEvent()) { var outArray = ((Object[])_listener.AssertOneGetNewAndReset().Underlying); startEventOne = (EventBean)outArray[0]; endEventOne = ((EventBean[])outArray[1])[0]; endEventTwo = ((EventBean[])outArray[1])[1]; } else { var outMap = ((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Underlying); startEventOne = (EventBean)outMap.Get("startEvent"); endEventOne = ((EventBean[])outMap.Get("endEvent"))[0]; endEventTwo = ((EventBean[])outMap.Get("endEvent"))[1]; } Assert.AreEqual("G1", startEventOne.Get("id")); Assert.AreEqual(2, endEventOne.Get("val")); Assert.AreEqual(3, endEventTwo.Get("val")); // Test invalid case of non-array destination insert var invalidEpl = "INSERT INTO FinalEventInvalidNonArray SELECT s as startEvent, e as endEvent FROM PATTERN [" + "every s=EventOne -> e=EventTwo(id=s.id) until timer:interval(10 sec)]"; try { _epService.EPAdministrator.CreateEPL(invalidEpl); Assert.Fail(); } catch (EPException ex) { Assert.AreEqual("Error starting statement: Event type named 'FinalEventInvalidNonArray' has already been declared with differing column name or type information: Type by name 'FinalEventInvalidNonArray' in property 'endEvent' expected event type 'EventTwo' but receives event type 'EventTwo[]' [INSERT INTO FinalEventInvalidNonArray SELECT s as startEvent, e as endEvent FROM PATTERN [every s=EventOne -> e=EventTwo(id=s.id) until timer:interval(10 sec)]]", ex.Message); } // Test invalid case of array destination insert from non-array var var invalidEplTwo = "INSERT INTO FinalEventInvalidArray SELECT s as startEvent, e as endEvent FROM PATTERN [" + "every s=EventOne -> e=EventTwo(id=s.id) until timer:interval(10 sec)]"; try { _epService.EPAdministrator.CreateEPL(invalidEplTwo); Assert.Fail(); } catch (EPException ex) { Assert.AreEqual("Error starting statement: Event type named 'FinalEventInvalidArray' has already been declared with differing column name or type information: Type by name 'FinalEventInvalidArray' in property 'endEvent' expected event type 'EventTwo' but receives event type 'EventTwo[]' [INSERT INTO FinalEventInvalidArray SELECT s as startEvent, e as endEvent FROM PATTERN [every s=EventOne -> e=EventTwo(id=s.id) until timer:interval(10 sec)]]", ex.Message); } _epService.Initialize(); }
private void RunAssertionSetMapProps(EventRepresentationEnum eventRepresentationEnum) { // test Update-istream with bean _epService.EPAdministrator.Configuration.AddEventType( typeof(MyMapPropEvent)); _epService.EPAdministrator.Configuration.AddEventType( typeof(SupportBean)); _epService.EPAdministrator.CreateEPL( "insert into MyStream select * from MyMapPropEvent"); EPStatement stmtUpdOne = _epService.EPAdministrator.CreateEPL( "update istream MyStream set Props('abc') = 1, Array[2] = 10"); stmtUpdOne.Events += _listener.Update; _epService.EPRuntime.SendEvent(new MyMapPropEvent()); EPAssertionUtil.AssertProps( _listener.AssertPairGetIRAndReset(), "Props('abc'),Array[2]".Split(','), new Object[] { 1, 10 }, new Object[] { null, null }); // test Update-istream with map _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema MyMapType(Simple String, MyArray System.Object[], MyMap com.espertech.esper.support.util.QuickMap)"); EPStatement stmtUpdTwo = _epService.EPAdministrator.CreateEPL( "Update istream MyMapType set Simple='A', MyMap('abc') = 1, MyArray[2] = 10"); stmtUpdTwo.Events += _listener.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent( new Object[] { null, new Object[10], new Dictionary <String, Object>() }, "MyMapType"); } else { _epService.EPRuntime.SendEvent( MakeMapEvent(new Dictionary <String, Object>(), new Object[10]), "MyMapType"); } EPAssertionUtil.AssertProps( _listener.AssertPairGetIRAndReset(), "Simple,MyMap('abc'),MyArray[2]".Split(','), new Object[] { "A", 1, 10 }, new Object[] { null, null, null }); // test named-window Update _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema MyNWMapType(Simple String, MyArray System.Object[], MyMap com.espertech.esper.support.util.QuickMap)"); EPStatement stmtWin = _epService.EPAdministrator.CreateEPL( "create window MyWindow.win:keepall() as MyNWMapType"); _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " insert into MyWindow select * from MyNWMapType"); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent( new Object[] { null, new Object[10], new Dictionary <String, Object>() }, "MyNWMapType"); } else { _epService.EPRuntime.SendEvent( MakeMapEvent(new Dictionary <String, Object>(), new Object[10]), "MyNWMapType"); } _epService.EPAdministrator.CreateEPL( "on SupportBean Update MyWindow set Simple='A', MyMap('abc') = IntPrimitive, MyArray[2] = IntPrimitive"); _epService.EPRuntime.SendEvent(new SupportBean("E1", 10)); EPAssertionUtil.AssertPropsPerRow( stmtWin.GetEnumerator(), "Simple,MyMap('abc'),MyArray[2]".Split(','), new Object[][] { new Object[] { "A", 10, 10 } }); // test null and array too small if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent( new Object[] { null, new Object[2], null }, "MyNWMapType"); } else { _epService.EPRuntime.SendEvent(MakeMapEvent(null, new Object[2]), "MyNWMapType"); } _epService.EPRuntime.SendEvent(new SupportBean("E2", 20)); EPAssertionUtil.AssertPropsPerRowAnyOrder( stmtWin.GetEnumerator(), "Simple,MyMap('abc'),MyArray[2]".Split(','), new Object[][] { new Object[] { "A", 20, 20 }, new Object[] { "A", null, null } }); _epService.Initialize(); }