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

            RunAssertion(env, BEAN_TYPENAME, FBEAN, typeof(InfraNestedSimplePropLvl1), typeof(InfraNestedSimplePropLvl1).FullName, path);
            RunAssertion(env, MAP_TYPENAME, FMAP, typeof(IDictionary <string, object>), MAP_TYPENAME + "_1", path);
            RunAssertion(env, OA_TYPENAME, FOA, typeof(object[]), OA_TYPENAME + "_1", path);
            RunAssertion(env, XML_TYPENAME, FXML, typeof(XmlNode), XML_TYPENAME + ".L1", path);
            RunAssertion(env, AVRO_TYPENAME, FAVRO, typeof(GenericRecord), AVRO_TYPENAME + "_1", path);

            var epl =
                "create json schema " + JSON_TYPENAME + "_4(Lvl4 int);\n" +
                "create json schema " + JSON_TYPENAME + "_3(Lvl3 int, L4 " + JSON_TYPENAME + "_4);\n" +
                "create json schema " + JSON_TYPENAME + "_2(Lvl2 int, L3 " + JSON_TYPENAME + "_3);\n" +
                "create json schema " + JSON_TYPENAME + "_1(Lvl1 int, L2 " + JSON_TYPENAME + "_2);\n" +
                "@Name('types') @public @buseventtype " +
                "create json schema " + JSON_TYPENAME + "(L1 " + JSON_TYPENAME + "_1);\n";

            env.CompileDeploy(epl, path);
            var nestedClass = SupportJsonEventTypeUtil.GetUnderlyingType(env, "types", JSON_TYPENAME + "_1");

            RunAssertion(env, JSON_TYPENAME, FJSON, nestedClass, JSON_TYPENAME + "_1", path);

            epl = $"@JsonSchema(ClassName='{typeof(MyLocalJSONProvidedTop).MaskTypeName()}') @name('types') @public @buseventtype create json schema {JSONPROVIDED_TYPENAME}();\n";
            env.CompileDeploy(epl, path);
            RunAssertion(env, JSONPROVIDED_TYPENAME, FJSON, typeof(MyLocalJSONProvidedLvl1), typeof(MyLocalJSONProvidedLvl1).FullName, path);

            env.UndeployAll();
        }
Ejemplo n.º 2
0
            private void AssertEvent(EventBean @event)
            {
                var und = (JsonEventObjectBase)@event.Underlying;

                Assert.That(und.NativeCount, Is.EqualTo(4));
                Assert.That(und.NativeContainsKey("p1"), Is.True);
                Assert.That(und.NativeContainsKey("p3"), Is.False);
                Assert.That(und.NativeContainsKey("c1"), Is.True);
                CollectionAssert.AreEquivalent(
                    new[] { "p1", "p2", "c1", "c2" },
                    und.NativeKeys);
                CollectionAssert.AreEquivalent(
                    new [] {
                    new KeyValuePair <string, object>("p1", "abc"),
                    new KeyValuePair <string, object>("p2", 10),
                    new KeyValuePair <string, object>("c1", "def"),
                    new KeyValuePair <string, object>("c2", 20)
                },
                    und.NativeEnumerable);

                Assert.IsTrue(und.JsonValues.IsEmpty());

                IDictionary <string, object> compared = new LinkedHashMap <string, object>();

                compared.Put("p1", "abc");
                compared.Put("p2", 10);
                compared.Put("c1", "def");
                compared.Put("c2", 20);
                SupportJsonEventTypeUtil.CompareDictionaries(compared, und);

                Assert.AreEqual("{\"p1\":\"abc\",\"p2\":10,\"c1\":\"def\",\"c2\":20}", und.ToString());
            }
Ejemplo n.º 3
0
        private static void AssertEventJson(
            EventBean eventBean,
            string json,
            object expected)
        {
            var @event = (JsonEventObjectBase)eventBean.Underlying;

            SupportJsonEventTypeUtil.CompareDictionaries(Collections.SingletonDataMap("value", expected), @event);
            Assert.AreEqual(json, @event.ToString());
        }
