public void Run(RegressionEnvironment env)
        {
            var fields = "name,favorite_number,favorite_color";
            env.CompileDeploy("@Name('s0') select " + fields + " from User").AddListener("s0");

            var schema =
                AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("User"));
            var eventOneJson = "{\"name\": \"Jane\", \"favorite_number\": 256, \"favorite_color\": \"red\"}";
            var record = Parse(schema, eventOneJson);
            env.SendEventAvro(record, "User");
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields.SplitCsv(),
                new object[] {"Jane", 256, "red"});

            var eventTwoJson = "{\"name\": \"Hans\", \"favorite_number\": -1, \"favorite_color\": \"green\"}";
            record = Parse(schema, eventTwoJson);
            env.SendEventAvro(record, "User");
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields.SplitCsv(),
                new object[] {"Hans", -1, "green"});

            env.UndeployAll();
        }
        private void RunAvroType(
            RegressionEnvironment env,
            RegressionPath path)
        {
            // Avro
            var schema      = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME));
            var innerSchema = schema.GetField("Nested").Schema;
            var avroInner   = new GenericRecord(innerSchema.AsRecordSchema());

            avroInner.Put("MyInsideInt", 10);
            var avro = new GenericRecord(schema.AsRecordSchema());

            avro.Put("MyInt", 1);
            avro.Put("MyString", "abc");
            avro.Put("Nested", avroInner);
            RunAssertion(env, AVRO_TYPENAME, FAVRO, avro, path);
        }
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();

            RunAssertion(
                env,
                BEAN_TYPE.Name,
                FBEAN,
                new MyIMEvent(new string[] { "v1", "v2" }, Collections.SingletonDataMap("k1", "v1")),
                path);

            RunAssertion(
                env,
                MAP_TYPENAME,
                FMAP,
                TwoEntryMap <string, object>("Indexed", new string[] { "v1", "v2" }, "Mapped", Collections.SingletonDataMap("k1", "v1")),
                path);

            RunAssertion(env, OA_TYPENAME, FOA, new object[] { new string[] { "v1", "v2" }, Collections.SingletonDataMap("k1", "v1") }, path);

            // Avro
            var avroSchema = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME)).AsRecordSchema();
            var datum      = new GenericRecord(avroSchema);

            datum.Put("Indexed", Arrays.AsList("v1", "v2"));
            datum.Put("Mapped", Collections.SingletonMap("k1", "v1"));
            RunAssertion(env, AVRO_TYPENAME, FAVRO, datum, path);

            // Json
            var mapType = typeof(IDictionary <string, object>).CleanName();

            env.CompileDeploy($"@public @buseventtype @name('schema') create json schema {JSON_TYPENAME} (Indexed string[], Mapped `{mapType}`)", path);
            var json = "{\"Mapped\":{\"k1\":\"v1\"},\"Indexed\":[\"v1\",\"v2\"]}";

            RunAssertion(env, JSON_TYPENAME, FJSON, json, path);

            // Json+ProvidedClass
            env.CompileDeploy(
                $"@public @buseventtype @name('schema') @JsonSchema(ClassName='{typeof(MyLocalJsonProvided).FullName}') " +
                $"create json schema {JSONPROVIDED_TYPENAME}()",
                path);
            RunAssertion(env, JSONPROVIDED_TYPENAME, FJSON, json, path);
        }
Beispiel #4
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("@Name('NamedWindow') create window MyWindow#keepall as MyEventWSchema", path);
                env.CompileDeploy("insert into MyWindow select * from MyEventWSchema", path);
                env.CompileDeploy("on SupportBean thebean update MyWindow set sb = thebean", path);

                var schema = AvroSchemaUtil
                    .ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("MyEventWSchema"))
                    .AsRecordSchema();
                var @event = new GenericRecord(schema);
                env.SendEventAvro(@event, "MyEventWSchema");
                env.SendEventBean(new SupportBean("E1", 10));

                var eventBean = env.GetEnumerator("NamedWindow").Advance();
                Assert.AreEqual(
                    "{\"sb\":{\"SupportBeanSchema\":{\"TheString\":\"E1\",\"IntPrimitive\":10}}}",
                    SupportAvroUtil.AvroToJson(eventBean));

                env.UndeployAll();
            }
