public void RunAssertion(
            RegressionEnvironment env,
            string typeName,
            string createSchemaEPL,
            BiConsumer <EventType, string> sender)
        {
            var epl =
                createSchemaEPL +
                $"@Name('s0') select * from {typeName};\n" +
                $"@Name('s1') select Property as c0, exists(Property) as c1, typeof(Property) as c2 from {typeName};\n";

            env.CompileDeploy(epl).AddListener("s0").AddListener("s1");

            var eventType = env.Statement("s0").EventType;

            var g0 = eventType.GetGetter("Property");

            sender.Invoke(eventType, "a");
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            AssertGetter(@event, g0, "a");
            AssertProps(env, "a");

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, null);
            AssertProps(env, null);

            env.UndeployAll();
        }
Exemplo n.º 2
0
        public void TestUnionResultingInNumber()
        {
            var schema = SchemaBuilder.Record(
                "typename",
                Field("anUnion", Union(IntType(), FloatType())));

            EventType eventType = SupportAvroUtil.MakeAvroSupportEventType(schema);

            AssertPropertyType(typeof(object), null, eventType, "anUnion");

            Consumer <Object> asserterFromDatum = (value) => {
                var datum = new GenericRecord(schema);
                datum.Put("anUnion", value);
                Assert.AreEqual(value, new AvroGenericDataEventBean(datum, eventType).Get("anUnion"));
            };

            asserterFromDatum.Invoke(1);
            asserterFromDatum.Invoke(2f);

            BiConsumer <String, Object> asserterFromJson = (
                json,
                value) => {
                var datum = SupportAvroUtil.ParseQuoted(schema, json);
                Assert.AreEqual(value, new AvroGenericDataEventBean(datum, eventType).Get("anUnion"));
            };

            asserterFromJson.Invoke("{'anUnion':{'int':1}}", 1);
            asserterFromJson.Invoke("{'anUnion':{'float':2}}", 2f);
        }
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, NullableObject <string> > sender)
        {
            var epl = createSchemaEPL +
                      "@Name('s0') select * from LocalEvent;\n" +
                      "@Name('s1') select Property.Id as c0, exists(Property.Id) as c1, typeof(Property.Id) as c2 from LocalEvent;\n";

            env.CompileDeploy(epl).AddListener("s0").AddListener("s1");
            var eventType = env.Statement("s0").EventType;

            var g0 = eventType.GetGetter("Property.Id");

            sender.Invoke(eventType, new NullableObject <string>("a"));
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            AssertGetter(@event, g0, true, "a");
            AssertProps(env, true, "a");

            sender.Invoke(eventType, new NullableObject <string>(null));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, true, null);
            AssertProps(env, true, null);

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertProps(env, false, null);

            env.UndeployAll();
        }
Exemplo n.º 4
0
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, IDictionary <string, string> > sender)
        {
            var path = new RegressionPath();

            env.CompileDeploy(createSchemaEPL, path);

            env.CompileDeploy("@Name('s0') select * from LocalEvent", path).AddListener("s0");
            var eventType = env.Statement("s0").EventType;
            var g0        = eventType.GetGetter("Mapped('a')");
            var g1        = eventType.GetGetter("Mapped('b')");

            var propepl = "@Name('s1') select Mapped('a') as c0, Mapped('b') as c1," +
                          "exists(Mapped('a')) as c2, exists(Mapped('b')) as c3, " +
                          "typeof(Mapped('a')) as c4, typeof(Mapped('b')) as c5 from LocalEvent;\n";

            env.CompileDeploy(propepl, path).AddListener("s1");

            IDictionary <string, string> values = new Dictionary <string, string>();

            values.Put("a", "x");
            values.Put("b", "y");
            sender.Invoke(eventType, values);
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            AssertGetter(@event, g0, true, "x");
            AssertGetter(@event, g1, true, "y");
            AssertProps(env, "x", "y");

            sender.Invoke(eventType, Collections.SingletonMap("a", "x"));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, true, "x");
            AssertGetter(@event, g1, false, null);
            AssertProps(env, "x", null);

            sender.Invoke(eventType, EmptyDictionary <string, string> .Instance);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            env.UndeployAll();
        }
