private static void runAssertion( RegressionEnvironment env, string eventTypeName, RegressionPath path) { var stmtText = "@Name('s0') select type?,dyn[1]?,nested.nes2?,map('a')? from " + eventTypeName; env.CompileDeploy(stmtText, path).AddListener("s0"); CollectionAssert.AreEquivalent( new EventPropertyDescriptor[] { new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("nested.nes2?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false) }, env.Statement("s0").EventType.PropertyDescriptors); SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("s0").EventType); var root = SupportXML.SendXMLEvent(env, NOSCHEMA_XML, eventTypeName); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(2), theEvent.Get("dyn[1]?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?")); SupportEventTypeAssertionUtil.AssertConsistency(theEvent); env.UndeployAll(); }
private static void RunAssertion( RegressionEnvironment env, String eventTypeName, RegressionPath path) { // url='page4' var text = "@Name('s0') select a.url as sesja from pattern [ every a=" + eventTypeName + "(url='page1') ]"; env.CompileDeploy(text, path).AddListener("s0"); SupportXML.SendXMLEvent( env, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" + "<url>page1</url>" + "</event-page-visit>", eventTypeName); var theEvent = env.Listener("s0").LastNewData[0]; Assert.AreEqual("page1", theEvent.Get("sesja")); env.Listener("s0").Reset(); SupportXML.SendXMLEvent( env, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" + "<url>page2</url>" + "</event-page-visit>", eventTypeName); Assert.IsFalse(env.Listener("s0").IsInvoked); var type = env.CompileDeploy("@Name('s1') select * from " + eventTypeName, path).Statement("s1").EventType; CollectionAssert.AreEquivalent( new EventPropertyDescriptor[] { new EventPropertyDescriptor("sessionId", typeof(XmlNode), null, false, false, false, false, true), new EventPropertyDescriptor("customerId", typeof(XmlNode), null, false, false, false, false, true), new EventPropertyDescriptor("url", typeof(string), null, false, false, false, false, false), new EventPropertyDescriptor("method", typeof(XmlNode), null, false, false, false, false, true) }, type.PropertyDescriptors); env.UndeployAll(); }
private static void RunAssertion( RegressionEnvironment env, string eventTypeName, RegressionPath path) { var text = "@Name('s0') select order_amount from " + eventTypeName; env.CompileDeploy(text, path).AddListener("s0"); SupportXML.SendXMLEvent( env, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<order>\n" + "<order_amount>202.1</order_amount>" + "</order>", "OrderEvent"); var theEvent = env.Listener("s0").LastNewData[0]; Assert.AreEqual(typeof(double), theEvent.Get("order_amount").GetType()); Assert.AreEqual(202.1d, theEvent.Get("order_amount")); env.Listener("s0").Reset(); env.UndeployAll(); }
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()};\n"; RunAssertion(env, "LocalEvent", beanepl, bean); // Map BiConsumer <EventType, string> map = ( type, property) => { env.SendEventMap(Collections.SingletonDataMap("Property", property), "LocalEvent"); }; var mapepl = "@public @buseventtype create schema LocalEvent(Property string);\n"; RunAssertion(env, "LocalEvent", mapepl, map); // Object-array BiConsumer <EventType, string> oa = ( type, property) => { env.SendEventObjectArray(new object[] { property }, "LocalEvent"); }; var oaepl = "@public @buseventtype create objectarray schema LocalEvent(Property string);\n"; RunAssertion(env, "LocalEvent", oaepl, oa); // Json BiConsumer <EventType, string> json = ( type, property) => { env.SendEventJson(new JObject(new JProperty("Property", property)).ToString(), "LocalEvent"); }; RunAssertion(env, "LocalEvent", "@public @buseventtype create json schema LocalEvent(Property string);\n", json); // Json-Class-Provided RunAssertion( env, "LocalEvent", "@JsonSchema(ClassName='" + typeof(MyLocalJsonProvided).MaskTypeName() + "') @public @buseventtype create json schema LocalEvent();\n", json); // Avro BiConsumer <EventType, string> avro = ( type, property) => { var theEvent = new GenericRecord(SupportAvroUtil.GetAvroSchema(type).AsRecordSchema()); theEvent.Put("Property", property); env.SendEventAvro(theEvent, type.Name); }; RunAssertion(env, "LocalEvent", "@public @buseventtype create avro schema LocalEvent(Property string);\n", avro); // XML BiConsumer <EventType, string> xml = ( type, property) => { var doc = "<" + XMLTYPENAME + (property != null ? " Property=\"" + property + "\"" : "") + "/>"; SupportXML.SendXMLEvent(env, doc, XMLTYPENAME); }; RunAssertion(env, XMLTYPENAME, "", xml); }