Beispiel #5
0
        public void Run(RegressionEnvironment env)
        {
            // schema from statement
            var epl = "@Name('s0') " +
                      EventRepresentationChoice.AVRO.GetAnnotationText() +
                      "select 1 as carId, 'abc' as carType from SupportBean";
            env.CompileDeploy(epl);
            var schema = (Schema) ((AvroSchemaEventType) env.Statement("s0").EventType).Schema;
            var schemaJson = schema.ToJsonObject();
            Assert.AreEqual(
                "{\"type\":\"record\",\"name\":\"stmt0_out0\",\"fields\":[{\"name\":\"carId\",\"type\":\"int\"},{\"name\":\"carType\",\"type\":{\"type\":\"string\",\"avro.string\":\"string\"}}]}",
                schemaJson.ToString(Newtonsoft.Json.Formatting.None));
            env.UndeployAll();

            // schema to-string Avro
            var schemaTwo = SchemaBuilder.Record(
                "MyAvroEvent",
                RequiredInt("carId"),
                Field(
                    "carType",
                    StringType(
                        Property(PROP_STRING_KEY, PROP_STRING_VALUE))));
            Assert.AreEqual(
                "{\"type\":\"record\",\"name\":\"MyAvroEvent\",\"fields\":[{\"name\":\"carId\",\"type\":\"int\"},{\"name\":\"carType\",\"type\":{\"type\":\"string\",\"avro.string\":\"string\"}}]}",
                schemaTwo.ToJsonObject().ToString(Newtonsoft.Json.Formatting.None));
            env.UndeployAll();

            env.CompileDeploy("@Name('s0') select count(*) from CarLocUpdateEvent(direction = 1)#time(1 min)")
                .AddListener("s0");
            var schemaCarLocUpd = AvroSchemaUtil
                .ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("CarLocUpdateEvent"))
                .AsRecordSchema();
            var @event = new GenericRecord(schemaCarLocUpd);
            @event.Put("carId", "A123456");
            @event.Put("direction", 1);
            env.SendEventAvro(@event, "CarLocUpdateEvent");
            Assert.AreEqual(1L, env.Listener("s0").AssertOneGetNewAndReset().Get("count(*)"));

            env.UndeployAll();
        }
        public override void Run(EPServiceProvider epService)
        {
            AddMapEventType(epService);
            AddOAEventType(epService);
            epService.EPAdministrator.Configuration.AddEventType(BEAN_TYPENAME, typeof(SupportBeanDynRoot));
            AddAvroEventType(epService);

            var notExists = MultipleNotExists(6);

            // Bean
            var beanOne = SupportBeanComplexProps.MakeDefaultBean();
            var n1_v    = beanOne.Nested.NestedValue;
            var n1_n_v  = beanOne.Nested.NestedNested.NestedNestedValue;
            var beanTwo = SupportBeanComplexProps.MakeDefaultBean();

            beanTwo.Nested.NestedValue = "nested1";
            beanTwo.Nested.NestedNested.NestedNestedValue = "nested2";
            var beanTests = new[]
            {
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(
                    new SupportBeanDynRoot(beanOne), AllExist(n1_v, n1_v, n1_n_v, n1_n_v, n1_n_v, n1_n_v)),
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(
                    new SupportBeanDynRoot(beanTwo),
                    AllExist("nested1", "nested1", "nested2", "nested2", "nested2", "nested2")),
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot("abc"), notExists)
            };

            RunAssertion(epService, BEAN_TYPENAME, FBEAN, null, beanTests, typeof(object));

            // Map
            var mapOneL2 = new Dictionary <string, object>();

            mapOneL2.Put("nestedNestedValue", 101);
            var mapOneL1 = new Dictionary <string, object>();

            mapOneL1.Put("nestedNested", mapOneL2);
            mapOneL1.Put("nestedValue", 100);
            var mapOneL0 = new Dictionary <string, object>();

            mapOneL0.Put("nested", mapOneL1);
            var mapOne   = Collections.SingletonDataMap("item", mapOneL0);
            var mapTests = new[]
            {
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(
                    mapOne, AllExist(100, 100, 101, 101, 101, 101)),
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.EmptyDataMap, notExists),
            };

            RunAssertion(epService, MAP_TYPENAME, FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaOneL2 = new object[] { 101 };
            var oaOneL1 = new object[] { oaOneL2, 100 };
            var oaOneL0 = new object[] { oaOneL1 };
            var oaOne   = new object[] { oaOneL0 };
            var oaTests = new[]
            {
                new Pair <object[], ValueWithExistsFlag[]>(oaOne, AllExist(100, 100, 101, 101, 101, 101)),
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { null }, notExists),
            };

            RunAssertion(epService, OA_TYPENAME, FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new[]
            {
                new Pair <string, ValueWithExistsFlag[]>(
                    "<item>\n" +
                    "\t<nested nestedValue=\"100\">\n" +
                    "\t\t<nestedNested nestedNestedValue=\"101\">\n" +
                    "\t\t</nestedNested>\n" +
                    "\t</nested>\n" +
                    "</item>\n", AllExist("100", "100", "101", "101", "101", "101")),
                new Pair <string, ValueWithExistsFlag[]>("<item/>", notExists),
            };

            RunAssertion(epService, XML_TYPENAME, FXML, XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            Schema schema       = GetAvroSchema();
            var    nestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(
                schema.GetField("item").Schema.GetField("nested").Schema).AsRecordSchema();
            var nestedNestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(
                nestedSchema.GetField("nestedNested").Schema).AsRecordSchema();
            var nestedNestedDatum = new GenericRecord(nestedNestedSchema);

            nestedNestedDatum.Put("nestedNestedValue", 101);
            var nestedDatum = new GenericRecord(nestedSchema);

            nestedDatum.Put("nestedValue", 100);
            nestedDatum.Put("nestedNested", nestedNestedDatum);
            var emptyDatum = new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME));
            var avroTests  = new[]
            {
                new Pair <object, ValueWithExistsFlag[]>(nestedDatum, AllExist(100, 100, 101, 101, 101, 101)),
                new Pair <object, ValueWithExistsFlag[]>(emptyDatum, notExists),
                new Pair <object, ValueWithExistsFlag[]>(null, notExists)
            };

            RunAssertion(epService, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object));
        }
        public void Run(RegressionEnvironment env)
        {
            // Bean
            Pair<object, object>[] beanTests = {
                new Pair<object, object>(
                    SupportBeanComplexProps.MakeDefaultBean(),
                    AllExist("Simple", "NestedValue", "NestedNestedValue")),
                new Pair<object, object>(new SupportMarkerImplA("x"), NOT_EXISTS)
            };
            RunAssertion(env, BEAN_TYPE.Name, FBEAN, null, beanTests, typeof(object));

            // Map
            var mapNestedNestedOne = Collections.SingletonDataMap("NestedNestedValue", 101);
            var mapNestedOne = TwoEntryMap<string, object>(
                "NestedNested", mapNestedNestedOne,
                "NestedValue", "abc");
            var mapOne = TwoEntryMap<string, object>(
                "SimpleProperty", 5, 
                "Nested", mapNestedOne);
            Pair<object, object>[] mapTests = {
                new Pair<object, object>(
                    Collections.SingletonDataMap("SimpleProperty", "a"),
                    new[] {Exists("a"), NotExists(), NotExists()}),
                new Pair<object, object>(mapOne, AllExist(5, "abc", 101))
            };
            RunAssertion(env, MAP_TYPENAME, FMAP, null, mapTests, typeof(object));
            
            // Object-Array
            object[] oaNestedNestedOne = {101};
            object[] oaNestedOne = {"abc", oaNestedNestedOne};
            object[] oaOne = {5, oaNestedOne};
            Pair<object, object>[] oaTests = {
                new Pair<object, object>(new object[] {"a", null}, new[] {Exists("a"), NotExists(), NotExists()}),
                new Pair<object, object>(oaOne, AllExist(5, "abc", 101))
            };
            RunAssertion(env, OA_TYPENAME, FOA, null, oaTests, typeof(object));

            // XML
            Pair<object, object>[] xmlTests = {
                new Pair<object, object>(
                    "<SimpleProperty>abc</SimpleProperty>" +
                    "<Nested NestedValue=\"100\">\n" +
                    "\t<NestedNested NestedNestedValue=\"101\">\n" +
                    "\t</NestedNested>\n" +
                    "</Nested>\n",
                    AllExist("abc", "100", "101")),
                new Pair<object, object>("<Nested/>", NOT_EXISTS)
            };
            RunAssertion(env, XML_TYPENAME, FXML, xmlToValue, xmlTests, typeof(XmlNode));

            // Avro
            var avroSchema = AvroSchemaUtil
                .ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME))
                .AsRecordSchema();
            var datumNull = new GenericRecord(avroSchema);
            var schema = avroSchema;
            var nestedSchema = AvroSchemaUtil
                .FindUnionRecordSchemaSingle(schema.GetField("Nested").Schema)
                .AsRecordSchema();
            var nestedNestedSchema = AvroSchemaUtil
                .FindUnionRecordSchemaSingle(nestedSchema.GetField("NestedNested").Schema)
                .AsRecordSchema();
            var nestedNestedDatum = new GenericRecord(nestedNestedSchema);
            nestedNestedDatum.Put("NestedNestedValue", 101);
            var nestedDatum = new GenericRecord(nestedSchema);
            nestedDatum.Put("NestedValue", 100);
            nestedDatum.Put("NestedNested", nestedNestedDatum);
            var datumOne = new GenericRecord(schema);
            datumOne.Put("SimpleProperty", "abc");
            datumOne.Put("Nested", nestedDatum);
            Pair<object, object>[] avroTests = {
                new Pair<object, object>(
                    new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME)),
                    NOT_EXISTS),
                new Pair<object, object>(datumNull, new[] {Exists(null), NotExists(), NotExists()}),
                new Pair<object, object>(datumOne, AllExist("abc", 100, 101))
            };
            RunAssertion(env, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object));
        }
        public void Run(RegressionEnvironment env)
        {
            var notExists = MultipleNotExists(4);
            var path      = new RegressionPath();

            // Bean
            var bean      = SupportBeanComplexProps.MakeDefaultBean();
            var beanTests = new Pair <object, object>[] {
                new Pair <object, object>(
                    bean,
                    AllExist(bean.GetIndexed(0), bean.GetIndexed(1), bean.GetMapped("keyOne"), bean.GetMapped("keyTwo")))
            };

            RunAssertion(env, nameof(SupportBeanComplexProps), FBEAN, null, beanTests, typeof(object), path);

            // Map
            var mapTests = new Pair <object, object>[] {
                new Pair <object, object>(Collections.SingletonMap("somekey", "10"), notExists),
                new Pair <object, object>(
                    TwoEntryMap <string, object>(
                        "Indexed",
                        new int[] { 1, 2 },
                        "Mapped",
                        TwoEntryMap <string, object>("keyOne", 3, "keyTwo", 4)),
                    AllExist(1, 2, 3, 4)),
            };

            RunAssertion(env, MAP_TYPENAME, FMAP, null, mapTests, typeof(object), path);

            // Object-Array
            var oaTests = new Pair <object, object>[] {
                new Pair <object, object>(new object[] { null, null }, notExists),
                new Pair <object, object>(new object[] { new int[] { 1, 2 }, TwoEntryMap("keyOne", 3, "keyTwo", 4) }, AllExist(1, 2, 3, 4)),
            };

            RunAssertion(env, OA_TYPENAME, FOA, null, oaTests, typeof(object), path);

            // XML
            var xmlTests = new Pair <object, object>[] {
                new Pair <object, object>("", notExists),
                new Pair <object, object>(
                    "<Indexed>1</Indexed><Indexed>2</Indexed><Mapped id=\"keyOne\">3</Mapped><Mapped id=\"keyTwo\">4</Mapped>",
                    AllExist("1", "2", "3", "4"))
            };

            RunAssertion(env, XML_TYPENAME, FXML, xmlToValue, xmlTests, typeof(XmlNode), path);

            // Avro
            var schema   = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME)).AsRecordSchema();
            var datumOne = new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME));
            var datumTwo = new GenericRecord(schema);

            datumTwo.Put("Indexed", Arrays.AsList(1, 2));
            datumTwo.Put("Mapped", TwoEntryMap("keyOne", 3, "keyTwo", 4));
            var avroTests = new Pair <object, object>[] {
                new Pair <object, object>(datumOne, notExists),
                new Pair <object, object>(datumTwo, AllExist(1, 2, 3, 4)),
            };

            RunAssertion(env, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object), path);

            // Json
            env.CompileDeploy("@JsonSchema(Dynamic=true) @public @buseventtype create json schema " + JSON_TYPENAME + "()", path);
            var jsonTests = new Pair <object, object>[] {
                new Pair <object, object>("{}", notExists),
                new Pair <object, object>(
                    "{\"Mapped\":{\"keyOne\":\"3\",\"keyTwo\":\"4\"},\"Indexed\":[\"1\",\"2\"]}",
                    AllExist("1", "2", "3", "4"))
            };

            RunAssertion(env, JSON_TYPENAME, FJSON, null, jsonTests, typeof(object), path);

            // Json-Provided-Class
            var jsonProvidedTests = new Pair <object, object>[] {
                new Pair <object, object>("{}", notExists),
                new Pair <object, object>(
                    "{\"Mapped\":{\"keyOne\":\"3\",\"keyTwo\":\"4\"},\"Indexed\":[\"1\",\"2\"]}",
                    AllExist(1, 2, "3", "4"))
            };

            env.CompileDeploy(
                "@JsonSchema(ClassName='" + typeof(MyLocalJsonProvided).FullName + "') @public @buseventtype create json schema " + JSONPROVIDED_TYPENAME + "()",
                path);
            RunAssertion(env, JSONPROVIDED_TYPENAME, FJSON, null, jsonProvidedTests, typeof(object), path);
        }
            public void Run(RegressionEnvironment env)
            {
                EPStage        stage = env.StageService.GetStage("ST");
                RegressionPath path  = new RegressionPath();

                // Bean
                RunAssertion(
                    env,
                    path,
                    stage,
                    "SupportBean",
                    new SupportBean(),
                    svc => svc.SendEventBean(new SupportBean(), "SupportBean"));

                // Map
                RunAssertion(
                    env,
                    path,
                    stage,
                    MAP_TYPENAME,
                    new Dictionary <string, object>(),
                    svc => svc.SendEventMap(new Dictionary <string, object>(), MAP_TYPENAME));

                // Object-Array
                RunAssertion(
                    env,
                    path,
                    stage,
                    OA_TYPENAME,
                    new object[0],
                    svc => svc.SendEventObjectArray(new object[0], OA_TYPENAME));

                // XML
                var node = SupportXML.GetDocument("<myevent/>").DocumentElement;

                RunAssertion(
                    env,
                    path,
                    stage,
                    XML_TYPENAME,
                    node,
                    svc => svc.SendEventXMLDOM(node, XML_TYPENAME));

                // Avro
                var schema = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME));
                var record = new GenericRecord(schema.AsRecordSchema());

                RunAssertion(
                    env,
                    path,
                    stage,
                    AVRO_TYPENAME,
                    record,
                    svc => svc.SendEventAvro(record, AVRO_TYPENAME));

                // Json
                RunAssertion(
                    env,
                    path,
                    stage,
                    JSON_TYPENAME,
                    "{}",
                    svc => svc.SendEventJson("{}", JSON_TYPENAME));

                env.UndeployAll();
            }
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();

            // Bean
            var beanTests = new Pair <object, object>[] {
                new Pair <object, object>(new SupportMarkerImplA("e1"), Exists("e1")),
                new Pair <object, object>(new SupportMarkerImplB(1), Exists(1)),
                new Pair <object, object>(new SupportMarkerImplC(), NotExists())
            };

            RunAssertion(env, nameof(SupportMarkerInterface), FBEAN, null, beanTests, typeof(object), path);

            // Map
            var mapTests = new Pair <object, object>[] {
                new Pair <object, object>(Collections.SingletonMap("somekey", "10"), NotExists()),
                new Pair <object, object>(Collections.SingletonMap("Id", "abc"), Exists("abc")),
                new Pair <object, object>(Collections.SingletonMap("Id", 10), Exists(10)),
            };

            RunAssertion(env, MAP_TYPENAME, FMAP, null, mapTests, typeof(object), path);

            // Object-Array
            var oaTests = new Pair <object, object>[] {
                new Pair <object, object>(new object[] { 1, null }, Exists(null)),
                new Pair <object, object>(new object[] { 2, "abc" }, Exists("abc")),
                new Pair <object, object>(new object[] { 3, 10 }, Exists(10)),
            };

            RunAssertion(env, OA_TYPENAME, FOA, null, oaTests, typeof(object), path);

            // XML
            var xmlTests = new Pair <object, object>[] {
                new Pair <object, object>("", NotExists()),
                new Pair <object, object>("<Id>10</Id>", Exists("10")),
                new Pair <object, object>("<Id>abc</Id>", Exists("abc")),
            };

            RunAssertion(env, XML_TYPENAME, FXML, xmlToValue, xmlTests, typeof(XmlNode), path);

            // Avro
            var avroSchema = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME)).AsRecordSchema();
            var datumEmpty = new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME));
            var datumOne   = new GenericRecord(avroSchema);

            datumOne.Put("Id", 101);
            var datumTwo = new GenericRecord(avroSchema);

            datumTwo.Put("Id", null);
            var avroTests = new Pair <object, object>[] {
                new Pair <object, object>(datumEmpty, NotExists()),
                new Pair <object, object>(datumOne, Exists(101)),
                new Pair <object, object>(datumTwo, Exists(null))
            };

            RunAssertion(env, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object), path);

            // Json
            env.CompileDeploy("@JsonSchema(Dynamic=true) @public @buseventtype create json schema " + JSON_TYPENAME + "()", path);
            var jsonTests = new Pair <object, object>[] {
                new Pair <object, object>("{}", NotExists()),
                new Pair <object, object>("{\"Id\": 10}", Exists(10)),
                new Pair <object, object>("{\"Id\": \"abc\"}", Exists("abc"))
            };

            RunAssertion(env, JSON_TYPENAME, FJSON, null, jsonTests, typeof(object), path);
        }