Exemplo n.º 5
0
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, string[]> sender)
        {
            var path = new RegressionPath();

            env.CompileDeploy(createSchemaEPL, path);

            env.CompileDeploy("@Name('s0') select * from LocalEvent", path).AddListener("s0");
            var eventType = env.Statement("s0").EventType;
            var g0        = eventType.GetGetter("Array[0]");
            var g1        = eventType.GetGetter("Array[1]");

            var propepl = "@Name('s1') select Array[0] as c0, Array[1] as c1," +
                          "exists(Array[0]) as c2, exists(Array[1]) as c3, " +
                          "typeof(Array[0]) as c4, typeof(Array[1]) as c5 from LocalEvent;\n";

            env.CompileDeploy(propepl, path).AddListener("s1");

            sender.Invoke(eventType, new string[] { "a", "b" });
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            AssertGetter(@event, g0, true, "a");
            AssertGetter(@event, g1, true, "b");
            AssertProps(env, "a", "b");

            sender.Invoke(eventType, new string[] { "a" });
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, true, "a");
            AssertGetter(@event, g1, false, null);
            AssertProps(env, "a", null);

            sender.Invoke(eventType, new string[0]);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            env.UndeployAll();
        }
Exemplo n.º 6
0
        private void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, Nullable2Lvl> sender)
        {
            var path = new RegressionPath();

            env.CompileDeploy(createSchemaEPL, path);

            env.CompileDeploy("@Name('s0') select * from LocalEvent", path).AddListener("s0");
            var eventType = env.Statement("s0").EventType;
            var g0        = eventType.GetGetter("Property?.Leaf.Id");

            if (sender == null)
            {
                Assert.IsNull(g0);
                env.UndeployAll();
                return;
            }
            else
            {
                var propepl = "@Name('s1') select Property?.Leaf.Id as c0, exists(Property?.Leaf.Id) as c1, typeof(Property?.Leaf.Id) as c2 from LocalEvent;\n";
                env.CompileDeploy(propepl, path).AddListener("s1");
            }

            sender.Invoke(eventType, new Nullable2Lvl(false, false, "a"));
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            AssertGetter(@event, g0, true, "a");
            AssertProps(env, true, "a");

            sender.Invoke(eventType, new Nullable2Lvl(false, false, null));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, true, null);
            AssertProps(env, true, null);

            sender.Invoke(eventType, new Nullable2Lvl(false, true, null));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertProps(env, false, null);

            sender.Invoke(eventType, new Nullable2Lvl(true, false, null));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertProps(env, false, null);

            env.UndeployAll();
        }
        public void TraverseStatementsContains(
            BiConsumer <EPDeployment, EPStatement> consumer,
            string containsIgnoreCase)
        {
            _runtimeSPI.TraverseStatements(
                (
                    deployment,
                    stmt) => {
                var match        = false;
                var searchString = containsIgnoreCase.ToLowerInvariant();
                if (stmt.Name.ToLowerInvariant().Contains(searchString))
                {
                    match = true;
                }

                if (!match)
                {
                    var epl = (string)stmt.GetProperty(StatementProperty.EPL);
                    if ((epl != null) && (epl.ToLowerInvariant().Contains(searchString)))
                    {
                        match = true;
                    }
                }

                if (!match)
                {
                    return;
                }

                consumer.Invoke(deployment, stmt);
            });
        }
Exemplo n.º 8
0
 public void EndVisit(
     IntSeqKey controllerPath,
     BiConsumer<ContextControllerInitTermPartitionKey, int> partKeyAndCPId)
 {
     foreach (var entry in endConditions) {
         partKeyAndCPId.Invoke(entry.Value.PartitionKey, entry.Value.SubpathIdOrCPId);
     }
 }
 public void KeyVisit(
     IntSeqKey controllerPath,
     BiConsumer<object, int> keyAndSubpathOrCPId)
 {
     foreach (var entry in _keys) {
         keyAndSubpathOrCPId.Invoke(entry.Key, entry.Value.SubpathOrCPId);
     }
 }
 public void EndVisitConditions(
     IntSeqKey controllerPath,
     BiConsumer<ContextControllerConditionNonHA, int> partKeyAndCPId)
 {
     foreach (var entry in endConditions) {
         partKeyAndCPId.Invoke(entry.Value.TerminationCondition, entry.Value.SubpathIdOrCPId);
     }
 }
Exemplo n.º 11
0
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, string[]> sender)
        {
            var epl = createSchemaEPL +
                      "@Name('s0') select * from LocalEvent;\n" +
                      "@Name('s1') select Property[0].Id as c0, Property[1].Id as c1," +
                      " exists(Property[0].Id) as c2, exists(Property[1].Id) as c3," +
                      " typeof(Property[0].Id) as c4, typeof(Property[1].Id) as c5" +
                      " from LocalEvent;\n";

            env.CompileDeploy(epl).AddListener("s0").AddListener("s1");
            var eventType = env.Statement("s0").EventType;

            var g0 = eventType.GetGetter("Property[0].Id");
            var g1 = eventType.GetGetter("Property[1].Id");

            sender.Invoke(eventType, new string[] { "a", "b" });
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            AssertGetter(@event, g0, true, "a");
            AssertGetter(@event, g1, true, "b");
            AssertProps(env, true, "a", true, "b");

            sender.Invoke(eventType, new string[] { "a" });
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, true, "a");
            AssertGetter(@event, g1, false, null);
            AssertProps(env, true, "a", false, null);

            sender.Invoke(eventType, new string[0]);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, false, null, false, null);

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, false, null, false, null);

            env.UndeployAll();
        }
