Exemplo n.º 1
0
 public LocalEventSubA(LocalInnerEvent property)
 {
     Property = property;
 }
 public LocalEvent(LocalInnerEvent property)
 {
     this.Property = property;
 }
Exemplo n.º 3
0
        public void Run(RegressionEnvironment env)
        {
            // Bean
            BiConsumer <EventType, string[]> bean = (
                type,
                array) => {
                LocalInnerEvent[] property;
                if (array == null)
                {
                    property = null;
                }
                else
                {
                    property = new LocalInnerEvent[array.Length];
                    for (var i = 0; i < array.Length; i++)
                    {
                        property[i] = new LocalInnerEvent(array[i]);
                    }
                }

                env.SendEventBean(new LocalEvent(property));
            };
            var beanepl = "@public @buseventtype create schema LocalInnerEvent as " +
                          typeof(LocalInnerEvent).MaskTypeName() +
                          ";\n" +
                          "@public @buseventtype create schema LocalEvent as " +
                          typeof(LocalEvent).MaskTypeName() +
                          ";\n";

            RunAssertion(env, beanepl, bean);

            // Map
            BiConsumer <EventType, string[]> map = (
                type,
                array) => {
                IDictionary <string, object>[] property;
                if (array == null)
                {
                    property = null;
                }
                else
                {
                    property = new IDictionary <string, object> [array.Length];
                    for (var i = 0; i < array.Length; i++)
                    {
                        property[i] = Collections.SingletonDataMap("Id", array[i]);
                    }
                }

                env.SendEventMap(Collections.SingletonDataMap("Property", property), "LocalEvent");
            };

            RunAssertion(env, GetEpl("map"), map);

            // Object-array
            BiConsumer <EventType, string[]> oa = (
                type,
                array) => {
                object[][] property;
                if (array == null)
                {
                    property = new object[][] { null };
                }
                else
                {
                    property = new object[array.Length][];
                    for (var i = 0; i < array.Length; i++)
                    {
                        property[i] = new object[] { array[i] };
                    }
                }

                env.SendEventObjectArray(new object[] { property }, "LocalEvent");
            };

            RunAssertion(env, GetEpl("objectarray"), oa);

            // Json
            BiConsumer <EventType, string[]> json = (
                type,
                array) => {
                JToken property;
                if (array == null)
                {
                    property = new JValue((object)null);
                }
                else
                {
                    var arr = new JArray();
                    for (var i = 0; i < array.Length; i++)
                    {
                        arr.Add(new JObject(new JProperty("Id", array[i])));
                    }

                    property = arr;
                }

                env.SendEventJson(new JObject(new JProperty("Property", property)).ToString(), "LocalEvent");
            };

            RunAssertion(env, GetEpl("json"), json);

            // Json-Class-Provided
            var eplJsonProvided = "@JsonSchema(ClassName='" +
                                  typeof(MyLocalJsonProvided).MaskTypeName() +
                                  "') @public @buseventtype create json schema LocalEvent();\n";

            RunAssertion(env, eplJsonProvided, json);

            // Avro
            BiConsumer <EventType, string[]> avro = (
                type,
                array) => {
                var schema = SupportAvroUtil.GetAvroSchema(type);
                var @event = new GenericRecord(schema.AsRecordSchema());
                if (array == null)
                {
                    @event.Put("Property", null);
                }
                else
                {
                    ICollection <GenericRecord> arr = new List <GenericRecord>();
                    for (var i = 0; i < array.Length; i++)
                    {
                        var inner = new GenericRecord(schema.GetField("Property")
                                                      .Schema.AsArraySchema()
                                                      .ItemSchema
                                                      .AsRecordSchema());
                        inner.Put("Id", array[i]);
                        arr.Add(inner);
                    }

                    @event.Put("Property", arr);
                }

                env.SendEventAvro(@event, "LocalEvent");
            };

            RunAssertion(env, GetEpl("avro"), avro);
        }