Beispiel #11
0
        public void TestIt()
        {
            var NOT_EXISTS = ValueWithExistsFlag.MultipleNotExists(3);

            // Bean
            var beanTests = new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>[] {
                new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(SupportBeanComplexProps.MakeDefaultBean(), ValueWithExistsFlag.AllExist("Simple", "NestedValue", "NestedNestedValue")),
                new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(new SupportMarkerImplA("x"), NOT_EXISTS),
            };

            RunAssertion(BEAN_TYPE.Name, SupportEventInfra.FBEAN, null, beanTests, typeof(object));

            // Map
            var mapNestedNestedOne = Collections.SingletonDataMap("nestedNestedValue", 101);
            IDictionary <string, object> mapNestedOne = SupportEventInfra.TwoEntryMap("nestedNested", mapNestedNestedOne, "nestedValue", "abc");
            IDictionary <string, object> mapOne       = SupportEventInfra.TwoEntryMap("simpleProperty", 5, "nested", mapNestedOne);
            var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>[] {
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.SingletonDataMap("simpleProperty", "a"), new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists("a"), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.NotExists() }),
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(mapOne, ValueWithExistsFlag.AllExist(5, "abc", 101)),
            };

            RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaNestedNestedOne = new object[] { 101 };
            var oaNestedOne       = new object[] { "abc", oaNestedNestedOne };
            var oaOne             = new object[] { 5, oaNestedOne };
            var oaTests           = new Pair <object[], ValueWithExistsFlag[]>[] {
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { "a", null }, new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists("a"), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.NotExists() }),
                new Pair <object[], ValueWithExistsFlag[]>(oaOne, ValueWithExistsFlag.AllExist(5, "abc", 101)),
            };

            RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new Pair <string, ValueWithExistsFlag[]>[]
            {
                new Pair <string, ValueWithExistsFlag[]>(
                    "<simpleProperty>abc</simpleProperty>" +
                    "<nested nestedValue=\"100\">\n" +
                    "\t<nestedNested nestedNestedValue=\"101\">\n" +
                    "\t</nestedNested>\n" +
                    "</nested>\n", ValueWithExistsFlag.AllExist("abc", "100", "101")),
                new Pair <string, ValueWithExistsFlag[]>("<nested/>", NOT_EXISTS),
            };

            RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            var schema             = GetAvroSchema();
            var datumNull          = new GenericRecord(schema);
            var nestedSchema       = AvroSchemaUtil.FindUnionRecordSchemaSingle(schema.GetField("nested").Schema).AsRecordSchema();
            var nestedNestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(nestedSchema.GetField("nestedNested").Schema).AsRecordSchema();
            var nestedNestedDatum  = new GenericRecord(nestedNestedSchema);

            nestedNestedDatum.Put("nestedNestedValue", 101);
            var nestedDatum = new GenericRecord(nestedSchema);

            nestedDatum.Put("nestedValue", 100);
            nestedDatum.Put("nestedNested", nestedNestedDatum);
            var datumOne = new GenericRecord(schema);

            datumOne.Put("simpleProperty", "abc");
            datumOne.Put("nested", nestedDatum);

            var avroTests = new Pair <GenericRecord, ValueWithExistsFlag[]>[] {
                new Pair <GenericRecord, ValueWithExistsFlag[]>(new GenericRecord(SchemaBuilder.Record(SupportEventInfra.AVRO_TYPENAME)), NOT_EXISTS),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumNull, new ValueWithExistsFlag[] { ValueWithExistsFlag.Exists(null), ValueWithExistsFlag.NotExists(), ValueWithExistsFlag.NotExists() }),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, ValueWithExistsFlag.AllExist("abc", 100, 101)),
            };

            RunAssertion(SupportEventInfra.AVRO_TYPENAME, SupportEventInfra.FAVRO, null, avroTests, typeof(object));
        }