Exemplo n.º 12
0
 public void TraverseStatements(BiConsumer<EPDeployment, EPStatement> consumer)
 {
     foreach (var deploymentId in DeploymentService.Deployments) {
         var deployment = DeploymentService.GetDeployment(deploymentId);
         if (deployment != null) {
             foreach (var stmt in deployment.Statements) {
                 consumer.Invoke(deployment, stmt);
             }
         }
     }
 }
        public void HashVisit(
            IntSeqKey controllerPath,
            BiConsumer<int, int> hashAndCPId)
        {
            if (optionalHashes == null) {
                if (subpathOrCPIdsPreallocate == null) {
                    return;
                }

                for (var i = 0; i < subpathOrCPIdsPreallocate.Length; i++) {
                    hashAndCPId.Invoke(i, subpathOrCPIdsPreallocate[i]);
                }

                return;
            }

            foreach (var entry in optionalHashes) {
                hashAndCPId.Invoke(entry.Key, entry.Value);
            }
        }
Exemplo n.º 14
0
 private static void RunAssertionSetGet(
     RegressionEnvironment env,
     string deploymentId,
     string variableName,
     object value,
     BiConsumer<object, object> assertion)
 {
     env.Runtime.VariableService.SetVariableValue(deploymentId, variableName, value);
     var returned = env.Runtime.VariableService.GetVariableValue(deploymentId, variableName);
     assertion.Invoke(value, returned);
 }
Exemplo n.º 15
0
 public static void TraverseAnnotations<T>(
     IList<Type> classes, 
     BiConsumer<Type, T> consumer)
     where T : Attribute
 {
     var annotationClass = typeof(T);
     WalkAnnotations(classes, (annotation, clazz) => {
         if (annotation.GetType() == annotationClass) {
             consumer.Invoke(clazz, (T) annotation);
         }
     });
 }
Exemplo n.º 16
0
        public static void DispatchPartition<T>(
            CopyOnWriteList<ContextPartitionStateListener> listeners,
            Supplier<T> supplier,
            BiConsumer<ContextPartitionStateListener, T> consumer)
        {
            if (listeners == null || listeners.IsEmpty()) {
                return;
            }

            T @event = supplier.Invoke();
            foreach (var listener in listeners) {
                consumer.Invoke(listener, @event);
            }
        }
 public void TraverseStatementsFilterExpr(
     BiConsumer <EPDeployment, EPStatement> consumer,
     ExprNode filterExpr)
 {
     _runtimeSPI.TraverseStatements(
         (
             deployment,
             stmt) => {
         if (EvaluateStatement(filterExpr, stmt))
         {
             consumer.Invoke(deployment, stmt);
         }
     });
 }
Exemplo n.º 18
0
        public void TestUnionResultingInObject()
        {
            var schema = SchemaBuilder.Record(
                "typename",
                Field(
                    "anUnion",
                    Union(
                        IntType(),
                        StringType(Property(PROP_STRING_KEY, PROP_STRING_VALUE)),
                        NullType())));

            EventType eventType = SupportAvroUtil.MakeAvroSupportEventType(schema);

            AssertPropertyType(typeof(object), null, eventType, "anUnion");

            Consumer <Object> asserterFromDatum = (value) => {
                var datum = new GenericRecord(schema);
                datum.Put("anUnion", value);
                Assert.AreEqual(value, new AvroGenericDataEventBean(datum, eventType).Get("anUnion"));
            };

            asserterFromDatum.Invoke("a");
            asserterFromDatum.Invoke(1);
            asserterFromDatum.Invoke(null);

            BiConsumer <String, Object> asserterFromJson = (
                json,
                value) => {
                var datum = SupportAvroUtil.ParseQuoted(schema, json);
                Assert.AreEqual(value, new AvroGenericDataEventBean(datum, eventType).Get("anUnion"));
            }
            ;

            asserterFromJson.Invoke("{'anUnion':{'int':1}}", 1);
            asserterFromJson.Invoke("{'anUnion':{'string':'abc'}}", "abc");
            asserterFromJson.Invoke("{'anUnion':null}", null);
        }