Ejemplo n.º 4
0
            private void AssertAny(
                LinkedHashMap <string, object> expected,
                string jsonOne,
                EventBean @event)
            {
                var und = (JsonEventObject)@event.Underlying;

                SupportJsonEventTypeUtil.CompareDictionaries(expected, und);
                Assert.AreEqual(jsonOne, und.ToString());
            }
 private void AssertGetter(
     EventBean @event,
     EventPropertyGetter getter,
     bool exists,
     string value)
 {
     Assert.AreEqual(SupportJsonEventTypeUtil.IsBeanBackedJson(@event.EventType) || exists, getter.IsExistsProperty(@event));
     Assert.AreEqual(value, getter.Get(@event));
     Assert.IsNull(getter.GetFragment(@event));
 }
Ejemplo n.º 6
0
        private void RunAssertionTypeValidProp(
            RegressionEnvironment env,
            bool preconfigured,
            string typeName,
            FunctionSendEvent4IntWArrayNested send,
            Type nestedClass,
            string fragmentTypeName)
        {
            var eventType = preconfigured
                                ? env.Runtime.EventTypeService.GetEventTypePreconfigured(typeName)
                                : env.Runtime.EventTypeService.GetEventType(env.DeploymentId("types"), typeName);

            var arrayType = nestedClass == typeof(object[]) ? nestedClass : TypeHelper.GetArrayType(nestedClass);
            //arrayType = arrayType == typeof(GenericRecord[]) ? typeof(ICollection) : arrayType;
            var expectedType = new object[][] {
                new object[] { "l1", arrayType, fragmentTypeName, true }
            };

            SupportEventTypeAssertionUtil.AssertEventTypeProperties(expectedType, eventType, SupportEventTypeAssertionEnumExtensions.GetSetWithFragment());

            EPAssertionUtil.AssertEqualsAnyOrder(new string[] { "l1" }, eventType.PropertyNames);

            foreach (var prop in Arrays.AsList("l1[0]", "l1[0].lvl1", "l1[0].l2", "l1[0].l2[0]", "l1[0].l2[0].lvl2"))
            {
                Assert.IsNotNull(eventType.GetGetter(prop));
                Assert.IsTrue(eventType.IsProperty(prop));
            }

            Assert.IsTrue(TypeHelper.IsSubclassOrImplementsInterface(eventType.GetPropertyType("l1"), arrayType));
            foreach (var prop in Arrays.AsList("l1[0].lvl1", "l1[0].l2[0].lvl2", "l1[0].l2[0].l3[0].lvl3"))
            {
                Assert.AreEqual(typeof(int?), eventType.GetPropertyType(prop).GetBoxedType());
            }

            var lvl1Fragment = eventType.GetFragmentType("l1");

            Assert.IsTrue(lvl1Fragment.IsIndexed);
            var isNative = typeName.Equals(BEAN_TYPENAME);

            Assert.AreEqual(isNative, lvl1Fragment.IsNative);
            Assert.AreEqual(fragmentTypeName, lvl1Fragment.FragmentType.Name);

            var lvl2Fragment = eventType.GetFragmentType("l1[0].l2");

            Assert.IsTrue(lvl2Fragment.IsIndexed);
            Assert.AreEqual(isNative, lvl2Fragment.IsNative);

            if (typeName.Equals(JSON_TYPENAME))
            {
                arrayType   = TypeHelper.GetArrayType(SupportJsonEventTypeUtil.GetNestedUnderlyingType((JsonEventType)eventType, "l1"));
                nestedClass = arrayType.GetElementType();
            }

            Assert.AreEqual(new EventPropertyDescriptor("l1", arrayType, nestedClass, false, false, true, false, true), eventType.GetPropertyDescriptor("l1"));
        }