Beispiel #12
0
        public void TestIt()
        {
            var NOT_EXISTS = ValueWithExistsFlag.MultipleNotExists(6);

            // Bean
            SupportBeanComplexProps inner = SupportBeanComplexProps.MakeDefaultBean();
            var beanTests = new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>[] {
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot("xxx"), NOT_EXISTS),
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot(inner), ValueWithExistsFlag.AllExist(
                                                                         inner.GetIndexed(0),
                                                                         inner.GetIndexed(1),
                                                                         inner.ArrayProperty[1],
                                                                         inner.GetMapped("keyOne"),
                                                                         inner.GetMapped("keyTwo"),
                                                                         inner.MapProperty.Get("xOne"))),
            };

            RunAssertion(BEAN_TYPE.Name, SupportEventInfra.FBEAN, null, beanTests, typeof(object));

            // Map
            IDictionary <string, object> mapNestedOne = new Dictionary <string, object>();

            mapNestedOne.Put("indexed", new int[] { 1, 2 });
            mapNestedOne.Put("arrayProperty", null);
            mapNestedOne.Put("mapped", SupportEventInfra.TwoEntryMap("keyOne", 100, "keyTwo", 200));
            mapNestedOne.Put("mapProperty", null);
            var mapOne   = Collections.SingletonDataMap("item", mapNestedOne);
            var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>[] {
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.EmptyDataMap, NOT_EXISTS),
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(mapOne, new ValueWithExistsFlag[]
                {
                    ValueWithExistsFlag.Exists(1),
                    ValueWithExistsFlag.Exists(2),
                    ValueWithExistsFlag.NotExists(),
                    ValueWithExistsFlag.Exists(100),
                    ValueWithExistsFlag.Exists(200),
                    ValueWithExistsFlag.NotExists()
                }),
            };

            RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaNestedOne = new object[] { new int[] { 1, 2 }, SupportEventInfra.TwoEntryMap("keyOne", 100, "keyTwo", 200), new int[] { 1000, 2000 }, Collections.SingletonMap("xOne", "abc") };
            var oaOne       = new object[] { null, oaNestedOne };
            var oaTests     = new Pair <object[], ValueWithExistsFlag[]>[] {
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { null, null }, NOT_EXISTS),
                new Pair <object[], ValueWithExistsFlag[]>(oaOne, ValueWithExistsFlag.AllExist(1, 2, 2000, 100, 200, "abc")),
            };

            RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new Pair <string, ValueWithExistsFlag[]>[] {
                new Pair <string, ValueWithExistsFlag[]>("", NOT_EXISTS),
                new Pair <string, ValueWithExistsFlag[]>(
                    "<item>" +
                    "<indexed>1</indexed><indexed>2</indexed><mapped id=\"keyOne\">3</mapped><mapped id=\"keyTwo\">4</mapped>" +
                    "</item>", new ValueWithExistsFlag[]
                {
                    ValueWithExistsFlag.Exists("1"),
                    ValueWithExistsFlag.Exists("2"),
                    ValueWithExistsFlag.NotExists(),
                    ValueWithExistsFlag.Exists("3"),
                    ValueWithExistsFlag.Exists("4"),
                    ValueWithExistsFlag.NotExists()
                })
            };

            RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            var schema     = GetAvroSchema();
            var itemSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(schema.GetField("item").Schema).AsRecordSchema();
            var datumOne   = new GenericRecord(schema);

            datumOne.Put("item", null);
            var datumItemTwo = new GenericRecord(itemSchema);

            datumItemTwo.Put("indexed", Collections.List(1, 2));
            datumItemTwo.Put("mapped", SupportEventInfra.TwoEntryMap("keyOne", 3, "keyTwo", 4));
            var datumTwo = new GenericRecord(schema);

            datumTwo.Put("item", datumItemTwo);
            var avroTests = new Pair <GenericRecord, ValueWithExistsFlag[]>[] {
                new Pair <GenericRecord, ValueWithExistsFlag[]>(new GenericRecord(schema), NOT_EXISTS),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, NOT_EXISTS),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumTwo, new ValueWithExistsFlag[]
                {
                    ValueWithExistsFlag.Exists(1),
                    ValueWithExistsFlag.Exists(2),
                    ValueWithExistsFlag.NotExists(),
                    ValueWithExistsFlag.Exists(3),
                    ValueWithExistsFlag.Exists(4),
                    ValueWithExistsFlag.NotExists()
                }),
            };

            RunAssertion(SupportEventInfra.AVRO_TYPENAME, SupportEventInfra.FAVRO, null, avroTests, typeof(object));
        }