Exemplo n.º 19
0
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, string> sender)
        {
            env.CompileDeploy(createSchemaEPL + "@Name('s0') select * from LocalEvent[Property];\n").AddListener("s0");
            var eventType = env.Runtime.EventTypeService.GetEventType(env.DeploymentId("s0"), "LocalEvent");

            sender.Invoke(eventType, "a");
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            Assert.AreEqual("a", @event.Get("Id"));

            env.UndeployAll();
        }
        public void HashVisit(
            IntSeqKey controllerPath,
            BiConsumer<int, int> hashAndCPId)
        {
            if (_optionalHashes == null) {
                var mgmtInfo = _mgmt.Get(controllerPath);
                if (mgmtInfo == null || mgmtInfo.SubpathOrCPIdsPreallocate == null) {
                    return;
                }

                var subpathOrCPIds = mgmtInfo.SubpathOrCPIdsPreallocate;
                for (var i = 0; i < subpathOrCPIds.Length; i++) {
                    hashAndCPId.Invoke(i, subpathOrCPIds[i]);
                }

                return;
            }

            foreach (var entry in _optionalHashes) {
                if (controllerPath.IsParentTo(entry.Key)) {
                    hashAndCPId.Invoke(entry.Key.Last, entry.Value);
                }
            }
        }
Exemplo n.º 21
0
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, string[]> sender)
        {
            env.CompileDeploy(
                createSchemaEPL +
                "create constant variable int offsetNum = 0;" +
                "@Name('s0') select Indexed(offsetNum+0) as c0, Indexed(offsetNum+1) as c1 from LocalEvent as e;\n"
                )
            .AddListener("s0");
            var eventType = env.Runtime.EventTypeService.GetEventType(env.DeploymentId("s0"), "LocalEvent");

            sender.Invoke(eventType, new string[] { "a", "b" });
            EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), "c0,c1".SplitCsv(), new object[] { "a", "b" });

            env.UndeployAll();
        }
Exemplo n.º 22
0
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, IDictionary <string, string> > sender)
        {
            env.CompileDeploy(
                createSchemaEPL +
                "create constant variable string keyChar = 'a';" +
                "@Name('s0') select Mapped(keyChar||'1') as c0, Mapped(keyChar||'2') as c1 from LocalEvent as e;\n"
                )
            .AddListener("s0");
            var eventType = env.Runtime.EventTypeService.GetEventType(env.DeploymentId("s0"), "LocalEvent");

            IDictionary <string, string> values = new Dictionary <string, string>();

            values.Put("a1", "x");
            values.Put("a2", "y");
            sender.Invoke(eventType, values);
            EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), "c0,c1".SplitCsv(), new object[] { "x", "y" });

            env.UndeployAll();
        }
Exemplo n.º 23
0
 public void TraverseWithModule(BiConsumer<string, TE> consumer)
 {
     foreach (var entry in _modules) {
         consumer.Invoke(entry.Key, entry.Value.Entity);
     }
 }
Exemplo n.º 24
0
        public void RunAssertion(
            RegressionEnvironment env,
            string createSchemaEPL,
            BiConsumer <EventType, NullableObject <string[]> > sender)
        {
            var path = new RegressionPath();

            env.CompileDeploy(createSchemaEPL, path);

            env.CompileDeploy("@Name('s0') select * from LocalEvent", path).AddListener("s0");
            var eventType = env.Statement("s0").EventType;
            var g0        = eventType.GetGetter("Array[0]?");
            var g1        = eventType.GetGetter("Array[1]?");

            if (sender == null)
            {
                Assert.IsNull(g0);
                Assert.IsNull(g1);
                env.UndeployAll();
                return;
            }
            else
            {
                var propepl =
                    "@Name('s1') select " +
                    "Array[0]? as c0, " +
                    "Array[1]? as c1," +
                    "exists(Array[0]?) as c2, " +
                    "exists(Array[1]?) as c3, " +
                    "typeof(Array[0]?) as c4, " +
                    "typeof(Array[1]?) as c5 " +
                    "from LocalEvent;\n";
                env.CompileDeploy(propepl, path).AddListener("s1");
            }

            sender.Invoke(eventType, new NullableObject <string[]>(new string[] { "a", "b" }));
            var @event = env.Listener("s0").AssertOneGetNewAndReset();

            AssertGetter(@event, g0, true, "a");
            AssertGetter(@event, g1, true, "b");
            AssertProps(env, "a", "b");

            sender.Invoke(eventType, new NullableObject <string[]>(new string[] { "a" }));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, true, "a");
            AssertGetter(@event, g1, false, null);
            AssertProps(env, "a", null);

            sender.Invoke(eventType, new NullableObject <string[]>(new string[0]));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            sender.Invoke(eventType, new NullableObject <string[]>(null));
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            sender.Invoke(eventType, null);
            @event = env.Listener("s0").AssertOneGetNewAndReset();
            AssertGetter(@event, g0, false, null);
            AssertGetter(@event, g1, false, null);
            AssertProps(env, null, null);

            env.UndeployAll();
        }