Ejemplo n.º 7
0
            private void AssertEvent(EventBean @event)
            {
                var und = (JsonEventObjectBase)@event.Underlying;

                Assert.That(und.NativeCount, Is.Zero);
                Assert.That(und.TryGetValue("x", out var result), Is.False);
                Assert.IsTrue(und.JsonValues.IsEmpty());

                SupportJsonEventTypeUtil.CompareDictionaries(new LinkedHashMap <string, object>(), und);
                Assert.AreEqual("{}", und.ToString());
            }
        private void AssertGetter(
            EventBean @event,
            EventPropertyGetter getter,
            bool exists)
        {
            Assert.AreEqual(exists, getter.IsExistsProperty(@event));
            Assert.AreEqual(exists, getter.Get(@event) != null);
            var beanBacked = @event.EventType is BeanEventType || SupportJsonEventTypeUtil.IsBeanBackedJson(@event.EventType);

            Assert.AreEqual(beanBacked && exists, getter.GetFragment(@event) != null);
        }
        private void AssertProps(
            RegressionEnvironment env,
            EventType eventType,
            bool exists,
            string value)
        {
            var @event = env.Listener("s1").AssertOneGetNewAndReset();

            Assert.AreEqual(value, @event.Get("c0"));
            Assert.AreEqual(SupportJsonEventTypeUtil.IsBeanBackedJson(eventType) || exists, @event.Get("c1"));
            Assert.AreEqual(value != null ? "String" : null, @event.Get("c2"));
        }
Ejemplo n.º 10
0
            private void AssertEvent(EventBean @event)
            {
                var und = (JsonEventObjectBase)@event.Underlying;

                Assert.That(und.NativeCount, Is.EqualTo(6));
                Assert.That(und.NativeContainsKey("a1"), Is.True);
                Assert.That(und.NativeContainsKey("b1"), Is.True);
                Assert.That(und.NativeContainsKey("b2"), Is.True);

                CollectionAssert.AreEquivalent(
                    new[] { "a1", "b1", "b2", "c1", "d1", "d2" },
                    und.NativeKeys);

                CollectionAssert.AreEquivalent(
                    new [] {
                    new KeyValuePair <string, object>("a1", 4d),
                    new KeyValuePair <string, object>("c1", "def")
                },
                    und.NativeEnumerable);

                Assert.That(und.NativeCount, Is.EqualTo(6));
                Assert.That(und.NativeContainsKey("a1"), Is.True);
                Assert.That(und.NativeContainsKey("a2"), Is.False);
                Assert.That(und.NativeContainsKey("c1"), Is.True);
                CollectionAssert.AreEquivalent(
                    new[] { "a1", "b1", "b2", "c1", "d1", "d2" },
                    und.NativeKeys);
                CollectionAssert.AreEquivalent(
                    new [] {
                    new KeyValuePair <string, object>("a1", 4d),
                    new KeyValuePair <string, object>("b1", "x"),
                    new KeyValuePair <string, object>("b2", 3),
                    new KeyValuePair <string, object>("c1", "def"),
                    new KeyValuePair <string, object>("d1", 2d),
                    new KeyValuePair <string, object>("d2", 1)
                },
                    und.NativeEnumerable);

                Assert.IsTrue(und.JsonValues.IsEmpty());

                IDictionary <string, object> compared = new LinkedHashMap <string, object>();

                compared.Put("a1", 4d);
                compared.Put("b1", "x");
                compared.Put("b2", 3);
                compared.Put("c1", "def");
                compared.Put("d1", 2d);
                compared.Put("d2", 1);
                SupportJsonEventTypeUtil.CompareDictionaries(compared, und);

                Assert.AreEqual("{\"a1\":4.0,\"b1\":\"x\",\"b2\":3,\"c1\":\"def\",\"d1\":2.0,\"d2\":1}", und.ToString());
            }