Beispiel #13
0
        public void TestIt()
        {
            var NOT_EXISTS = ValueWithExistsFlag.MultipleNotExists(6);

            // Bean
            SupportBeanComplexProps beanOne = SupportBeanComplexProps.MakeDefaultBean();
            string n1_v   = beanOne.Nested.NestedValue;
            string n1_n_v = beanOne.Nested.NestedNested.NestedNestedValue;
            SupportBeanComplexProps beanTwo = SupportBeanComplexProps.MakeDefaultBean();

            beanTwo.Nested.NestedValue = "nested1";
            beanTwo.Nested.NestedNested.SetNestedNestedValue("nested2");
            var beanTests = new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>[] {
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot(beanOne), ValueWithExistsFlag.AllExist(n1_v, n1_v, n1_n_v, n1_n_v, n1_n_v, n1_n_v)),
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot(beanTwo), ValueWithExistsFlag.AllExist("nested1", "nested1", "nested2", "nested2", "nested2", "nested2")),
                new Pair <SupportBeanDynRoot, ValueWithExistsFlag[]>(new SupportBeanDynRoot("abc"), NOT_EXISTS)
            };

            RunAssertion(BEAN_TYPENAME, SupportEventInfra.FBEAN, null, beanTests, typeof(object));

            // Map
            IDictionary <string, object> mapOneL2 = new Dictionary <string, object>();

            mapOneL2.Put("nestedNestedValue", 101);
            IDictionary <string, object> mapOneL1 = new Dictionary <string, object>();

            mapOneL1.Put("nestedNested", mapOneL2);
            mapOneL1.Put("nestedValue", 100);
            IDictionary <string, object> mapOneL0 = new Dictionary <string, object>();

            mapOneL0.Put("nested", mapOneL1);
            var mapOne   = Collections.SingletonDataMap("item", mapOneL0);
            var mapTests = new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>[] {
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(mapOne, ValueWithExistsFlag.AllExist(100, 100, 101, 101, 101, 101)),
                new Pair <IDictionary <string, object>, ValueWithExistsFlag[]>(Collections.EmptyDataMap, NOT_EXISTS),
            };

            RunAssertion(SupportEventInfra.MAP_TYPENAME, SupportEventInfra.FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaOneL2 = new object[] { 101 };
            var oaOneL1 = new object[] { oaOneL2, 100 };
            var oaOneL0 = new object[] { oaOneL1 };
            var oaOne   = new object[] { oaOneL0 };
            var oaTests = new Pair <object[], ValueWithExistsFlag[]>[] {
                new Pair <object[], ValueWithExistsFlag[]>(oaOne, ValueWithExistsFlag.AllExist(100, 100, 101, 101, 101, 101)),
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { null }, NOT_EXISTS),
            };

            RunAssertion(SupportEventInfra.OA_TYPENAME, SupportEventInfra.FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new Pair <string, ValueWithExistsFlag[]>[] {
                new Pair <string, ValueWithExistsFlag[]>("<item>\n" +
                                                         "\t<nested nestedValue=\"100\">\n" +
                                                         "\t\t<nestedNested nestedNestedValue=\"101\">\n" +
                                                         "\t\t</nestedNested>\n" +
                                                         "\t</nested>\n" +
                                                         "</item>\n", ValueWithExistsFlag.AllExist("100", "100", "101", "101", "101", "101")),
                new Pair <string, ValueWithExistsFlag[]>("<item/>", NOT_EXISTS),
            };

            RunAssertion(SupportEventInfra.XML_TYPENAME, SupportEventInfra.FXML, SupportEventInfra.XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            var schema       = GetAvroSchema();
            var nestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(
                schema.GetField("item").Schema.GetField("nested").Schema).AsRecordSchema();
            var nestedNestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(
                nestedSchema.GetField("nestedNested").Schema).AsRecordSchema();
            var nestedNestedDatum = new GenericRecord(nestedNestedSchema);

            nestedNestedDatum.Put("nestedNestedValue", 101);
            var nestedDatum = new GenericRecord(nestedSchema);

            nestedDatum.Put("nestedValue", 100);
            nestedDatum.Put("nestedNested", nestedNestedDatum);
            var emptyDatum = new GenericRecord(SchemaBuilder.Record(SupportEventInfra.AVRO_TYPENAME));
            var avroTests  = new Pair <object, ValueWithExistsFlag[]>[] {
                new Pair <object, ValueWithExistsFlag[]>(nestedDatum, ValueWithExistsFlag.AllExist(100, 100, 101, 101, 101, 101)),
                new Pair <object, ValueWithExistsFlag[]>(emptyDatum, NOT_EXISTS),
                new Pair <object, ValueWithExistsFlag[]>(null, NOT_EXISTS)
            };

            RunAssertion(SupportEventInfra.AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object));
        }
Beispiel #14
0
        public void Run(RegressionEnvironment env)
        {
            var notExists = MultipleNotExists(6);

            // Bean
            var beanOne = SupportBeanComplexProps.MakeDefaultBean();
            var n1v = beanOne.Nested.NestedValue;
            var n1nv = beanOne.Nested.NestedNested.NestedNestedValue;
            var beanTwo = SupportBeanComplexProps.MakeDefaultBean();
            beanTwo.Nested.NestedValue = "nested1";
            beanTwo.Nested.NestedNested.NestedNestedValue = "nested2";
            Pair<object, object>[] beanTests = {
                new Pair<object, object>(new SupportBeanDynRoot(beanOne), AllExist(n1v, n1v, n1nv, n1nv, n1nv, n1nv)),
                new Pair<object, object>(
                    new SupportBeanDynRoot(beanTwo),
                    AllExist("nested1", "nested1", "nested2", "nested2", "nested2", "nested2")),
                new Pair<object, object>(new SupportBeanDynRoot("abc"), notExists)
            };
            RunAssertion(env, "SupportBeanDynRoot", FBEAN, null, beanTests, typeof(object));

            // Map
            IDictionary<string, object> mapOneL2 = new Dictionary<string, object>();
            mapOneL2.Put("NestedNestedValue", 101);
            IDictionary<string, object> mapOneL1 = new Dictionary<string, object>();
            mapOneL1.Put("NestedNested", mapOneL2);
            mapOneL1.Put("NestedValue", 100);
            IDictionary<string, object> mapOneL0 = new Dictionary<string, object>();
            mapOneL0.Put("Nested", mapOneL1);
            var mapOne = Collections.SingletonDataMap("Item", mapOneL0);
            Pair<object, object>[] mapTests = {
                new Pair<object, object>(mapOne, AllExist(100, 100, 101, 101, 101, 101)),
                new Pair<object, object>(Collections.EmptyDataMap, notExists)
            };
            RunAssertion(env, MAP_TYPENAME, FMAP, null, mapTests, typeof(object));

            // Object-Array
            object[] oaOneL2 = {101};
            object[] oaOneL1 = {oaOneL2, 100};
            object[] oaOneL0 = {oaOneL1};
            object[] oaOne = {oaOneL0};
            Pair<object, object>[] oaTests = {
                new Pair<object, object>(oaOne, AllExist(100, 100, 101, 101, 101, 101)),
                new Pair<object, object>(new object[] {null}, notExists)
            };
            RunAssertion(env, OA_TYPENAME, FOA, null, oaTests, typeof(object));

            // XML
            Pair<object, object>[] xmlTests = {
                new Pair<object, object>(
                    "<Item>\n" +
                    "\t<Nested NestedValue=\"100\">\n" +
                    "\t\t<NestedNested NestedNestedValue=\"101\">\n" +
                    "\t\t</NestedNested>\n" +
                    "\t</Nested>\n" +
                    "</Item>\n",
                    AllExist("100", "100", "101", "101", "101", "101")),
                new Pair<object, object>("<item/>", notExists)
            };
            RunAssertion(env, XML_TYPENAME, FXML, xmlToValue, xmlTests, typeof(XmlNode));

            // Avro
            var schema =
                AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME));
            var nestedSchema =
                AvroSchemaUtil.FindUnionRecordSchemaSingle(
                    schema
                        .GetField("Item")
                        .Schema.AsRecordSchema()
                        .GetField("Nested")
                        .Schema);
            var nestedNestedSchema =
                AvroSchemaUtil.FindUnionRecordSchemaSingle(
                    nestedSchema.GetField("NestedNested").Schema);
            var nestedNestedDatum = new GenericRecord(nestedNestedSchema.AsRecordSchema());
            nestedNestedDatum.Put("NestedNestedValue", 101);
            var nestedDatum = new GenericRecord(nestedSchema.AsRecordSchema());
            nestedDatum.Put("NestedValue", 100);
            nestedDatum.Put("NestedNested", nestedNestedDatum);
            var emptyDatum = new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME));
            Pair<object, object>[] avroTests = {
                new Pair<object, object>(nestedDatum, AllExist(100, 100, 101, 101, 101, 101)),
                new Pair<object, object>(emptyDatum, notExists),
                new Pair<object, object>(null, notExists)
            };
            RunAssertion(env, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object));
        }
