private void TryAssertionNewWRepresentation(EPServiceProvider epService, EventRepresentationChoice rep) { string epl = rep.GetAnnotationText() + "select new { TheString = 'x' || TheString || 'x', IntPrimitive = IntPrimitive + 2} as val0 from SupportBean as sb"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; Assert.AreEqual(rep.IsAvroEvent() ? typeof(GenericRecord) : typeof(Map), stmt.EventType.GetPropertyType("val0")); FragmentEventType fragType = stmt.EventType.GetFragmentType("val0"); Assert.IsFalse(fragType.IsIndexed); Assert.IsFalse(fragType.IsNative); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("TheString")); Assert.AreEqual(typeof(int?), TypeHelper.GetBoxedType(fragType.FragmentType.GetPropertyType("IntPrimitive"))); string[] fieldsInner = "TheString,IntPrimitive".Split(','); epService.EPRuntime.SendEvent(new SupportBean("E1", -5)); EventBean @event = listener.AssertOneGetNewAndReset(); if (rep.IsAvroEvent()) { SupportAvroUtil.AvroToJson(@event); GenericRecord inner = (GenericRecord)@event.Get("val0"); Assert.AreEqual("xE1x", inner.Get("TheString")); Assert.AreEqual(-3, inner.Get("IntPrimitive")); } else { EPAssertionUtil.AssertPropsMap((Map)@event.Get("val0"), fieldsInner, new object[] { "xE1x", -3 }); } stmt.Dispose(); }
public void TestParse() { Object result; Assert.AreEqual("abc", ParseLoadJson("\"abc\"")); Assert.AreEqual("http://www.uri.com", ParseLoadJson("\"http://www.uri.com\"")); Assert.AreEqual("new\nline", ParseLoadJson("\"new\\nline\"")); Assert.AreEqual(" ~ ", ParseLoadJson("\" \\u007E \"")); Assert.AreEqual("/", ParseLoadJson("\"\\/\"")); Assert.AreEqual(true, ParseLoadJson("true")); Assert.AreEqual(false, ParseLoadJson("false")); Assert.AreEqual(null, ParseLoadJson("null")); Assert.AreEqual(10, ParseLoadJson("10")); Assert.AreEqual(-10, ParseLoadJson("-10")); Assert.AreEqual(20L, ParseLoadJson("20L")); Assert.AreEqual(5.5d, ParseLoadJson("5.5")); result = ParseLoadJson("{\"name\":\"myname\",\"value\":5}"); EPAssertionUtil.AssertPropsMap((Map)result, "name,value".Split(','), "myname", 5); result = ParseLoadJson("{name:\"myname\",value:5}"); EPAssertionUtil.AssertPropsMap((Map)result, "name,value".Split(','), "myname", 5); result = ParseLoadJson("[\"one\",2]"); EPAssertionUtil.AssertEqualsExactOrder(new Object[] { "one", 2 }, (IList <object>)result); result = ParseLoadJson("{\"one\": { 'a' : 2 } }"); Map inner = (Map)((Map)result).Get("one"); Assert.AreEqual(1, inner.Count); String json = "{\n" + " \"glossary\": {\n" + " \"title\": \"example glossary\",\n" + "\t\t\"GlossDiv\": {\n" + " \"title\": \"S\",\n" + "\t\t\t\"GlossList\": {\n" + " \"GlossEntry\": {\n" + " \"ID\": \"SGML\",\n" + "\t\t\t\t\t\"SortAs\": \"SGML\",\n" + "\t\t\t\t\t\"GlossTerm\": \"Standard Generalized Markup Language\",\n" + "\t\t\t\t\t\"Acronym\": \"SGML\",\n" + "\t\t\t\t\t\"Abbrev\": \"ISO 8879:1986\",\n" + "\t\t\t\t\t\"GlossDef\": {\n" + " \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\n" + "\t\t\t\t\t\t\"GlossSeeAlso\": [\"GML\", \"XML\"]\n" + " },\n" + "\t\t\t\t\t\"GlossSee\": \"markup\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}"; ITree tree = ParseJson(json).First; ASTUtil.DumpAST(tree); Object loaded = ParseLoadJson(json); Assert.AreEqual("{glossary={title=example glossary, GlossDiv={title=S, GlossList={GlossEntry={ID=SGML, SortAs=SGML, GlossTerm=Standard Generalized Markup Language, Acronym=SGML, Abbrev=ISO 8879:1986, GlossDef={para=A meta-markup language, used to create markup languages such as DocBook., GlossSeeAlso=[GML, XML]}, GlossSee=markup}}}}}", loaded.RenderAny()); }
public void AssertIRStreamAndReset( EPStatement stmt, string[] fields, object[] expectedIStream, object[] expectedRStream) { AssertStmtMultipleReceived(stmt, 1 + (expectedRStream == null ? 0 : 1)); Assert.AreEqual(1, _indicateIStream.Count); EPAssertionUtil.AssertPropsMap(_indicateIStream[0], fields, expectedIStream); if (expectedRStream == null) { Assert.IsTrue(_indicateRStream.IsEmpty()); } else { Assert.AreEqual(1, _indicateRStream.Count); EPAssertionUtil.AssertPropsMap(_indicateRStream[0], fields, expectedRStream); } _indicateIStream.Clear(); _indicateRStream.Clear(); ResetStmts(); }
private void AssertResults(EPStatement stmt, string[] fields, object[] values) { var @event = stmt.First(); var map = (IDictionary <string, object>)@event.Get("varagg"); EPAssertionUtil.AssertPropsMap(map, fields, values); }
private void RunAssertion(string epl) { EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.AddListener(_listener); Assert.AreEqual(typeof(IDictionary <string, object>), stmt.EventType.GetPropertyType("val0")); FragmentEventType fragType = stmt.EventType.GetFragmentType("val0"); Assert.IsFalse(fragType.IsIndexed); Assert.IsFalse(fragType.IsNative); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("col1")); Assert.AreEqual(typeof(int?), fragType.FragmentType.GetPropertyType("col2")); string[] fieldsInner = "col1,col2".Split(','); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "Z", 30 }); _epService.EPRuntime.SendEvent(new SupportBean("A", 2)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "X", 10 }); _epService.EPRuntime.SendEvent(new SupportBean("B", 3)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "Y", 20 }); _epService.EPRuntime.SendEvent(new SupportBean("C", 4)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { null, null }); stmt.Dispose(); }
public void RunOnMergeInsertUpdDeleteUngrouped(bool soda) { var eplDeclare = "create table varagg (p0 string, sumint sum(int))"; SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplDeclare); var fields = "c0,c1".Split(','); var eplRead = "select varagg.p0 as c0, varagg.sumint as c1, varagg as c2 from SupportBean_S0"; EPStatement stmtRead = SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplRead); stmtRead.AddListener(_listener); // assert selected column types var expectedAggType = new object[][] { new object[] { "c0", typeof(string) }, new object[] { "c1", typeof(int?) } }; EventTypeAssertionUtil.AssertEventTypeProperties(expectedAggType, stmtRead.EventType, EventTypeAssertionEnum.NAME, EventTypeAssertionEnum.TYPE); // assert no row _epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { null, null }); // create merge var eplMerge = "on SupportBean merge varagg" + " when not matched then" + " insert select TheString as p0" + " when matched and TheString like \"U%\" then" + " update set p0=\"updated\"" + " when matched and TheString like \"D%\" then" + " delete"; SupportModelHelper.CreateByCompileOrParse(_epService, soda, eplMerge); // merge for varagg _epService.EPRuntime.SendEvent(new SupportBean("E1", 0)); // assert _epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", null }); // also aggregate-into the same key SupportModelHelper.CreateByCompileOrParse(_epService, soda, "into table varagg select sum(50) as sumint from SupportBean_S1"); _epService.EPRuntime.SendEvent(new SupportBean_S1(0)); _epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 50 }); // update for varagg _epService.EPRuntime.SendEvent(new SupportBean("U2", 10)); _epService.EPRuntime.SendEvent(new SupportBean_S0(0)); var received = _listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(received, fields, new object[] { "updated", 50 }); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)received.Get("c2"), "p0,sumint".Split(','), new object[] { "updated", 50 }); // delete for varagg _epService.EPRuntime.SendEvent(new SupportBean("D3", 0)); _epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new object[] { null, null }); _epService.EPAdministrator.DestroyAllStatements(); }
private void AssertReceived(SupportBean[] beans, int[] indexesAll, int[] indexesWhere, string[] mapKeys, object[] mapValues) { var received = _listenerStmtOne.AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsExactOrder(SupportBean.GetBeansPerIndex(beans, indexesAll), (object[])received.Get("c0")); EPAssertionUtil.AssertEqualsExactOrder(SupportBean.GetBeansPerIndex(beans, indexesWhere), received.Get("c1").Unwrap <object>()); EPAssertionUtil.AssertPropsMap((IDictionary <object, object>)received.Get("c2"), mapKeys, mapValues); }
private void RunAssertionTopLevelReadUnGrouped(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType(typeof(AggBean)); epService.EPAdministrator.CreateEPL("create objectarray schema MyEventOATLRU(c0 int)"); epService.EPAdministrator.CreateEPL( "create table windowAndTotalTLRUG (" + "thewindow window(*) @Type(MyEventOATLRU), thetotal sum(int))"); epService.EPAdministrator.CreateEPL( "into table windowAndTotalTLRUG " + "select window(*) as thewindow, sum(c0) as thetotal from MyEventOATLRU#length(2)"); var stmt = epService.EPAdministrator.CreateEPL("select windowAndTotalTLRUG as val0 from SupportBean_S0"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var e1 = new object[] { 10 }; epService.EPRuntime.SendEvent(e1, "MyEventOATLRU"); var fieldsInner = "thewindow,thetotal".Split(','); epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertPropsMap( (Map)listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[][] { e1 }, 10); var e2 = new object[] { 20 }; epService.EPRuntime.SendEvent(e2, "MyEventOATLRU"); epService.EPRuntime.SendEvent(new SupportBean_S0(1)); EPAssertionUtil.AssertPropsMap( (Map)listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[][] { e1, e2 }, 30); var e3 = new object[] { 30 }; epService.EPRuntime.SendEvent(e3, "MyEventOATLRU"); epService.EPRuntime.SendEvent(new SupportBean_S0(2)); EPAssertionUtil.AssertPropsMap( (Map)listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[][] { e2, e3 }, 50); // test typable output stmt.Dispose(); var stmtConvert = epService.EPAdministrator.CreateEPL( "insert into AggBean select windowAndTotalTLRUG as val0 from SupportBean_S0"); stmtConvert.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_S0(2)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), "val0.thewindow,val0.thetotal".Split(','), new object[] { new object[][] { e2, e3 }, 50 }); epService.EPAdministrator.DestroyAllStatements(); }
private void AssertMapField(string fieldName, EventBean @event, string[] names, object[] values) { var subq = (IDictionary <string, object>)@event.Get(fieldName); if (values == null && subq == null) { return; } EPAssertionUtil.AssertPropsMap(subq, names, values); }
private static void CompareMap( object received, string keyCSV, params object[] values) { var keys = string.IsNullOrWhiteSpace(keyCSV) ? new string[0] : keyCSV.SplitCsv(); var receivedDictionary = received.AsObjectDictionary(); EPAssertionUtil.AssertPropsMap(receivedDictionary, keys, values); }
public override void Run(EPServiceProvider epService) { // - duplicate value allowed, latest value wins // - null key & value allowed string eplFragment = "select Contained.ToMap(c => id, c=> p00) as val from Bean"; EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment); var listener = new SupportUpdateListener(); stmtFragment.Events += listener.Update; LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, "val".Split(','), new Type[] { typeof(IDictionary <object, object>) }); epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,5")); EPAssertionUtil.AssertPropsMap(listener.AssertOneGetNewAndReset().Get("val").UnwrapStringDictionary(), "E1,E2,E3".Split(','), new object[] { 1, 5, 12 }); epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,12", "E1,2")); EPAssertionUtil.AssertPropsMap(listener.AssertOneGetNewAndReset().Get("val").UnwrapStringDictionary(), "E1,E2,E3".Split(','), new object[] { 2, 12, 12 }); epService.EPRuntime.SendEvent(new SupportBean_ST0_Container(Collections.SingletonList(new SupportBean_ST0(null, null)))); EPAssertionUtil.AssertPropsMap(listener.AssertOneGetNewAndReset().Get("val").UnwrapStringDictionary(), "E1,E2,E3".Split(','), new object[] { null, null, null }); stmtFragment.Dispose(); // test scalar-coll with lambda string[] fields = "val0".Split(','); epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("extractNum", typeof(ExecEnumMinMax.MyService), "ExtractNum"); string eplLambda = "select " + "Strvals.ToMap(c => c, c => extractNum(c)) as val0 " + "from SupportCollection"; EPStatement stmtLambda = epService.EPAdministrator.CreateEPL(eplLambda); stmtLambda.Events += listener.Update; LambdaAssertionUtil.AssertTypes(stmtLambda.EventType, fields, new Type[] { typeof(IDictionary <object, object>) }); epService.EPRuntime.SendEvent(SupportCollection.MakeString("E2,E1,E3")); EPAssertionUtil.AssertPropsMap( listener.AssertOneGetNewAndReset().Get("val0").UnwrapDictionary(), "E1,E2,E3".Split(','), new object[] { 1, 2, 3 }); epService.EPRuntime.SendEvent(SupportCollection.MakeString("E1")); EPAssertionUtil.AssertPropsMap( listener.AssertOneGetNewAndReset().Get("val0").UnwrapDictionary(), "E1".Split(','), new object[] { 1 }); epService.EPRuntime.SendEvent(SupportCollection.MakeString(null)); Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val0")); epService.EPRuntime.SendEvent(SupportCollection.MakeString("")); Assert.AreEqual(0, listener.AssertOneGetNewAndReset().Get("val0").Unwrap <object>().Count); }
private void RunAssertionRowMapDelivery(EventRepresentationEnum eventRepresentationEnum) { var subscriber = new MySubscriberRowByRowMap(); EPStatement stmt = _epService.EPAdministrator.CreateEPL( eventRepresentationEnum.GetAnnotationText() + " select irstream TheString, IntPrimitive from SupportBean.std:unique(TheString)"); stmt.Subscriber = subscriber; Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmt.EventType.UnderlyingType); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsMap( subscriber.GetAndResetIndicateIStream()[0], _fields, new Object[] { "E1", 1 } ); Assert.AreEqual(0, subscriber.GetAndResetIndicateRStream().Count); _epService.EPRuntime.SendEvent(new SupportBean("E2", 10)); EPAssertionUtil.AssertPropsMap( subscriber.GetAndResetIndicateIStream()[0], _fields, new Object[] { "E2", 10 } ); Assert.AreEqual(0, subscriber.GetAndResetIndicateRStream().Count); _epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); EPAssertionUtil.AssertPropsMap( subscriber.GetAndResetIndicateIStream()[0], _fields, new Object[] { "E1", 2 } ); EPAssertionUtil.AssertPropsMap( subscriber.GetAndResetIndicateRStream()[0], _fields, new Object[] { "E1", 1 } ); _epService.EPAdministrator.DestroyAllStatements(); }
private void RunAssertionTopLevelReadGrouped2Keys(bool soda) { SupportModelHelper.CreateByCompileOrParse(_epService, soda, "create objectarray schema MyEvent as (c0 int, c1 string, c2 int)"); SupportModelHelper.CreateByCompileOrParse(_epService, soda, "create table windowAndTotal (" + "keyi int primary key, keys string primary key, TheWindow window(*) @type('MyEvent'), TheTotal sum(int))"); SupportModelHelper.CreateByCompileOrParse(_epService, soda, "into table windowAndTotal " + "select window(*) as TheWindow, sum(c2) as TheTotal from MyEvent.win:length(2) group by c0, c1"); var stmtSelect = SupportModelHelper.CreateByCompileOrParse(_epService, soda, "select windowAndTotal[id,p00] as Val0 from SupportBean_S0"); stmtSelect.AddListener(_listener); AssertTopLevelTypeInfo(stmtSelect); var e1 = new object[] { 10, "G1", 100 }; _epService.EPRuntime.SendEvent(e1, "MyEvent"); var fieldsInner = "TheWindow,TheTotal".Split(','); _epService.EPRuntime.SendEvent(new SupportBean_S0(10, "G1")); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("Val0"), fieldsInner, new object[][] { e1 }, 100); var e2 = new object[] { 20, "G2", 200 }; _epService.EPRuntime.SendEvent(e2, "MyEvent"); _epService.EPRuntime.SendEvent(new SupportBean_S0(20, "G2")); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("Val0"), fieldsInner, new object[][] { e2 }, 200); var e3 = new object[] { 20, "G2", 300 }; _epService.EPRuntime.SendEvent(e3, "MyEvent"); _epService.EPRuntime.SendEvent(new SupportBean_S0(10, "G1")); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("Val0"), fieldsInner, null, null); _epService.EPRuntime.SendEvent(new SupportBean_S0(20, "G2")); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("Val0"), fieldsInner, new object[][] { e2, e3 }, 500); // test typable output stmtSelect.Dispose(); var stmtConvert = _epService.EPAdministrator.CreateEPL("insert into AggBean select windowAndTotal[20, 'G2'] as Val0 from SupportBean_S0"); stmtConvert.AddListener(_listener); _epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "Val0.TheWindow,Val0.TheTotal".Split(','), new object[] { new object[][] { e2, e3 }, 500 }); _epService.EPAdministrator.DestroyAllStatements(); }
private static void TryAssertion( RegressionEnvironment env, string epl, AtomicLong milestone) { env.CompileDeploy(epl).AddListener("s0").Milestone(milestone.GetAndIncrement()); Assert.AreEqual(typeof(IDictionary <string, object>), env.Statement("s0").EventType.GetPropertyType("val0")); var fragType = env.Statement("s0").EventType.GetFragmentType("val0"); Assert.IsFalse(fragType.IsIndexed); Assert.IsFalse(fragType.IsNative); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("col1")); Assert.AreEqual(typeof(int?), fragType.FragmentType.GetPropertyType("col2")); var fieldsInner = "col1,col2".SplitCsv(); env.SendEventBean(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsMap( (IDictionary <string, object>)env.Listener("s0").AssertOneGetNewAndReset().Get("val0"), fieldsInner, "Z", 30); env.SendEventBean(new SupportBean("A", 2)); EPAssertionUtil.AssertPropsMap( (IDictionary <string, object>)env.Listener("s0").AssertOneGetNewAndReset().Get("val0"), fieldsInner, "X", 10); env.SendEventBean(new SupportBean("B", 3)); EPAssertionUtil.AssertPropsMap( (IDictionary <string, object>)env.Listener("s0").AssertOneGetNewAndReset().Get("val0"), fieldsInner, "Y", 20); env.SendEventBean(new SupportBean("C", 4)); EPAssertionUtil.AssertPropsMap( (IDictionary <string, object>)env.Listener("s0").AssertOneGetNewAndReset().Get("val0"), fieldsInner, null, null); env.UndeployAll(); }
private static void TryAssertionNewWRepresentation( RegressionEnvironment env, EventRepresentationChoice rep, AtomicLong milestone) { var epl = rep.GetAnnotationTextWJsonProvided <MyLocalJsonProvided>() + "@Name('s0') select new { TheString = 'x' || TheString || 'x', IntPrimitive = IntPrimitive + 2} as val0 from SupportBean as sb"; env.CompileDeploy(epl).AddListener("s0").Milestone(milestone.GetAndIncrement()); Assert.AreEqual( rep.IsAvroEvent() ? typeof(GenericRecord) : typeof(IDictionary <string, object>), env.Statement("s0").EventType.GetPropertyType("val0")); var fragType = env.Statement("s0").EventType.GetFragmentType("val0"); if (rep == EventRepresentationChoice.JSONCLASSPROVIDED) { Assert.IsNull(fragType); } else { Assert.IsFalse(fragType.IsIndexed); Assert.IsFalse(fragType.IsNative); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("TheString")); Assert.AreEqual(typeof(int?), Boxing.GetBoxedType(fragType.FragmentType.GetPropertyType("IntPrimitive"))); } var fieldsInner = "TheString,IntPrimitive".SplitCsv(); env.SendEventBean(new SupportBean("E1", -5)); var @event = env.Listener("s0").AssertOneGetNewAndReset(); if (rep.IsAvroEvent()) { SupportAvroUtil.AvroToJson(@event); GenericRecord inner = (GenericRecord)@event.Get("val0"); Assert.AreEqual("xE1x", inner.Get("TheString")); Assert.AreEqual(-3, inner.Get("IntPrimitive")); } else { EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)@event.Get("val0"), fieldsInner, "xE1x", -3); } env.UndeployAll(); }
public void TestTopLevelReadUnGrouped() { _epService.EPAdministrator.Configuration.AddEventType(typeof(AggBean)); _epService.EPAdministrator.CreateEPL("create objectarray schema MyEvent(c0 int)"); _epService.EPAdministrator.CreateEPL("create table windowAndTotal (" + "TheWindow window(*) @type(MyEvent), TheTotal sum(int))"); _epService.EPAdministrator.CreateEPL("into table windowAndTotal " + "select window(*) as TheWindow, sum(c0) as TheTotal from MyEvent.win:length(2)"); var stmt = _epService.EPAdministrator.CreateEPL("select windowAndTotal as Val0 from SupportBean_S0"); stmt.AddListener(_listener); var e1 = new object[] { 10 }; _epService.EPRuntime.SendEvent(e1, "MyEvent"); var fieldsInner = "TheWindow,TheTotal".Split(','); _epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("Val0"), fieldsInner, new object[][] { e1 }, 10); var e2 = new object[] { 20 }; _epService.EPRuntime.SendEvent(e2, "MyEvent"); _epService.EPRuntime.SendEvent(new SupportBean_S0(1)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("Val0"), fieldsInner, new object[][] { e1, e2 }, 30); var e3 = new object[] { 30 }; _epService.EPRuntime.SendEvent(e3, "MyEvent"); _epService.EPRuntime.SendEvent(new SupportBean_S0(2)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("Val0"), fieldsInner, new object[][] { e2, e3 }, 50); // test typable output stmt.Dispose(); var stmtConvert = _epService.EPAdministrator.CreateEPL("insert into AggBean select windowAndTotal as Val0 from SupportBean_S0"); stmtConvert.AddListener(_listener); _epService.EPRuntime.SendEvent(new SupportBean_S0(2)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "Val0.TheWindow,Val0.TheTotal".Split(','), new object[] { new object[][] { e2, e3 }, 50 }); }
public void TestVariables() { String[] fields = "myvar".Split(','); SubscriberMap subscriberCreateVariable = new SubscriberMap(); String stmtTextCreate = "create variable string myvar = 'abc'"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtTextCreate); stmt.Subscriber = subscriberCreateVariable; SubscriberMap subscriberSetVariable = new SubscriberMap(); String stmtTextSet = "on SupportBean set myvar = TheString"; stmt = _epService.EPAdministrator.CreateEPL(stmtTextSet); stmt.Subscriber = subscriberSetVariable; _epService.EPRuntime.SendEvent(new SupportBean("def", 1)); EPAssertionUtil.AssertPropsMap(subscriberCreateVariable.GetAndResetIndicate()[0], fields, new Object[] { "def" }); EPAssertionUtil.AssertPropsMap(subscriberSetVariable.GetAndResetIndicate()[0], fields, new Object[] { "def" }); }
public void TestToMap() { // - duplicate value allowed, latest value wins // - null key & value allowed String eplFragment = "select contained.toMap(c => id, c=> p00) as val from Bean"; EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment); stmtFragment.Events += _listener.Update; LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, "val".Split(','), new Type[] { typeof(AnyMap) }); _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,5")); ArrayAssertionUtil.AssertPropsMap(ToDataMap(_listener.AssertOneGetNewAndReset().Get("val")), "E1,E2,E3".Split(','), new Object[] { 1, 5, 12 }); _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,12", "E1,2")); ArrayAssertionUtil.AssertPropsMap(ToDataMap(_listener.AssertOneGetNewAndReset().Get("val")), "E1,E2,E3".Split(','), new Object[] { 2, 12, 12 }); _epService.EPRuntime.SendEvent(new SupportBean_ST0_Container(new SupportBean_ST0[] { new SupportBean_ST0(null, null) })); ArrayAssertionUtil.AssertPropsMap(ToDataMap(_listener.AssertOneGetNewAndReset().Get("val")), "E1,E2,E3".Split(','), new Object[] { null, null, null }); stmtFragment.Dispose(); // test scalar-coll with lambda String[] fields = "val0".SplitCsv(); _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("extractNum", typeof(TestEnumMinMax.MyService).FullName, "ExtractNum"); String eplLambda = "select Strvals.toMap(c => c, c => extractNum(c)) as val0 from SupportCollection"; EPStatement stmtLambda = _epService.EPAdministrator.CreateEPL(eplLambda); stmtLambda.Events += _listener.Update; LambdaAssertionUtil.AssertTypes(stmtLambda.EventType, fields, new [] { typeof(AnyMap) }); _epService.EPRuntime.SendEvent(SupportCollection.MakeString("E2,E1,E3")); EPAssertionUtil.AssertPropsMap((AnyMap)_listener.AssertOneGetNewAndReset().Get("val0"), "E1,E2,E3".SplitCsv(), new Object[] { 1, 2, 3 }); _epService.EPRuntime.SendEvent(SupportCollection.MakeString("E1")); EPAssertionUtil.AssertPropsMap((AnyMap)_listener.AssertOneGetNewAndReset().Get("val0"), "E1".SplitCsv(), new Object[] { 1 }); _epService.EPRuntime.SendEvent(SupportCollection.MakeString(null)); Assert.IsNull(_listener.AssertOneGetNewAndReset().Get("val0")); _epService.EPRuntime.SendEvent(SupportCollection.MakeString("")); Assert.AreEqual(0, ((AnyMap)_listener.AssertOneGetNewAndReset().Get("val0")).Count); }
private void TryAssertionNamedWindow(EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum) { var fields = "key,value".Split(','); var subscriberNamedWindow = new SubscriberMap(); var stmtTextCreate = eventRepresentationEnum.GetAnnotationText() + " create window MyWindow#keepall as select TheString as key, IntPrimitive as value from SupportBean"; var stmt = epService.EPAdministrator.CreateEPL(stmtTextCreate); stmt.Subscriber = subscriberNamedWindow; var subscriberInsertInto = new SubscriberFields(); var stmtTextInsertInto = "insert into MyWindow select TheString as key, IntPrimitive as value from SupportBean"; stmt = epService.EPAdministrator.CreateEPL(stmtTextInsertInto); stmt.Subscriber = subscriberInsertInto; epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsMap(subscriberNamedWindow.GetAndResetIndicate()[0], fields, new object[] { "E1", 1 }); EPAssertionUtil.AssertEqualsExactOrder(new object[][] { new object[] { "E1", 1 } }, subscriberInsertInto.GetAndResetIndicate()); // test on-delete var subscriberDelete = new SubscriberMap(); var stmtTextDelete = "on SupportMarketDataBean s0 delete from MyWindow s1 where s0.symbol = s1.key"; stmt = epService.EPAdministrator.CreateEPL(stmtTextDelete); stmt.Subscriber = subscriberDelete; epService.EPRuntime.SendEvent(new SupportMarketDataBean("E1", 0, 1L, "")); EPAssertionUtil.AssertPropsMap(subscriberDelete.GetAndResetIndicate()[0], fields, new object[] { "E1", 1 }); // test on-select var subscriberSelect = new SubscriberMap(); var stmtTextSelect = "on SupportMarketDataBean s0 select key, value from MyWindow s1"; stmt = epService.EPAdministrator.CreateEPL(stmtTextSelect); stmt.Subscriber = subscriberSelect; epService.EPRuntime.SendEvent(new SupportBean("E2", 2)); epService.EPRuntime.SendEvent(new SupportMarketDataBean("M1", 0, 1L, "")); EPAssertionUtil.AssertPropsMap(subscriberSelect.GetAndResetIndicate()[0], fields, new object[] { "E2", 2 }); epService.EPAdministrator.DestroyAllStatements(); }
public void TestNewAlone() { string epl = "select new { theString = 'x' || theString || 'x', intPrimitive = intPrimitive + 2} as val0 from SupportBean as sb"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.AddListener(_listener); Assert.AreEqual(typeof(IDictionary <string, object>), stmt.EventType.GetPropertyType("val0")); var fragType = stmt.EventType.GetFragmentType("val0"); Assert.IsFalse(fragType.IsIndexed); Assert.IsFalse(fragType.IsNative); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("theString")); Assert.AreEqual(typeof(int?), fragType.FragmentType.GetPropertyType("intPrimitive")); string[] fieldsInner = "theString,intPrimitive".Split(','); _epService.EPRuntime.SendEvent(new SupportBean("E1", -5)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "xE1x", -3 }); }
private void RunAssertionVariables(EPServiceProvider epService) { var fields = "myvar".Split(','); var subscriberCreateVariable = new SubscriberMap(); var stmtTextCreate = "create variable string myvar = 'abc'"; var stmt = epService.EPAdministrator.CreateEPL(stmtTextCreate); stmt.Subscriber = subscriberCreateVariable; var subscriberSetVariable = new SubscriberMap(); var stmtTextSet = "on SupportBean set myvar = TheString"; stmt = epService.EPAdministrator.CreateEPL(stmtTextSet); stmt.Subscriber = subscriberSetVariable; epService.EPRuntime.SendEvent(new SupportBean("def", 1)); EPAssertionUtil.AssertPropsMap(subscriberCreateVariable.GetAndResetIndicate()[0], fields, new object[] { "def" }); EPAssertionUtil.AssertPropsMap(subscriberSetVariable.GetAndResetIndicate()[0], fields, new object[] { "def" }); stmt.Dispose(); }
private void RunAssertionDefault(EPStatement stmt) { Assert.AreEqual(typeof(IDictionary <string, object>), stmt.EventType.GetPropertyType("val0")); FragmentEventType fragType = stmt.EventType.GetFragmentType("val0"); Assert.IsFalse(fragType.IsIndexed); Assert.IsFalse(fragType.IsNative); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("theString")); Assert.AreEqual(typeof(int?), fragType.FragmentType.GetPropertyType("intPrimitive")); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("col2")); string[] fieldsInner = "theString,intPrimitive,col2".Split(','); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { null, null, null }); _epService.EPRuntime.SendEvent(new SupportBean("A", 2)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "Q", 2, "AA" }); _epService.EPRuntime.SendEvent(new SupportBean("B", 3)); EPAssertionUtil.AssertPropsMap((IDictionary <string, object>)_listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[] { "B", 10, "BB" }); stmt.Dispose(); }
private static void TryAssertionDefault(RegressionEnvironment env) { Assert.AreEqual(typeof(IDictionary <string, object>), env.Statement("s0").EventType.GetPropertyType("val0")); var fragType = env.Statement("s0").EventType.GetFragmentType("val0"); Assert.IsFalse(fragType.IsIndexed); Assert.IsFalse(fragType.IsNative); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("TheString")); Assert.AreEqual(typeof(int?), fragType.FragmentType.GetPropertyType("IntPrimitive")); Assert.AreEqual(typeof(string), fragType.FragmentType.GetPropertyType("col2")); var fieldsInner = "TheString,IntPrimitive,col2".SplitCsv(); env.SendEventBean(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsMap( (IDictionary <string, object>)env.Listener("s0").AssertOneGetNewAndReset().Get("val0"), fieldsInner, null, null, null); env.SendEventBean(new SupportBean("A", 2)); EPAssertionUtil.AssertPropsMap( (IDictionary <string, object>)env.Listener("s0").AssertOneGetNewAndReset().Get("val0"), fieldsInner, "Q", 2, "AA"); env.SendEventBean(new SupportBean("B", 3)); EPAssertionUtil.AssertPropsMap( (IDictionary <string, object>)env.Listener("s0").AssertOneGetNewAndReset().Get("val0"), fieldsInner, "B", 10, "BB"); }
public void TestParse() { object result; Assert.AreEqual("abc", ParseLoadJson("\"abc\"")); Assert.AreEqual("http://www.uri.com", ParseLoadJson("\"http://www.uri.com\"")); Assert.AreEqual("new\nline", ParseLoadJson("\"new\\nline\"")); Assert.AreEqual(" ~ ", ParseLoadJson("\" \\u007E \"")); Assert.AreEqual("/", ParseLoadJson("\"\\/\"")); Assert.AreEqual(true, ParseLoadJson("true")); Assert.AreEqual(false, ParseLoadJson("false")); Assert.AreEqual(null, ParseLoadJson("null")); Assert.AreEqual(10, ParseLoadJson("10")); Assert.AreEqual(-10, ParseLoadJson("-10")); Assert.AreEqual(20L, ParseLoadJson("20L")); Assert.AreEqual(5.5d, ParseLoadJson("5.5")); result = ParseLoadJson("{\"name\":\"myname\",\"value\":5}"); EPAssertionUtil.AssertPropsMap(result.AsStringDictionary(), "name,value".SplitCsv(), "myname", 5); result = ParseLoadJson("{name:\"myname\",value:5}"); EPAssertionUtil.AssertPropsMap(result.AsStringDictionary(), "name,value".SplitCsv(), "myname", 5); result = ParseLoadJson("[\"one\",2]"); EPAssertionUtil.AssertEqualsExactOrder(new object[] { "one", 2 }, (IList <object>)result); result = ParseLoadJson("{\"one\": { 'a' : 2 } }"); var inner = result.AsStringDictionary().Get("one").AsStringDictionary(); Assert.AreEqual(1, inner.Count); var json = "{\n" + " \"glossary\": {\n" + " \"title\": \"example glossary\",\n" + "\t\t\"GlossDiv\": {\n" + " \"title\": \"S\",\n" + "\t\t\t\"GlossList\": {\n" + " \"GlossEntry\": {\n" + " \"ID\": \"SGML\",\n" + "\t\t\t\t\t\"SortAs\": \"SGML\",\n" + "\t\t\t\t\t\"GlossTerm\": \"Standard Generalized Markup Language\",\n" + "\t\t\t\t\t\"Acronym\": \"SGML\",\n" + "\t\t\t\t\t\"Abbrev\": \"ISO 8879:1986\",\n" + "\t\t\t\t\t\"GlossDef\": {\n" + " \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\n" + "\t\t\t\t\t\t\"GlossSeeAlso\": [\"GML\", \"XML\"]\n" + " },\n" + "\t\t\t\t\t\"GlossSee\": \"markup\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}"; var tree = ParseJson(json).First; ASTUtil.DumpAST(tree); var loaded = ParseLoadJson(json); Assert.AreEqual( "{\"glossary\"={\"title\"=\"example glossary\", \"GlossDiv\"={\"title\"=\"S\", \"GlossList\"={\"GlossEntry\"={\"ID\"=\"SGML\", \"SortAs\"=\"SGML\", \"GlossTerm\"=\"Standard Generalized Markup Language\", \"Acronym\"=\"SGML\", \"Abbrev\"=\"ISO 8879:1986\", \"GlossDef\"={\"para\"=\"A meta-markup language, used to create markup languages such as DocBook.\", \"GlossSeeAlso\"=[\"GML\", \"XML\"]}, \"GlossSee\"=\"markup\"}}}}}", loaded.ToString()); }
private void TryAssertionTopLevelReadGrouped2Keys(EPServiceProvider epService, bool soda) { SupportModelHelper.CreateByCompileOrParse( epService, soda, "create objectarray schema MyEventOA as (c0 int, c1 string, c2 int)"); SupportModelHelper.CreateByCompileOrParse( epService, soda, "create table windowAndTotalTLP2K (" + "keyi int primary key, keys string primary key, thewindow window(*) @Type('MyEventOA'), thetotal sum(int))"); SupportModelHelper.CreateByCompileOrParse( epService, soda, "into table windowAndTotalTLP2K " + "select window(*) as thewindow, sum(c2) as thetotal from MyEventOA#length(2) group by c0, c1"); var stmtSelect = SupportModelHelper.CreateByCompileOrParse( epService, soda, "select windowAndTotalTLP2K[id,p00] as val0 from SupportBean_S0"); var listener = new SupportUpdateListener(); stmtSelect.Events += listener.Update; AssertTopLevelTypeInfo(stmtSelect); var e1 = new object[] { 10, "G1", 100 }; epService.EPRuntime.SendEvent(e1, "MyEventOA"); var fieldsInner = "thewindow,thetotal".Split(','); epService.EPRuntime.SendEvent(new SupportBean_S0(10, "G1")); EPAssertionUtil.AssertPropsMap( (Map)listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[][] { e1 }, 100); var e2 = new object[] { 20, "G2", 200 }; epService.EPRuntime.SendEvent(e2, "MyEventOA"); epService.EPRuntime.SendEvent(new SupportBean_S0(20, "G2")); EPAssertionUtil.AssertPropsMap( (Map)listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[][] { e2 }, 200); var e3 = new object[] { 20, "G2", 300 }; epService.EPRuntime.SendEvent(e3, "MyEventOA"); epService.EPRuntime.SendEvent(new SupportBean_S0(10, "G1")); EPAssertionUtil.AssertPropsMap( (Map)listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, null, null); epService.EPRuntime.SendEvent(new SupportBean_S0(20, "G2")); EPAssertionUtil.AssertPropsMap( (Map)listener.AssertOneGetNewAndReset().Get("val0"), fieldsInner, new object[][] { e2, e3 }, 500); // test typable output stmtSelect.Dispose(); var stmtConvert = epService.EPAdministrator.CreateEPL( "insert into OutStream select windowAndTotalTLP2K[20, 'G2'] as val0 from SupportBean_S0"); stmtConvert.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean_S0(0)); EPAssertionUtil.AssertProps( listener.AssertOneGetNewAndReset(), "val0.thewindow,val0.thetotal".Split(','), new object[] { new object[][] { e2, e3 }, 500 }); epService.EPAdministrator.DestroyAllStatements(); }
public void Run(RegressionEnvironment env) { Environment.SetEnvironmentVariable("test.variable", "test.value"); // test simple properties MyOperatorOneForge.Operators.Clear(); env.Compile( "@Name('flow') create dataflow MyGraph MyOperatorOne {" + " theString = 'a'," + " theInt: 1," + " theBool: true," + " theLongOne: 1L," + " theLongTwo: 2," + " theLongThree: null," + " theDoubleOne: 1d," + " theDoubleTwo: 2," + " theFloatOne: 1f," + " theFloatTwo: 2," + " TheStringWithSetter: 'b'," + " theSystemProperty: systemProperties('test.variable')" + "}"); Assert.AreEqual(1, MyOperatorOneForge.Operators.Count); var instanceOne = MyOperatorOneForge.Operators[0]; Assert.AreEqual("a", instanceOne.TheString); Assert.AreEqual(null, instanceOne.TheNotSetString); Assert.AreEqual(1, instanceOne.TheInt); Assert.AreEqual(true, instanceOne.TheBool); Assert.AreEqual(1L, (long) instanceOne.TheLongOne); Assert.AreEqual(2, instanceOne.TheLongTwo); Assert.AreEqual(null, instanceOne.TheLongThree); Assert.AreEqual(1.0, instanceOne.TheDoubleOne); Assert.AreEqual(2.0, instanceOne.TheDoubleTwo); Assert.AreEqual(1f, instanceOne.TheFloatOne); Assert.AreEqual(2f, instanceOne.TheFloatTwo); Assert.AreEqual(">b<", instanceOne.TheStringWithSetter); Assert.AreEqual("test.value", instanceOne.TheSystemProperty); // test array etc. properties MyOperatorTwoForge.Operators.Clear(); env.Compile( "@Name('flow') create dataflow MyGraph MyOperatorTwo {\n" + " TheStringArray: ['a', \"b\"],\n" + " TheIntArray: [1, 2, 3],\n" + " TheObjectArray: ['a', 1],\n" + " TheMap: {\n" + " a : 10,\n" + " b : 'xyz'\n" + " },\n" + " TheInnerOp: {\n" + " fieldOne: 'x',\n" + " fieldTwo: 2\n" + " },\n" + " TheInnerOpInterface: {\n" + " class: '" + typeof(MyOperatorTwoInterfaceImplTwo).MaskTypeName() + "'\n" + " },\n" + // NOTE the last comma here, it's acceptable "}"); Assert.AreEqual(1, MyOperatorTwoForge.Operators.Count); var instanceTwo = MyOperatorTwoForge.Operators[0]; EPAssertionUtil.AssertEqualsExactOrder(new[] {"a", "b"}, instanceTwo.TheStringArray); EPAssertionUtil.AssertEqualsExactOrder(new[] {1, 2, 3}, instanceTwo.TheIntArray); EPAssertionUtil.AssertEqualsExactOrder(new object[] {"a", 1}, instanceTwo.TheObjectArray); EPAssertionUtil.AssertPropsMap( instanceTwo.TheMap, new [] { "a","b" }, 10, "xyz"); Assert.AreEqual("x", instanceTwo.TheInnerOp.fieldOne); Assert.AreEqual(2, instanceTwo.TheInnerOp.fieldTwo); Assert.IsInstanceOf<MyOperatorTwoInterfaceImplTwo>(instanceTwo.TheInnerOpInterface); }
private static void RunOnMergeInsertUpdDeleteUngrouped( RegressionEnvironment env, bool soda) { var path = new RegressionPath(); var eplDeclare = "create table varaggIUD (p0 string, sumint sum(int))"; env.CompileDeploy(soda, eplDeclare, path); var fields = new[] {"c0", "c1"}; var eplRead = "@Name('s0') select varaggIUD.p0 as c0, varaggIUD.sumint as c1, varaggIUD as c2 from SupportBean_S0"; env.CompileDeploy(soda, eplRead, path).AddListener("s0"); // assert selected column types object[][] expectedAggType = {new object[] {"c0", typeof(string)}, new object[] {"c1", typeof(int?)}}; SupportEventTypeAssertionUtil.AssertEventTypeProperties( expectedAggType, env.Statement("s0").EventType, SupportEventTypeAssertionEnum.NAME, SupportEventTypeAssertionEnum.TYPE); // assert no row env.SendEventBean(new SupportBean_S0(0)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {null, null}); // create merge var eplMerge = "on SupportBean merge varaggIUD" + " when not matched then" + " insert select TheString as p0" + " when matched and TheString like \"U%\" then" + " update set p0=\"updated\"" + " when matched and TheString like \"D%\" then" + " delete"; env.CompileDeploy(soda, eplMerge, path); // merge for varagg env.SendEventBean(new SupportBean("E1", 0)); // assert env.SendEventBean(new SupportBean_S0(0)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {"E1", null}); // also aggregate-into the same key env.CompileDeploy(soda, "into table varaggIUD select sum(50) as sumint from SupportBean_S1", path); env.SendEventBean(new SupportBean_S1(0)); env.Milestone(0); env.SendEventBean(new SupportBean_S0(0)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {"E1", 50}); // update for varagg env.SendEventBean(new SupportBean("U2", 10)); env.Milestone(1); env.SendEventBean(new SupportBean_S0(0)); var received = env.Listener("s0").AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps( received, fields, new object[] {"updated", 50}); EPAssertionUtil.AssertPropsMap( (IDictionary<string, object>) received.Get("c2"), new[] {"p0", "sumint"}, "updated", 50); // delete for varagg env.SendEventBean(new SupportBean("D3", 0)); env.Milestone(2); env.SendEventBean(new SupportBean_S0(0)); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {null, null}); env.UndeployAll(); }
public void TestPopulateBeanSimple() { // test select column names var stmtTextOne = "insert into SupportBean select " + "'E1' as TheString, 1 as IntPrimitive, 2 as IntBoxed, 3L as LongPrimitive," + "null as LongBoxed, true as BoolPrimitive, " + "'x' as CharPrimitive, 0xA as BytePrimitive, " + "8.0f as FloatPrimitive, 9.0d as DoublePrimitive, " + "0x05 as ShortPrimitive, SupportEnum.ENUM_VALUE_2 as EnumValue " + " from MyMap"; var stmtOne = _epService.EPAdministrator.CreateEPL(stmtTextOne); var stmtTextTwo = "select * from SupportBean"; var stmtTwo = _epService.EPAdministrator.CreateEPL(stmtTextTwo); stmtTwo.Events += _listener.Update; _epService.EPRuntime.SendEvent(new Dictionary <string, object>(), "MyMap"); var received = (SupportBean)_listener.AssertOneGetNewAndReset().Underlying; Assert.AreEqual("E1", received.TheString); EPAssertionUtil.AssertPropsPONO(received, "IntPrimitive,IntBoxed,LongPrimitive,LongBoxed,BoolPrimitive,CharPrimitive,BytePrimitive,FloatPrimitive,DoublePrimitive,ShortPrimitive,EnumValue".Split(','), new Object[] { 1, 2, 3l, null, true, 'x', (byte)10, 8f, 9d, (short)5, SupportEnum.ENUM_VALUE_2 }); // test insert-into column names stmtOne.Dispose(); stmtTwo.Dispose(); _listener.Reset(); stmtTextOne = "insert into SupportBean(TheString, IntPrimitive, IntBoxed, LongPrimitive," + "LongBoxed, BoolPrimitive, CharPrimitive, BytePrimitive, FloatPrimitive, DoublePrimitive, " + "ShortPrimitive, EnumValue) select " + "'E1', 1, 2, 3L," + "null, true, " + "'x', 0xA, " + "8.0f, 9.0d, " + "0x05 as ShortPrimitive, SupportEnum.ENUM_VALUE_2 " + " from MyMap"; stmtOne = _epService.EPAdministrator.CreateEPL(stmtTextOne); stmtOne.Events += _listener.Update; _epService.EPRuntime.SendEvent(new Dictionary <string, object>(), "MyMap"); received = (SupportBean)_listener.AssertOneGetNewAndReset().Underlying; Assert.AreEqual("E1", received.TheString); EPAssertionUtil.AssertPropsPONO(received, "IntPrimitive,IntBoxed,LongPrimitive,LongBoxed,BoolPrimitive,CharPrimitive,BytePrimitive,FloatPrimitive,DoublePrimitive,ShortPrimitive,EnumValue".Split(','), new Object[] { 1, 2, 3l, null, true, 'x', (byte)10, 8f, 9d, (short)5, SupportEnum.ENUM_VALUE_2 }); // test convert Integer boxed to Long boxed stmtOne.Dispose(); _listener.Reset(); stmtTextOne = "insert into SupportBean(LongBoxed, DoubleBoxed) select IntBoxed, FloatBoxed from MyMap"; stmtOne = _epService.EPAdministrator.CreateEPL(stmtTextOne); stmtOne.Events += _listener.Update; IDictionary <String, Object> vals = new Dictionary <String, Object>(); vals.Put("IntBoxed", 4); vals.Put("FloatBoxed", 0f); _epService.EPRuntime.SendEvent(vals, "MyMap"); EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), "LongBoxed,DoubleBoxed".Split(','), new Object[] { 4L, 0d }); _epService.EPAdministrator.DestroyAllStatements(); // test new-to-map conversion _epService.EPAdministrator.Configuration.AddEventType(typeof(MyEventWithMapFieldSetter)); var stmt = _epService.EPAdministrator.CreateEPL("insert into MyEventWithMapFieldSetter(Id, TheMap) " + "select 'test' as Id, new {somefield = TheString} as TheMap from SupportBean"); stmt.Events += _listener.Update; _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); EPAssertionUtil.AssertPropsMap((IDictionary <String, Object>)_listener.AssertOneGetNew().Get("TheMap"), "somefield".Split(','), "E1"); }
public void TestCustomProps() { _epService.EPAdministrator.Configuration.AddImport(typeof(MyOperatorOne)); _epService.EPAdministrator.Configuration.AddImport(typeof(MyOperatorTwo)); // test simple properties MyOperatorOne.Operators.Clear(); EPStatement stmtGraph = _epService.EPAdministrator.CreateEPL("create dataflow MyGraph " + typeof(MyOperatorOne).Name + " {" + " TheString = 'a'," + " TheInt: 1," + " TheBool: true," + " TheLongOne: 1L," + " TheLongTwo: 2," + " TheLongThree: null," + " TheDoubleOne: 1d," + " TheDoubleTwo: 2," + " TheFloatOne: 1f," + " TheFloatTwo: 2," + " TheStringWithSetter: 'b'," + " TheSystemProperty: env('Path')" + "}"); _epService.EPRuntime.DataFlowRuntime.Instantiate("MyGraph"); Assert.AreEqual(1, MyOperatorOne.Operators.Count); MyOperatorOne instanceOne = MyOperatorOne.Operators[0]; Assert.AreEqual("a", instanceOne.TheString); Assert.AreEqual(null, instanceOne.TheNotSetString); Assert.AreEqual(1, instanceOne.TheInt); Assert.AreEqual(true, instanceOne.TheBool); Assert.AreEqual(1L, (long)instanceOne.TheLongOne); Assert.AreEqual(2, instanceOne.TheLongTwo); Assert.AreEqual(null, instanceOne.TheLongThree); Assert.AreEqual(1.0, instanceOne.TheDoubleOne); Assert.AreEqual(2.0, instanceOne.TheDoubleTwo); Assert.AreEqual(1f, instanceOne.TheFloatOne); Assert.AreEqual(2f, instanceOne.TheFloatTwo); Assert.AreEqual(">b<", instanceOne.TheStringWithSetter); Assert.NotNull(instanceOne.TheSystemProperty); stmtGraph.Dispose(); // test array etc. properties MyOperatorTwo.Operators.Clear(); _epService.EPAdministrator.CreateEPL("create dataflow MyGraph " + typeof(MyOperatorTwo).Name + " {\n" + " theStringArray: ['a', \"b\"],\n" + " theIntArray: [1, 2, 3],\n" + " theObjectArray: ['a', 1],\n" + " theMap: {\n" + " a : 10,\n" + " b : 'xyz'\n" + " },\n" + " theInnerOp: {\n" + " fieldOne: 'x',\n" + " fieldTwo: 2\n" + " },\n" + " theInnerOpInterface: {\n" + " class: '" + typeof(MyOperatorTwoInterfaceImplTwo).FullName + "'\n" + " },\n" + // NOTE the last comma here, it's acceptable "}"); _epService.EPRuntime.DataFlowRuntime.Instantiate("MyGraph"); Assert.AreEqual(1, MyOperatorTwo.Operators.Count); MyOperatorTwo instanceTwo = MyOperatorTwo.Operators[0]; EPAssertionUtil.AssertEqualsExactOrder(new String[] { "a", "b" }, instanceTwo.TheStringArray); EPAssertionUtil.AssertEqualsExactOrder(new int[] { 1, 2, 3 }, instanceTwo.TheIntArray); EPAssertionUtil.AssertEqualsExactOrder(new Object[] { "a", 1 }, instanceTwo.TheObjectArray); EPAssertionUtil.AssertPropsMap(instanceTwo.TheMap, "a,b".Split(','), new Object[] { 10, "xyz" }); Assert.AreEqual("x", instanceTwo.TheInnerOp.fieldOne); Assert.AreEqual(2, instanceTwo.TheInnerOp.fieldTwo); Assert.IsTrue(instanceTwo.TheInnerOpInterface is MyOperatorTwoInterfaceImplTwo); }