Exemplo n.º 4
0
        public void Run(RegressionEnvironment env)
        {
            // Bean
            BiConsumer <EventType, string[]> bean = (
                type,
                ids) => {
                var property = new LocalInnerEvent[ids.Length];
                for (var i = 0; i < ids.Length; i++)
                {
                    property[i] = new LocalInnerEvent(new LocalLeafEvent(ids[i]));
                }

                env.SendEventBean(new LocalEvent(property));
            };
            var beanepl = "@public @buseventtype create schema LocalLeafEvent as " +
                          typeof(LocalLeafEvent).MaskTypeName() +
                          ";\n" +
                          "@public @buseventtype create schema LocalInnerEvent as " +
                          typeof(LocalInnerEvent).MaskTypeName() +
                          ";\n" +
                          "@public @buseventtype create schema LocalEvent as " +
                          typeof(LocalEvent).MaskTypeName() +
                          ";\n";

            RunAssertion(env, beanepl, bean);

            // Map
            BiConsumer <EventType, string[]> map = (
                type,
                ids) => {
                var property = new IDictionary <string, object> [ids.Length];
                for (var i = 0; i < ids.Length; i++)
                {
                    property[i] = Collections.SingletonDataMap("Leaf", Collections.SingletonDataMap("Id", ids[i]));
                }

                env.SendEventMap(Collections.SingletonDataMap("Property", property), "LocalEvent");
            };

            RunAssertion(env, GetEpl("map"), map);

            // Object-array
            BiConsumer <EventType, string[]> oa = (
                type,
                ids) => {
                var property = new object[ids.Length][];
                for (var i = 0; i < ids.Length; i++)
                {
                    property[i] = new object[] { new object[] { ids[i] } };
                }

                env.SendEventObjectArray(new object[] { property }, "LocalEvent");
            };

            RunAssertion(env, GetEpl("objectarray"), oa);

            // Json
            BiConsumer <EventType, string[]> json = (
                type,
                ids) => {
                var property = new JArray();
                for (var i = 0; i < ids.Length; i++)
                {
                    var inner = new JObject(new JProperty("Leaf", new JObject(new JProperty("Id", ids[i]))));
                    property.Add(inner);
                }

                env.SendEventJson(new JObject(new JProperty("Property", property)).ToString(), "LocalEvent");
            };

            RunAssertion(env, GetEpl("json"), json);

            // Json-Class-Provided
            var eplJsonProvided = "@JsonSchema(ClassName='" + typeof(MyLocalJsonProvided).MaskTypeName() + "') @public @buseventtype create json schema LocalEvent();\n";

            RunAssertion(env, eplJsonProvided, json);

            // Avro
            BiConsumer <EventType, string[]> avro = (
                type,
                ids) => {
                var schema   = SupportAvroUtil.GetAvroSchema(type);
                var property = new List <GenericRecord>();
                for (var i = 0; i < ids.Length; i++)
                {
                    var leaf = new GenericRecord(
                        schema
                        .GetField("Property")
                        .Schema
                        .AsArraySchema()
                        .ItemSchema
                        .AsRecordSchema()
                        .GetField("Leaf")
                        .Schema
                        .AsRecordSchema()
                        );
                    leaf.Put("Id", ids[i]);
                    var inner = new GenericRecord(
                        schema
                        .GetField("Property")
                        .Schema
                        .AsArraySchema()
                        .ItemSchema
                        .AsRecordSchema());
                    inner.Put("Leaf", leaf);
                    property.Add(inner);
                }

                var @event = new GenericRecord(schema.AsRecordSchema());
                @event.Put("Property", property);
                env.SendEventAvro(@event, "LocalEvent");
            };

            RunAssertion(env, GetEpl("avro"), avro);
        }