Beispiel #15
0
        public override void Run(EPServiceProvider epService)
        {
            AddMapEventType(epService);
            AddOAEventType(epService);
            epService.EPAdministrator.Configuration.AddEventType(BEAN_TYPE);
            AddAvroEventType(epService);

            var notExists = MultipleNotExists(6);

            // Bean
            var inner     = SupportBeanComplexProps.MakeDefaultBean();
            var beanTests = new[] {
                new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(new SupportBeanDynRoot("xxx"), notExists),
                new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(new SupportBeanDynRoot(inner), AllExist(
                                                                             inner.GetIndexed(0),
                                                                             inner.GetIndexed(1),
                                                                             inner.ArrayProperty[1],
                                                                             inner.GetMapped("keyOne"),
                                                                             inner.GetMapped("keyTwo"),
                                                                             inner.MapProperty.Get("xOne")
                                                                             )),
            };

            RunAssertion(epService, BEAN_TYPE.Name, FBEAN, null, beanTests, typeof(object));

            // Map
            var mapNestedOne = new Dictionary <string, object>();

            mapNestedOne.Put("indexed", new[] { 1, 2 });
            mapNestedOne.Put("arrayProperty", null);
            mapNestedOne.Put("mapped", TwoEntryMap("keyOne", 100, "keyTwo", 200));
            mapNestedOne.Put("mapProperty", null);
            var mapOne   = Collections.SingletonDataMap("item", mapNestedOne);
            var mapTests = new[] {
                new Pair <Map, ValueWithExistsFlag[]>(Collections.EmptyDataMap, notExists),
                new Pair <Map, ValueWithExistsFlag[]>(mapOne, new[] {
                    Exists(1),
                    Exists(2),
                    NotExists(),
                    Exists(100),
                    Exists(200),
                    NotExists()
                }),
            };

            RunAssertion(epService, MAP_TYPENAME, FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaNestedOne = new object[] { new[] { 1, 2 }, TwoEntryMap("keyOne", 100, "keyTwo", 200), new[] { 1000, 2000 }, Collections.SingletonMap("xOne", "abc") };
            var oaOne       = new object[] { null, oaNestedOne };
            var oaTests     = new[] {
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { null, null }, notExists),
                new Pair <object[], ValueWithExistsFlag[]>(oaOne, AllExist(1, 2, 2000, 100, 200, "abc")),
            };

            RunAssertion(epService, OA_TYPENAME, FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new[] {
                new Pair <string, ValueWithExistsFlag[]>("", notExists),
                new Pair <string, ValueWithExistsFlag[]>("<item>" +
                                                         "<indexed>1</indexed><indexed>2</indexed><mapped id=\"keyOne\">3</mapped><mapped id=\"keyTwo\">4</mapped>" +
                                                         "</item>", new[] {
                    Exists("1"),
                    Exists("2"),
                    NotExists(),
                    Exists("3"),
                    Exists("4"),
                    NotExists()
                })
            };

            RunAssertion(epService, XML_TYPENAME, FXML, XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            var schema     = GetAvroSchema();
            var itemSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(schema.GetField("item").Schema);
            var datumOne   = new GenericRecord(schema);

            datumOne.Put("item", null);
            var datumItemTwo = new GenericRecord(itemSchema.AsRecordSchema());

            datumItemTwo.Put("indexed", Collections.List(1, 2));
            datumItemTwo.Put("mapped", TwoEntryMap("keyOne", 3, "keyTwo", 4));
            var datumTwo = new GenericRecord(schema);

            datumTwo.Put("item", datumItemTwo);
            var avroTests = new[] {
                new Pair <GenericRecord, ValueWithExistsFlag[]>(new GenericRecord(schema), notExists),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, notExists),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumTwo, new[] {
                    Exists(1),
                    Exists(2),
                    NotExists(),
                    Exists(3),
                    Exists(4),
                    NotExists()
                }),
            };

            RunAssertion(epService, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object));
        }
Beispiel #16
0
        public void Run(RegressionEnvironment env)
        {
            RegressionPath path = new RegressionPath();

            // Bean
            RunAssertionConversionImplicitType(
                env,
                path,
                "Bean",
                "SupportBean",
                "ConvertEvent",
                typeof(BeanEventType),
                typeof(SupportBean),
                "SupportMarketDataBean",
                new SupportMarketDataBean("ACME", 0, 0L, null),
                FBEANWTYPE,
                "TheString".SplitCsv(),
                new object[] {"ACME"});

            // Map
            IDictionary<string, object> mapEventOne = new Dictionary<string, object>();
            mapEventOne.Put("one", "1");
            mapEventOne.Put("two", "2");
            RunAssertionConversionImplicitType(
                env,
                path,
                "Map",
                "MapOne",
                "ConvertEventMap",
                typeof(WrapperEventType),
                typeof(IDictionary<string, object>),
                "MapTwo",
                mapEventOne,
                FMAPWTYPE,
                "one,two".SplitCsv(),
                new object[] {"1", "|2|"});

            IDictionary<string, object> mapEventTwo = new Dictionary<string, object>();
            mapEventTwo.Put("one", "3");
            mapEventTwo.Put("two", "4");
            RunAssertionConversionConfiguredType(
                env,
                path,
                "MapOne",
                "ConvertEventMap",
                "MapTwo",
                typeof(MappedEventBean),
                typeof(Dictionary<string, object>),
                mapEventTwo,
                FMAPWTYPE,
                "one,two".SplitCsv(),
                new object[] {"3", "|4|"});

            // Object-Array
            RunAssertionConversionImplicitType(
                env,
                path,
                "OA",
                "OAOne",
                "ConvertEventObjectArray",
                typeof(WrapperEventType),
                typeof(object[]),
                "OATwo",
                new object[] {"1", "2"},
                FOAWTYPE,
                "one,two".SplitCsv(),
                new object[] {"1", "|2|"});
            RunAssertionConversionConfiguredType(
                env,
                path,
                "OAOne",
                "ConvertEventObjectArray",
                "OATwo",
                typeof(ObjectArrayBackedEventBean),
                typeof(object[]),
                new object[] {"3", "4"},
                FOAWTYPE,
                "one,two".SplitCsv(),
                new object[] {"3", "|4|"});

            // Avro
            var rowOne = new GenericRecord(
                AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("AvroOne")).AsRecordSchema());
            rowOne.Put("one", "1");
            rowOne.Put("two", "2");
            RunAssertionConversionImplicitType(
                env,
                path,
                "Avro",
                "AvroOne",
                "ConvertEventAvro",
                typeof(WrapperEventType),
                typeof(GenericRecord),
                "AvroTwo",
                rowOne,
                FAVROWTYPE,
                "one,two".SplitCsv(),
                new object[] {"1", "|2|"});

            var avroSchema = AvroSchemaUtil
                .ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("AvroTwo"))
                .AsRecordSchema();
            var rowTwo = new GenericRecord(avroSchema);
            rowTwo.Put("one", "3");
            rowTwo.Put("two", "4");
            RunAssertionConversionConfiguredType(
                env,
                path,
                "AvroOne",
                "ConvertEventAvro",
                "AvroTwo",
                typeof(AvroGenericDataBackedEventBean),
                typeof(GenericRecord),
                rowTwo,
                FAVROWTYPE,
                "one,two".SplitCsv(),
                new object[] {"3", "|4|"});

            // Json
            env.CompileDeploy(
                "@buseventtype @public create json schema JsonOne(one string, two string);\n" +
                "@buseventtype @public create json schema JsonTwo(one string, two string);\n",
                path);
            var jsonOne = new JObject();
            jsonOne.Add("one", "1");
            jsonOne.Add("two", "2");
            RunAssertionConversionImplicitType(
                env,
                path,
                "Json",
                "JsonOne",
                "ConvertEventJson",
                typeof(WrapperEventType),
                typeof(JsonEventObject),
                "JsonTwo",
                jsonOne.ToString(),
                FJSONWTYPE,
                "one,two".SplitCsv(),
                new object[] {"1", "|2|"});

            var jsonTwo = new JObject();
            jsonTwo.Add("one", "3");
            jsonTwo.Add("two", "4");
            RunAssertionConversionConfiguredType(
                env,
                path,
                "JsonOne",
                "ConvertEventJson",
                "JsonTwo",
                typeof(object),
                typeof(object),
                jsonTwo.ToString(),
                FJSONWTYPE,
                "one,two".SplitCsv(),
                new object[] {"3", "|4|"});

            env.UndeployAll();
        }
