private void RunAssertionMeasurePresence(
            RegressionEnvironment env,
            long baseTime,
            string select,
            object value)
        {
            env.AdvanceTime(baseTime);
            var epl = "@Name('s0') select * from SupportBean  " +
                      "match_recognize (" +
                      "    measures A as a, A.TheString as Id, " +
                      select +
                      " as val " +
                      "    pattern (A B*) " +
                      "    interval 1 minute " +
                      "    define " +
                      "        A as (A.IntPrimitive=1)," +
                      "        B as (B.IntPrimitive=2))";
            env.CompileDeploy(epl).AddListener("s0");

            env.SendEventBean(new SupportBean("E1", 1));
            env.SendEventBean(new SupportBean("E2", 2));

            env.AdvanceTimeSpan(baseTime + 60 * 1000 * 2);
            Assert.AreEqual(value, env.Listener("s0").NewDataListFlattened[0].Get("val"));

            env.UndeployAll();
        }
 private static void SetCurrentTime(
     RegressionEnvironment env,
     string time)
 {
     var timestamp = "2002-05-30T" + time + ".000";
     var current = DateTimeParsingFunctions.ParseDefaultMSec(timestamp);
     Console.Out.WriteLine("Advancing time to " + timestamp + " msec " + current);
     env.AdvanceTimeSpan(current);
 }
Exemple #3
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);

                env.CompileDeploy(
                    "@Name('s0') select current_timestamp() as ct from pattern[every timer:interval(1.5 sec)]");
                env.AddListener("s0");

                env.AdvanceTimeSpan(3500);
                Assert.AreEqual(2, env.Listener("s0").NewDataList.Count);
                Assert.AreEqual(1500L, env.Listener("s0").NewDataList[0][0].Get("ct"));
                Assert.AreEqual(3000L, env.Listener("s0").NewDataList[1][0].Get("ct"));
                env.Listener("s0").Reset();

                env.AdvanceTimeSpan(4500);
                Assert.AreEqual(1, env.Listener("s0").NewDataList.Count);
                Assert.AreEqual(4500L, env.Listener("s0").NewDataList[0][0].Get("ct"));
                env.Listener("s0").Reset();

                env.AdvanceTimeSpan(9000);
                Assert.AreEqual(3, env.Listener("s0").NewDataList.Count);
                Assert.AreEqual(6000L, env.Listener("s0").NewDataList[0][0].Get("ct"));
                Assert.AreEqual(7500L, env.Listener("s0").NewDataList[1][0].Get("ct"));
                Assert.AreEqual(9000L, env.Listener("s0").NewDataList[2][0].Get("ct"));
                env.Listener("s0").Reset();

                env.AdvanceTimeSpan(10499);
                Assert.AreEqual(0, env.Listener("s0").NewDataList.Count);

                env.AdvanceTimeSpan(10499);
                Assert.AreEqual(0, env.Listener("s0").NewDataList.Count);

                env.AdvanceTimeSpan(10500);
                Assert.AreEqual(1, env.Listener("s0").NewDataList.Count);
                Assert.AreEqual(10500L, env.Listener("s0").NewDataList[0][0].Get("ct"));
                env.Listener("s0").Reset();

                env.AdvanceTimeSpan(10500);
                Assert.AreEqual(0, env.Listener("s0").NewDataList.Count);

                env.EventService.AdvanceTimeSpan(14000, 200);
                Assert.AreEqual(14000, env.EventService.CurrentTime);
                Assert.AreEqual(2, env.Listener("s0").NewDataList.Count);
                Assert.AreEqual(12100L, env.Listener("s0").NewDataList[0][0].Get("ct"));
                Assert.AreEqual(13700L, env.Listener("s0").NewDataList[1][0].Get("ct"));

                env.UndeployAll();
            }