Exemplo n.º 5
0
        public void Run(RegressionEnvironment env)
        {
            // Bean
            BiConsumer <EventType, string[]> bean = (
                type,
                ids) => {
                var inners = new LocalInnerEvent[ids.Length];
                for (var i = 0; i < ids.Length; i++)
                {
                    inners[i] = new LocalInnerEvent(ids[i]);
                }

                env.SendEventBean(new LocalEvent(inners));
            };
            var beanepl = "@public @buseventtype create schema LocalInnerEvent as " +
                          typeof(LocalInnerEvent).MaskTypeName() +
                          ";\n" +
                          "@public @buseventtype create schema LocalEvent as " +
                          typeof(LocalEvent).MaskTypeName() +
                          ";\n";

            RunAssertion(env, beanepl, bean);

            // Map
            BiConsumer <EventType, string[]> map = (
                type,
                ids) => {
                var inners = new IDictionary <string, object> [ids.Length];
                for (var i = 0; i < ids.Length; i++)
                {
                    inners[i] = Collections.SingletonDataMap("Id", ids[i]);
                }

                env.SendEventMap(Collections.SingletonDataMap("Indexed", inners), "LocalEvent");
            };
            var mapepl = "@public @buseventtype create schema LocalInnerEvent(Id string);\n" +
                         "@public @buseventtype create schema LocalEvent(Indexed LocalInnerEvent[]);\n";

            RunAssertion(env, mapepl, map);

            // Object-array
            BiConsumer <EventType, string[]> oa = (
                type,
                ids) => {
                var inners = new object[ids.Length][];
                for (var i = 0; i < ids.Length; i++)
                {
                    inners[i] = new object[] { ids[i] };
                }

                env.SendEventObjectArray(new object[] { inners }, "LocalEvent");
            };
            var oaepl = "@public @buseventtype create objectarray schema LocalInnerEvent(Id string);\n" +
                        "@public @buseventtype create objectarray schema LocalEvent(Indexed LocalInnerEvent[]);\n";

            RunAssertion(env, oaepl, oa);

            // Json
            BiConsumer <EventType, string[]> json = (
                type,
                ids) => {
                var array = new JArray();
                for (var i = 0; i < ids.Length; i++)
                {
                    array.Add(new JObject(new JProperty("Id", ids[i])));
                }

                var @event = new JObject(new JProperty("Indexed", array));
                env.SendEventJson(@event.ToString(), "LocalEvent");
            };
            var jsonepl =
                "@public @buseventtype create json schema LocalInnerEvent(Id string);\n" +
                "@public @buseventtype create json schema LocalEvent(Indexed LocalInnerEvent[]);\n";

            RunAssertion(env, jsonepl, json);

            // Json-Class-Provided
            var jsonProvidedEpl = "@JsonSchema(ClassName='" + typeof(MyLocalJsonProvided).MaskTypeName() + "') @public @buseventtype create json schema LocalEvent();\n";

            RunAssertion(env, jsonProvidedEpl, json);

            // Avro
            BiConsumer <EventType, string[]> avro = (
                type,
                ids) => {
                var schema = SchemaBuilder.Record(
                    "name",
                    TypeBuilder.Field(
                        "Id",
                        TypeBuilder.StringType(
                            TypeBuilder.Property(
                                AvroConstant.PROP_STRING_KEY,
                                AvroConstant.PROP_STRING_VALUE))));
                var inners = new List <GenericRecord>();
                for (var i = 0; i < ids.Length; i++)
                {
                    var inner = new GenericRecord(schema);
                    inner.Put("Id", ids[i]);
                    inners.Add(inner);
                }

                var @event = new GenericRecord(SupportAvroUtil.GetAvroSchema(type).AsRecordSchema());
                @event.Put("Indexed", inners);
                env.SendEventAvro(@event, "LocalEvent");
            };
            var avroepl = "@public @buseventtype create avro schema LocalInnerEvent(Id string);\n" +
                          "@public @buseventtype create avro schema LocalEvent(Indexed LocalInnerEvent[]);\n";

            RunAssertion(env, avroepl, avro);
        }