Beispiel #17
0
        public override void Run(EPServiceProvider epService)
        {
            AddMapEventType(epService);
            AddOAEventType(epService);
            epService.EPAdministrator.Configuration.AddEventType(BEAN_TYPE);
            AddAvroEventType(epService);

            // Bean
            var beanTests = new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>[] {
                new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(SupportBeanComplexProps.MakeDefaultBean(), AllExist("Simple", "NestedValue", "NestedNestedValue")),
                new Pair <SupportMarkerInterface, ValueWithExistsFlag[]>(new SupportMarkerImplA("x"), NOT_EXISTS),
            };

            RunAssertion(epService, BEAN_TYPE.Name, FBEAN, null, beanTests, typeof(object));

            // Map
            Map mapNestedNestedOne = Collections.SingletonDataMap("nestedNestedValue", 101);
            Map mapNestedOne       = TwoEntryMap("nestedNested", mapNestedNestedOne, "nestedValue", "abc");
            Map mapOne             = TwoEntryMap("simpleProperty", 5, "nested", mapNestedOne);
            var mapTests           = new Pair <Map, ValueWithExistsFlag[]>[] {
                new Pair <Map, ValueWithExistsFlag[]>(Collections.SingletonDataMap("simpleProperty", "a"), new ValueWithExistsFlag[] { Exists("a"), NotExists(), NotExists() }),
                new Pair <Map, ValueWithExistsFlag[]>(mapOne, AllExist(5, "abc", 101)),
            };

            RunAssertion(epService, MAP_TYPENAME, FMAP, null, mapTests, typeof(object));

            // Object-Array
            var oaNestedNestedOne = new object[] { 101 };
            var oaNestedOne       = new object[] { "abc", oaNestedNestedOne };
            var oaOne             = new object[] { 5, oaNestedOne };
            var oaTests           = new Pair <object[], ValueWithExistsFlag[]>[] {
                new Pair <object[], ValueWithExistsFlag[]>(new object[] { "a", null }, new ValueWithExistsFlag[] { Exists("a"), NotExists(), NotExists() }),
                new Pair <object[], ValueWithExistsFlag[]>(oaOne, AllExist(5, "abc", 101)),
            };

            RunAssertion(epService, OA_TYPENAME, FOA, null, oaTests, typeof(object));

            // XML
            var xmlTests = new Pair <string, ValueWithExistsFlag[]>[] {
                new Pair <string, ValueWithExistsFlag[]>(
                    "<simpleProperty>abc</simpleProperty>" +
                    "<nested nestedValue=\"100\">\n" +
                    "\t<nestedNested nestedNestedValue=\"101\">\n" +
                    "\t</nestedNested>\n" +
                    "</nested>\n", AllExist("abc", "100", "101")),
                new Pair <string, ValueWithExistsFlag[]>("<nested/>", NOT_EXISTS),
            };

            RunAssertion(epService, XML_TYPENAME, FXML, XML_TO_VALUE, xmlTests, typeof(XmlNode));

            // Avro
            var datumNull          = new GenericRecord(GetAvroSchema());
            var schema             = GetAvroSchema();
            var nestedSchema       = AvroSchemaUtil.FindUnionRecordSchemaSingle(schema.GetField("nested").Schema);
            var nestedNestedSchema = AvroSchemaUtil.FindUnionRecordSchemaSingle(nestedSchema.GetField("nestedNested").Schema);
            var nestedNestedDatum  = new GenericRecord(nestedNestedSchema.AsRecordSchema());

            nestedNestedDatum.Put("nestedNestedValue", 101);
            var nestedDatum = new GenericRecord(nestedSchema.AsRecordSchema());

            nestedDatum.Put("nestedValue", 100);
            nestedDatum.Put("nestedNested", nestedNestedDatum);
            var datumOne = new GenericRecord(schema);

            datumOne.Put("simpleProperty", "abc");
            datumOne.Put("nested", nestedDatum);
            var avroTests = new Pair <GenericRecord, ValueWithExistsFlag[]>[] {
                new Pair <GenericRecord, ValueWithExistsFlag[]>(new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME)), NOT_EXISTS),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumNull, new ValueWithExistsFlag[] { Exists(null), NotExists(), NotExists() }),
                new Pair <GenericRecord, ValueWithExistsFlag[]>(datumOne, AllExist("abc", 100, 101)),
            };

            RunAssertion(epService, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object));
        }
Beispiel #18
0
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();

            // Bean
            RunAssertionSendEvent(env, path, "SupportBean", new SupportBean());
            RunAssertionInvalid(
                env,
                "SupportBean",
                new SupportBean_G("G1"),
                "Event object of type " +
                typeof(SupportBean_G).MaskTypeName() +
                " does not equal, extend or implement the type " +
                typeof(SupportBean).MaskTypeName() +
                " of event type 'SupportBean'");
            RunAssertionSendEvent(env, path, "SupportMarkerInterface", new SupportMarkerImplA("Q2"), new SupportBean_G("Q3"));
            RunAssertionRouteEvent(env, path, "SupportBean", new SupportBean());

            // Map
            RunAssertionSendEvent(env, path, MAP_TYPENAME, new Dictionary <string, object>());
            RunAssertionRouteEvent(env, path, MAP_TYPENAME, new Dictionary <string, object>());
            RunAssertionInvalid(
                env,
                MAP_TYPENAME,
                new SupportBean(),
                "Unexpected event object of type " + typeof(SupportBean).MaskTypeName() + ", expected " + typeof(IDictionary <string, object>).CleanName());

            // Object-Array
            RunAssertionSendEvent(env, path, OA_TYPENAME, new object[] { });
            RunAssertionRouteEvent(env, path, OA_TYPENAME, new object[] { });
            RunAssertionInvalid(
                env,
                OA_TYPENAME,
                new SupportBean(),
                "Unexpected event object of type " + typeof(SupportBean).MaskTypeName() + ", expected Object[]");

            // XML
            RunAssertionSendEvent(env, path, XML_TYPENAME, SupportXML.GetDocument("<Myevent/>").DocumentElement);
            RunAssertionRouteEvent(env, path, XML_TYPENAME, SupportXML.GetDocument("<Myevent/>").DocumentElement);
            RunAssertionInvalid(
                env,
                XML_TYPENAME,
                new SupportBean(),
                "Unexpected event object type '" + typeof(SupportBean).MaskTypeName() + "' encountered, please supply a XmlDocument or XmlElement node");
            RunAssertionInvalid(
                env,
                XML_TYPENAME,
                SupportXML.GetDocument("<xxxx/>"),
                "Unexpected root element name 'xxxx' encountered, expected a root element name of 'Myevent'");

            // Avro
            var schema = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME))
                         .AsRecordSchema();

            RunAssertionSendEvent(env, path, AVRO_TYPENAME, new GenericRecord(schema));
            RunAssertionRouteEvent(env, path, AVRO_TYPENAME, new GenericRecord(schema));
            RunAssertionInvalid(
                env,
                AVRO_TYPENAME,
                new SupportBean(),
                "Unexpected event object type '" + typeof(SupportBean).MaskTypeName() + "' encountered, please supply a GenericRecord");

            // Json
            var schemas = "@public @buseventtype @name('schema') create json schema " + JSON_TYPENAME + "()";

            env.CompileDeploy(schemas, path);
            RunAssertionSendEvent(env, path, JSON_TYPENAME, "{}");
            RunAssertionRouteEvent(env, path, JSON_TYPENAME, "{}");
            RunAssertionInvalid(
                env,
                JSON_TYPENAME,
                new SupportBean(),
                "Unexpected event object of type '" + typeof(SupportBean).Name + "', expected a Json-formatted string-type value");

            // No such type
            try {
                env.EventService.GetEventSender("ABC");
                Assert.Fail();
            }
            catch (EventTypeException ex) {
                Assert.AreEqual("Event type named 'ABC' could not be found", ex.Message);
            }

            // Internal implicit wrapper type
            env.CompileDeploy("insert into ABC select *, TheString as value from SupportBean");
            try {
                env.EventService.GetEventSender("ABC");
                Assert.Fail("Event type named 'ABC' could not be found");
            }
            catch (EventTypeException ex) {
                Assert.AreEqual("Event type named 'ABC' could not be found", ex.Message);
            }

            env.UndeployAll();
        }
