Esempio n. 1
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));
        }
Esempio n. 2
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));
        }
        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 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));
        }
Esempio n. 5
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));
        }
Esempio n. 6
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));
        }
Esempio n. 7
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));
        }
Esempio n. 8
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));
        }
Esempio n. 9
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));
        }