private void SendProduct(EventRepresentationChoice eventRepresentationEnum, string product, int size) { if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { product, size }, "Product"); } else if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new LinkedHashMap <string, Object>(); theEvent.Put("product", product); theEvent.Put("size", size); _epService.EPRuntime.SendEvent(theEvent, "Product"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(_epService, "Product").AsRecordSchema()); theEvent.Put("product", product); theEvent.Put("size", size); _epService.EPRuntime.SendEventAvro(theEvent, "Product"); } else { Assert.Fail(); } }
private Object SendEvent(EventRepresentationChoice rep, string value) { Object eventOne; if (rep.IsMapEvent()) { var @event = Collections.SingletonDataMap("col1", value); _epService.EPRuntime.SendEvent(@event, "MyEvent"); eventOne = @event; } else if (rep.IsObjectArrayEvent()) { var @event = new Object[] { value }; _epService.EPRuntime.SendEvent(@event, "MyEvent"); eventOne = @event; } else if (rep.IsAvroEvent()) { var schema = SupportAvroUtil.GetAvroSchema(_epService, "MyEvent").AsRecordSchema(); var @event = new GenericRecord(schema); @event.Put("col1", value); _epService.EPRuntime.SendEventAvro(@event, "MyEvent"); eventOne = @event; } else { throw new IllegalStateException(); } return(eventOne); }
private static void SendRepEvent( RegressionEnvironment env, EventRepresentationChoice rep, string name, string id, int p00) { if (rep.IsMapEvent()) { IDictionary<string, object> theEvent = new Dictionary<string, object>(); theEvent.Put("Id", id); theEvent.Put("P00", p00); env.SendEventMap(theEvent, name); } else if (rep.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {id, p00}, name); } else if (rep.IsAvroEvent()) { var theEvent = new GenericRecord( SupportAvroUtil.GetAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(name)) .AsRecordSchema()); theEvent.Put("Id", id); theEvent.Put("P00", p00); env.SendEventAvro(theEvent, name); } else if (rep.IsJsonEvent() || rep.IsJsonProvidedClassEvent()) { String json = "{\"Id\": \"" + id + "\", \"P00\": " + p00 + "}"; env.EventService.SendEventJson(json, name); } else { Assert.Fail(); } }
private void MakeSendScoreEvent(EPServiceProvider epService, string typeName, EventRepresentationChoice eventRepresentationEnum, string userId, string keyword, string productId, long score) { if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new LinkedHashMap <string, object>(); theEvent.Put("userId", userId); theEvent.Put("keyword", keyword); theEvent.Put("productId", productId); theEvent.Put("score", score); epService.EPRuntime.SendEvent(theEvent, typeName); } else if (eventRepresentationEnum.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent(new object[] { userId, keyword, productId, score }, typeName); } else if (eventRepresentationEnum.IsAvroEvent()) { var record = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, typeName).AsRecordSchema()); record.Put("userId", userId); record.Put("keyword", keyword); record.Put("productId", productId); record.Put("score", score); epService.EPRuntime.SendEventAvro(record, typeName); } else { Assert.Fail(); } }
private void SendPortfolio(EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum, string portfolio, string product) { if (eventRepresentationEnum.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent(new object[] { portfolio, product }, "Portfolio"); } else if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new LinkedHashMap <string, Object>(); theEvent.Put("portfolio", portfolio); theEvent.Put("product", product); epService.EPRuntime.SendEvent(theEvent, "Portfolio"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, "Portfolio").AsRecordSchema()); theEvent.Put("portfolio", portfolio); theEvent.Put("product", product); epService.EPRuntime.SendEventAvro(theEvent, "Portfolio"); } else { Assert.Fail(); } }
private void SendRepEvent(EventRepresentationChoice rep, string name, string id, int p00) { if (rep.IsMapEvent()) { IDictionary <string, object> theEvent = new Dictionary <string, object>(); theEvent.Put("id", id); theEvent.Put("p00", p00); _epService.EPRuntime.SendEvent(theEvent, name); } else if (rep.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new object[] { id, p00 }, name); } else if (rep.IsAvroEvent()) { GenericRecord theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(_epService, name).AsRecordSchema()); theEvent.Put("id", id); theEvent.Put("p00", p00); _epService.EPRuntime.SendEventAvro(theEvent, name); } else { Assert.Fail(); } }
private void RunStreamInsertAssertion( EPServiceProvider epService, EventRepresentationChoice rep, string epl, string fields, object[] expected) { var stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; if (rep.IsMapEvent()) { epService.EPRuntime.SendEvent(MakeMap(123, "abc"), "Src"); } else if (rep.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent(new object[] {123, "abc"}, "Src"); } else if (rep.IsAvroEvent()) { var @event = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, "Src").AsRecordSchema()); @event.Put("myint", 123); @event.Put("mystr", "abc"); epService.EPRuntime.SendEventAvro(@event, "Src"); } EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields.Split(','), expected); stmt.Dispose(); }
private void SendMyEvent(EventRepresentationChoice eventRepresentationEnum, string in1, int in2) { if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent( new Object[] { in1, in2 }, "MyEvent"); } else if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new LinkedHashMap <string, Object>(); theEvent.Put("in1", in1); theEvent.Put("in2", in2); _epService.EPRuntime.SendEvent(theEvent, "MyEvent"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(_epService, "MyEvent").AsRecordSchema()); theEvent.Put("in1", in1); theEvent.Put("in2", in2); _epService.EPRuntime.SendEventAvro(theEvent, "MyEvent"); } else { Assert.Fail(); } }
private void MakeSendEvent(EPServiceProvider epService, string typeName, EventRepresentationChoice eventRepresentationEnum, Object startTs, Object endTs) { if (eventRepresentationEnum.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent(new object[] { startTs, endTs }, typeName); } else if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new LinkedHashMap <string, object>(); theEvent.Put("startts", startTs); theEvent.Put("endts", endTs); epService.EPRuntime.SendEvent(theEvent, typeName); } else if (eventRepresentationEnum.IsAvroEvent()) { var record = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, typeName).AsRecordSchema()); record.Put("startts", startTs); record.Put("endts", endTs); epService.EPRuntime.SendEventAvro(record, typeName); } else { throw new IllegalStateException("Unrecognized enum " + eventRepresentationEnum); } }
public void RunAssertionCreateSchemaModelAfter(EventRepresentationChoice 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#unique(event.hsi) as EventTypeTwo"); _epService.EPAdministrator.CreateEPL("on EventTypeOne as ev insert into NamedWindow select ev as event"); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { 10 }, "EventTypeOne"); } else if (eventRepresentationEnum.IsMapEvent()) { _epService.EPRuntime.SendEvent(Collections.SingletonDataMap("hsi", 10), "EventTypeOne"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(_epService, "EventTypeOne").AsRecordSchema()); theEvent.Put("hsi", 10); _epService.EPRuntime.SendEventAvro(theEvent, "EventTypeOne"); } else { Assert.Fail(); } var result = stmt.First(); var getter = result.EventType.GetGetter("event.hsi"); Assert.AreEqual(10, getter.Get(result)); _epService.Initialize(); }
private void RunAssertionUpdateIStreamSetMapProps(EventRepresentationChoice eventRepresentationEnum) { // test update-istream with map _epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema MyInfraType(simple string, myarray int[], mymap com.espertech.esper.compat.collections.StringMap)"); EPStatement stmtUpdTwo = _epService.EPAdministrator.CreateEPL("update istream MyInfraType set simple='A', mymap('abc') = 1, myarray[2] = 10"); stmtUpdTwo.AddListener(_listener); if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { null, new int[10], new Dictionary <string, Object>() }, "MyInfraType"); } else if (eventRepresentationEnum.IsMapEvent()) { _epService.EPRuntime.SendEvent(MakeMapEvent(new Dictionary <string, object>(), new int[10]), "MyInfraType"); } else if (eventRepresentationEnum.IsAvroEvent()) { GenericRecord theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(_epService, "MyInfraType").AsRecordSchema()); theEvent.Put("myarray", Collections.List(0, 0, 0, 0, 0)); theEvent.Put("mymap", new Dictionary <string, object>()); _epService.EPRuntime.SendEventAvro(theEvent, "MyInfraType"); } else { Assert.Fail(); } EPAssertionUtil.AssertProps(_listener.AssertPairGetIRAndReset(), "simple,mymap('abc'),myarray[2]".Split(','), new Object[] { "A", 1, 10 }, new Object[] { null, null, 0 }); _epService.Initialize(); }
private void MakeSendEvent( RegressionEnvironment env, string typeName, EventRepresentationChoice eventRepresentationEnum, object startTs, object endTs) { if (eventRepresentationEnum.IsObjectArrayEvent()) { env.SendEventObjectArray(new[] {startTs, endTs}, typeName); } else if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new Dictionary<string, object>(); theEvent.Put("startts", startTs); theEvent.Put("endts", endTs); env.SendEventMap(theEvent, typeName); } else if (eventRepresentationEnum.IsAvroEvent()) { var record = new GenericRecord( SupportAvroUtil.GetAvroSchema( env.Runtime.EventTypeService.GetEventTypePreconfigured(typeName)) .AsRecordSchema()); record.Put("startts", startTs); record.Put("endts", endTs); env.EventService.SendEventAvro(record, typeName); } else if (eventRepresentationEnum.IsJsonEvent() || eventRepresentationEnum.IsJsonProvidedClassEvent()) { var json = "{\"startts\": \"" + startTs + "\", \"endts\": \"" + endTs + "\"}"; env.EventService.SendEventJson(json, typeName); } else { throw new IllegalStateException("Unrecognized enum " + eventRepresentationEnum); } }
private static void SendMyEvent( RegressionEnvironment env, EventRepresentationChoice eventRepresentationEnum, string in1, int in2) { if (eventRepresentationEnum.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {in1, in2}, "MyEvent"); } else if (eventRepresentationEnum.IsMapEvent()) { IDictionary<string, object> theEvent = new Dictionary<string, object>(); theEvent.Put("in1", in1); theEvent.Put("in2", in2); env.SendEventMap(theEvent, "MyEvent"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord( SupportAvroUtil.GetAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("MyEvent")) .AsRecordSchema()); theEvent.Put("in1", in1); theEvent.Put("in2", in2); env.EventService.SendEventAvro(theEvent, "MyEvent"); } else if (eventRepresentationEnum.IsJsonEvent() || eventRepresentationEnum.IsJsonProvidedClassEvent()) { env.EventService.SendEventJson("{\"in1\": \"" + in1 + "\", \"in2\": " + in2 + "}", "MyEvent"); } else { Assert.Fail(); } }
private static object SendEvent( RegressionEnvironment env, EventRepresentationChoice rep, string value) { object eventOne; if (rep.IsMapEvent()) { var @event = Collections.SingletonDataMap("col1", value); env.SendEventMap(@event, "MyEvent"); eventOne = @event; } else if (rep.IsObjectArrayEvent()) { var @event = new object[] {value}; env.SendEventObjectArray(@event, "MyEvent"); eventOne = @event; } else if (rep.IsAvroEvent()) { var schema = SupportAvroUtil.GetAvroSchema(env.Statement("schema").EventType).AsRecordSchema(); var @event = new GenericRecord(schema); @event.Put("col1", value); env.SendEventAvro(@event, "MyEvent"); eventOne = @event; } else if (rep.IsJsonEvent() || rep.IsJsonProvidedClassEvent()) { var @object = new JObject(new JProperty("col1", value)); env.SendEventJson(@object.ToString(), "MyEvent"); eventOne = @object.ToString(); } else { throw new IllegalStateException(); } return eventOne; }
private GenericRecord MakeAvro(EPServiceProvider epService, int myint, string mystr) { var record = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, "A").AsRecordSchema()); record.Put("myint", myint); record.Put("mystr", mystr); return record; }
private void SendOrderEvent(EventRepresentationChoice eventRepresentationEnum, string orderId, string productId, double price, int quantity, bool deletedFlag) { if (eventRepresentationEnum.IsObjectArrayEvent()) { _epService.EPRuntime.SendEvent(new Object[] { orderId, productId, price, quantity, deletedFlag }, "OrderEvent"); } else if (eventRepresentationEnum.IsMapEvent()) { var 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); _epService.EPRuntime.SendEvent(theEvent, "OrderEvent"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(_epService, "OrderEvent").AsRecordSchema()); theEvent.Put("orderId", orderId); theEvent.Put("productId", productId); theEvent.Put("price", price); theEvent.Put("quantity", quantity); theEvent.Put("deletedFlag", deletedFlag); _epService.EPRuntime.SendEventAvro(theEvent, "OrderEvent"); } else { Assert.Fail(); } }
private static void sendPortfolio( RegressionEnvironment env, EventRepresentationChoice eventRepresentationEnum, string portfolio, string product) { if (eventRepresentationEnum.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {portfolio, product}, "Portfolio"); } else if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new LinkedHashMap<string, object>(); theEvent.Put("portfolio", portfolio); theEvent.Put("product", product); env.SendEventMap(theEvent, "Portfolio"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord( SupportAvroUtil.GetAvroSchema( env.Runtime.EventTypeService.GetEventTypePreconfigured("Portfolio")) .AsRecordSchema()); theEvent.Put("portfolio", portfolio); theEvent.Put("product", product); env.EventService.SendEventAvro(theEvent, "Portfolio"); } else if (eventRepresentationEnum.IsJsonEvent() || eventRepresentationEnum.IsJsonProvidedClassEvent()) { var @object = new JObject(); @object.Add("portfolio", portfolio); @object.Add("product", product); env.EventService.SendEventJson(@object.ToString(), "Portfolio"); } else { Assert.Fail(); } }
private GenericRecord MakeAvro(int myint, string mystr) { var record = new GenericRecord(SupportAvroUtil.GetAvroSchema(_epService, "A").AsRecordSchema()); record.Put("myint", myint); record.Put("mystr", mystr); return(record); }
private void SendEvent( RegressionEnvironment env, string symbol) { var schema = SupportAvroUtil.GetAvroSchema(env.Statement("input").EventType).AsRecordSchema(); var rec = new GenericRecord(schema); rec.Put("symbol", symbol); env.SendEventAvro(rec, "Input"); }
private static GenericRecord MakeAvro( RegressionEnvironment env, int myint, string mystr) { EventType eventType = env.Runtime.EventTypeService.GetEventType(env.DeploymentId("schema"), "A"); var record = new GenericRecord(SupportAvroUtil.GetAvroSchema(eventType).AsRecordSchema()); record.Put("myint", myint); record.Put("mystr", mystr); return record; }
public void Run(RegressionEnvironment env) { // Bean BiConsumer <EventType, string> bean = (type, property) => { env.SendEventBean(new LocalEvent(property)); }; var beanepl = $"@public @buseventtype create schema LocalEvent as {typeof(LocalEvent).MaskTypeName()}"; RunAssertion(env, beanepl, bean); // Map BiConsumer <EventType, string> map = (type, property) => { env.SendEventMap(Collections.SingletonDataMap("Property", property), "LocalEvent"); }; RunAssertion(env, GetEpl("map"), map); // Object-array BiConsumer <EventType, string> oa = (type, property) => { env.SendEventObjectArray(new object[] { property }, "LocalEvent"); }; RunAssertion(env, GetEpl("objectarray"), oa); // Json BiConsumer <EventType, string> json = (type, property) => { if (property == null) { env.SendEventJson(new JObject(new JProperty("Property", null)).ToString(), "LocalEvent"); } else { env.SendEventJson(new JObject(new JProperty("Property", property)).ToString(), "LocalEvent"); } }; RunAssertion(env, GetEpl("json"), json); // Json-Class-Predefined var eplJsonPredefined = "@JsonSchema(ClassName='" + typeof(MyLocalJsonProvided).MaskTypeName() + "') @buseventtype @public " + "create json schema LocalEvent();\n"; RunAssertion(env, eplJsonPredefined, json); // Avro BiConsumer <EventType, string> avro = (type, property) => { var @event = new GenericRecord(SupportAvroUtil.GetAvroSchema(type).AsRecordSchema()); @event.Put("Property", property); env.SendEventAvro(@event, "LocalEvent"); }; RunAssertion(env, GetEpl("avro"), avro); }
private void RunAssertionUpdateIStreamSetMapProps( EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum) { // test update-istream with map epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " create schema MyInfraType(simple string, myarray int[], mymap Map)"); var stmtUpdTwo = epService.EPAdministrator.CreateEPL( "update istream MyInfraType set simple='A', mymap('abc') = 1, myarray[2] = 10"); var listener = new SupportUpdateListener(); stmtUpdTwo.Events += listener.Update; if (eventRepresentationEnum.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent( new object[] { null, new int[10], new Dictionary <string, object>() }, "MyInfraType"); } else if (eventRepresentationEnum.IsMapEvent()) { epService.EPRuntime.SendEvent( MakeMapEvent(new Dictionary <string, object>(), new int[10]), "MyInfraType"); } else if (eventRepresentationEnum.IsAvroEvent()) { var @event = new GenericRecord( SupportAvroUtil.GetAvroSchema(epService, "MyInfraType").AsRecordSchema()); @event.Put("myarray", Collections.List(0, 0, 0, 0, 0)); @event.Put("mymap", new Dictionary <string, object>()); epService.EPRuntime.SendEventAvro(@event, "MyInfraType"); } else { Assert.Fail(); } EPAssertionUtil.AssertProps( listener.AssertPairGetIRAndReset(), "simple,mymap('abc'),myarray[2]".Split(','), new object[] { "A", 1, 10 }, new object[] { null, null, 0 }); epService.EPAdministrator.DestroyAllStatements(); foreach (var name in "MyInfraType".Split(',')) { epService.EPAdministrator.Configuration.RemoveEventType(name, true); } }
private static void SendOrderEvent( RegressionEnvironment env, EventRepresentationChoice eventRepresentationEnum, string orderId, string productId, double price, int quantity, bool deletedFlag) { if (eventRepresentationEnum.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {orderId, productId, price, quantity, deletedFlag}, "OrderEvent"); } else if (eventRepresentationEnum.IsMapEvent()) { 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); env.SendEventMap(theEvent, "OrderEvent"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord( SupportAvroUtil.GetAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("OrderEvent")) .AsRecordSchema()); theEvent.Put("OrderId", orderId); theEvent.Put("ProductId", productId); theEvent.Put("Price", price); theEvent.Put("Quantity", quantity); theEvent.Put("DeletedFlag", deletedFlag); env.EventService.SendEventAvro(theEvent, "OrderEvent"); } else if (eventRepresentationEnum.IsJsonEvent() || eventRepresentationEnum.IsJsonProvidedClassEvent()) { var @object = new JObject(); @object.Add("OrderId", orderId); @object.Add("ProductId", productId); @object.Add("Price", price); @object.Add("Quantity", quantity); @object.Add("DeletedFlag", deletedFlag); env.EventService.SendEventJson(@object.ToString(), "OrderEvent"); } else { Assert.Fail(); } }
public void TestSchemaFromClass() { var epl = EventRepresentationChoice.AVRO.GetAnnotationText() + "insert into MyEvent select " + this.GetType().FullName + ".MakeDateTime() as isodate from SupportBean as e1"; var stmt = _epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.AddListener(listener); Schema schema = SupportAvroUtil.GetAvroSchema(stmt.EventType); Assert.AreEqual("{\"type\":\"record\",\"name\":\"MyEvent\",\"fields\":[{\"name\":\"isodate\",\"type\":\"string\"}]}", schema.ToString()); _epService.EPRuntime.SendEvent(new SupportBean("E1", 10)); var @event = listener.AssertOneGetNewAndReset(); SupportAvroUtil.AvroToJson(@event); Assert.IsTrue(@event.Get("isodate").ToString().Length > 10); }
public void Run(RegressionEnvironment env) { var epl = eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedSchemaOne>() + " @name('schema') create schema SchemaOne(col1 int, col2 int);\n"; epl += eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedSchemaWindow>() + " @name('create') create window SchemaWindow#lastevent as (s1 SchemaOne);\n"; epl += "insert into SchemaWindow (s1) select sone from SchemaOne as sone;\n"; env.CompileDeployWBusPublicType(epl, new RegressionPath()).AddListener("create"); Assert.IsTrue(eventRepresentationEnum.MatchesClass(env.Statement("schema").EventType.UnderlyingType)); Assert.IsTrue(eventRepresentationEnum.MatchesClass(env.Statement("create").EventType.UnderlyingType)); if (eventRepresentationEnum.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {10, 11}, "SchemaOne"); } else if (eventRepresentationEnum.IsMapEvent()) { IDictionary<string, object> theEvent = new Dictionary<string, object>(); theEvent.Put("col1", 10); theEvent.Put("col2", 11); env.SendEventMap(theEvent, "SchemaOne"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord( SupportAvroUtil .GetAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("SchemaOne")) .AsRecordSchema()); theEvent.Put("col1", 10); theEvent.Put("col2", 11); env.EventService.SendEventAvro(theEvent, "SchemaOne"); } else if (eventRepresentationEnum.IsJsonEvent() || eventRepresentationEnum.IsJsonProvidedClassEvent()) { env.EventService.SendEventJson("{\"col1\": 10, \"col2\": 11}", "SchemaOne"); } else { Assert.Fail(); } EPAssertionUtil.AssertProps( env.Listener("create").AssertOneGetNewAndReset(), new[] {"s1.col1", "s1.col2"}, new object[] {10, 11}); env.UndeployAll(); }
private void TryAssertionWildcard(EPServiceProvider epService, bool bean, EventRepresentationChoice?rep) { if (bean) { epService.EPAdministrator.CreateEPL("create schema MySchema as " + typeof(MyP0P1Event).FullName); } else { epService.EPAdministrator.CreateEPL("create " + rep.Value.GetOutputTypeCreateSchemaName() + " schema MySchema (p0 string, p1 string)"); } EPStatement stmtTheTable = epService.EPAdministrator.CreateEPL("create table TheTable (p0 string, p1 string)"); epService.EPAdministrator.CreateEPL("insert into TheTable select * from MySchema"); if (bean) { epService.EPRuntime.SendEvent(new MyP0P1Event("a", "b")); } else if (rep.Value.IsMapEvent()) { var map = new Dictionary <string, Object>(); map.Put("p0", "a"); map.Put("p1", "b"); epService.EPRuntime.SendEvent(map, "MySchema"); } else if (rep.Value.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent(new object[] { "a", "b" }, "MySchema"); } else if (rep.Value.IsAvroEvent()) { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, "MySchema").AsRecordSchema()); theEvent.Put("p0", "a"); theEvent.Put("p1", "b"); epService.EPRuntime.SendEventAvro(theEvent, "MySchema"); } EPAssertionUtil.AssertProps(stmtTheTable.First(), "p0,p1".Split(','), new object[] { "a", "b" }); epService.EPAdministrator.DestroyAllStatements(); epService.EPAdministrator.Configuration.RemoveEventType("MySchema", false); epService.EPAdministrator.DestroyAllStatements(); }
private void RunAssertionEventTypeColumnDef(EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum) { EPStatement stmtSchema = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create schema SchemaOne(col1 int, col2 int)"); Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtSchema.EventType.UnderlyingType)); EPStatement stmt = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window SchemaWindow#lastevent as (s1 SchemaOne)"); Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmt.EventType.UnderlyingType)); var listenerWindow = new SupportUpdateListener(); stmt.Events += listenerWindow.Update; epService.EPAdministrator.CreateEPL("insert into SchemaWindow (s1) select sone from SchemaOne as sone"); if (eventRepresentationEnum.IsObjectArrayEvent()) { epService.EPRuntime.SendEvent(new object[] { 10, 11 }, "SchemaOne"); } else if (eventRepresentationEnum.IsMapEvent()) { var theEvent = new LinkedHashMap <string, object>(); theEvent.Put("col1", 10); theEvent.Put("col2", 11); epService.EPRuntime.SendEvent(theEvent, "SchemaOne"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(epService, "SchemaOne").AsRecordSchema()); theEvent.Put("col1", 10); theEvent.Put("col2", 11); epService.EPRuntime.SendEventAvro(theEvent, "SchemaOne"); } else { Assert.Fail(); } 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); }
private static void MakeSendScoreEvent( RegressionEnvironment env, string typeName, EventRepresentationChoice eventRepresentationEnum, string userId, string keyword, string productId, long score) { if (eventRepresentationEnum.IsMapEvent()) { IDictionary<string, object> theEvent = new LinkedHashMap<string, object>(); theEvent.Put("UserId", userId); theEvent.Put("Keyword", keyword); theEvent.Put("ProductId", productId); theEvent.Put("Score", score); env.SendEventMap(theEvent, typeName); } else if (eventRepresentationEnum.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {userId, keyword, productId, score}, typeName); } else if (eventRepresentationEnum.IsAvroEvent()) { var record = new GenericRecord( SupportAvroUtil.GetAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(typeName)) .AsRecordSchema()); record.Put("UserId", userId); record.Put("Keyword", keyword); record.Put("ProductId", productId); record.Put("Score", score); env.SendEventAvro(record, typeName); } else if (eventRepresentationEnum.IsJsonEvent() || eventRepresentationEnum.IsJsonProvidedClassEvent()) { var jobject = new JObject(); jobject.Add("UserId", userId); jobject.Add("Keyword", keyword); jobject.Add("ProductId", productId); jobject.Add("Score", score); env.SendEventJson(jobject.ToString(), typeName); } else { Assert.Fail(); } }
public void Run(RegressionEnvironment env) { var epl = "@Name('s0') " + EventRepresentationChoice.AVRO.GetAnnotationText() + "insert into MyEventOut select " + typeof(EventAvroHook).FullName + ".MakeDateTimeOffset() as isodate from SupportBean as e1"; env.CompileDeploy(epl).AddListener("s0"); var schema = SupportAvroUtil.GetAvroSchema(env.Statement("s0").EventType); Assert.AreEqual( "{\"type\":\"record\",\"name\":\"MyEventOut\",\"fields\":[{\"name\":\"isodate\",\"type\":\"string\"}]}", schema.ToString()); env.SendEventBean(new SupportBean("E1", 10)); var @event = env.Listener("s0").AssertOneGetNewAndReset(); SupportAvroUtil.AvroToJson(@event); Assert.IsTrue(@event.Get("isodate").ToString().Length > 10); env.UndeployAll(); }
private void TryAssertionCreateSchemaModelAfter( RegressionEnvironment env, EventRepresentationChoice eventRepresentationEnum) { var epl = eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedEventTypeOne>() + " create schema EventTypeOne (hsi int);\n" + eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedEventTypeTwo>() + " create schema EventTypeTwo (event EventTypeOne);\n" + "@Name('create') create window NamedWindow#unique(event.hsi) as EventTypeTwo;\n" + "on EventTypeOne as ev insert into NamedWindow select ev as event;\n"; env.CompileDeployWBusPublicType(epl, new RegressionPath()); if (eventRepresentationEnum.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {10}, "EventTypeOne"); } else if (eventRepresentationEnum.IsMapEvent()) { env.SendEventMap(Collections.SingletonDataMap("hsi", 10), "EventTypeOne"); } else if (eventRepresentationEnum.IsAvroEvent()) { var theEvent = new GenericRecord( SupportAvroUtil .GetAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("EventTypeOne")) .AsRecordSchema()); theEvent.Put("hsi", 10); env.EventService.SendEventAvro(theEvent, "EventTypeOne"); } else if (eventRepresentationEnum.IsJsonEvent() || eventRepresentationEnum.IsJsonProvidedClassEvent()) { env.EventService.SendEventJson("{\"hsi\": 10}", "EventTypeOne"); } else { Assert.Fail(); } var result = env.Statement("create").First(); var getter = result.EventType.GetGetter("event.hsi"); Assert.AreEqual(10, getter.Get(result)); env.UndeployAll(); }