Beispiel #19
0
        public void Run(RegressionEnvironment env)
        {
            var notExists = MultipleNotExists(6);

            // Bean
            var inner = SupportBeanComplexProps.MakeDefaultBean();
            Pair<object, object>[] beanTests = {
                new Pair<object, object>(new SupportBeanDynRoot("xxx"), notExists),
                new Pair<object, object>(
                    new SupportBeanDynRoot(inner),
                    AllExist(
                        inner.GetIndexed(0),
                        inner.GetIndexed(1),
                        inner.ArrayProperty[1],
                        inner.GetMapped("keyOne"),
                        inner.GetMapped("keyTwo"),
                        inner.MapProperty.Get("xOne")))
            };
            RunAssertion(env, BEAN_TYPE.Name, FBEAN, null, beanTests, typeof(object));

            // Map
            IDictionary<string, object> mapNestedOne = new Dictionary<string, object>();
            mapNestedOne.Put("Indexed", new[] {1, 2});
            mapNestedOne.Put("ArrayProperty", null);
            mapNestedOne.Put("Mapped", TwoEntryMap("keyOne", 100, "keyTwo", 200));
            mapNestedOne.Put("MapProperty", null);
            var mapOne = Collections.SingletonDataMap("Item", mapNestedOne);
            Pair<object, object>[] mapTests = {
                new Pair<object, object>(Collections.EmptyDataMap, notExists),
                new Pair<object, object>(
                    mapOne,
                    new[] {Exists(1), Exists(2), NotExists(), Exists(100), Exists(200), NotExists()})
            };
            RunAssertion(env, MAP_TYPENAME, FMAP, null, mapTests, typeof(object));

            // Object-Array
            object[] oaNestedOne = {
                new[] {1, 2}, TwoEntryMap("keyOne", 100, "keyTwo", 200), new[] {1000, 2000},
                Collections.SingletonMap("xOne", "abc")
            };
            object[] oaOne = {null, oaNestedOne};
            Pair<object, object>[] oaTests = {
                new Pair<object, object>(new object[] {null, null}, notExists),
                new Pair<object, object>(oaOne, AllExist(1, 2, 2000, 100, 200, "abc"))
            };
            RunAssertion(env, OA_TYPENAME, FOA, null, oaTests, typeof(object));
            
            // XML
            Pair<object, object>[] xmlTests = {
                new Pair<object, object>("", notExists),
                new Pair<object, object>(
                    "<Item>" +
                    "<Indexed>1</Indexed>" +
                    "<Indexed>2</Indexed>" +
                    "<Mapped Id=\"keyOne\">3</Mapped>" + 
                    "<Mapped Id=\"keyTwo\">4</Mapped>" +
                    "</Item>",
                    new[] {Exists("1"), Exists("2"), NotExists(), Exists("3"), Exists("4"), NotExists()})
            };
            RunAssertion(env, XML_TYPENAME, FXML, xmlToValue, xmlTests, typeof(XmlNode));

            // Avro
            var schema = AvroSchemaUtil
                .ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME))
                .AsRecordSchema();
            var itemSchema = AvroSchemaUtil
                .FindUnionRecordSchemaSingle(schema.GetField("Item").Schema)
                .AsRecordSchema();
            var datumOne = new GenericRecord(schema);
            datumOne.Put("Item", null);
            var datumItemTwo = new GenericRecord(itemSchema);
            datumItemTwo.Put("Indexed", Arrays.AsList(1, 2));
            datumItemTwo.Put("Mapped", TwoEntryMap("keyOne", 3, "keyTwo", 4));
            var datumTwo = new GenericRecord(schema);
            datumTwo.Put("Item", datumItemTwo);
            Pair<object, object>[] avroTests = {
                new Pair<object, object>(new GenericRecord(schema), notExists),
                new Pair<object, object>(datumOne, notExists),
                new Pair<object, object>(
                    datumTwo,
                    new[] {Exists(1), Exists(2), NotExists(), Exists(3), Exists(4), NotExists()})
            };
            RunAssertion(env, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object));
        }
Beispiel #20
0
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('bean') select * from " +
                    BEAN_TYPENAME +
                    ";\n" +
                    "@Name('map') select * from " +
                    MAP_TYPENAME +
                    ";\n" +
                    "@Name('oa') select * from " +
                    OA_TYPENAME +
                    ";\n" +
                    "@Name('xml') select * from " +
                    XML_TYPENAME +
                    ";\n" +
                    "@Name('avro') select * from " +
                    AVRO_TYPENAME +
                    ";\n" +
                    "@public @buseventtype create json schema JsonEvent(Ident string);\n" +
                    "@Name('json') select * from JsonEvent;\n" +
                    "@Name('trigger') select * from SupportBean;";
                env.CompileDeploy(epl)
                    .AddListener("map")
                    .AddListener("oa")
                    .AddListener("xml")
                    .AddListener("avro")
                    .AddListener("bean")
                    .AddListener("json");

                env.Statement("trigger").Events += (
                    sender,
                    updateEventArgs) => {
                    var newEvents = updateEventArgs.NewEvents;
                    var processEvent = updateEventArgs.Runtime.EventService;
                    var ident = (string) newEvents[0].Get("TheString");

                    processEvent.RouteEventBean(new RoutedBeanEvent(ident), BEAN_TYPENAME);
                    processEvent.RouteEventMap(Collections.SingletonDataMap("Ident", ident), MAP_TYPENAME);
                    processEvent.RouteEventObjectArray(new object[] {ident}, OA_TYPENAME);

                    var xml = "<Myevent Ident=\"XXXXXX\"></Myevent>\n".Replace("XXXXXX", ident);
                    processEvent.RouteEventXMLDOM(SupportXML.GetDocument(xml).DocumentElement, XML_TYPENAME);

                    var avroSchema = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME));
                    var datum = new GenericRecord(avroSchema.AsRecordSchema());
                    datum.Put("Ident", ident);
                    processEvent.RouteEventAvro(datum, AVRO_TYPENAME);

                    var jsonObject = new JObject(new JProperty("Ident", ident));
                    processEvent.RouteEventJson(jsonObject.ToString(), "JsonEvent");
                };

                env.SendEventBean(new SupportBean("xy", -1));

                foreach (var name in new[] {"map", "bean", "oa", "xml", "avro", "json"}) {
                    var listener = env.Listener(name);
                    Assert.IsTrue(listener.IsInvoked, "failed for " + name);
                    Assert.AreEqual("xy", env.Listener(name).AssertOneGetNewAndReset().Get("Ident"));
                }

                env.UndeployAll();
            }