Beispiel #1
0
        private void RunAssertionFormat(EPServiceProvider epService)
        {
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            string[] fields      = "val0,val1,val2".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.Format() as val0," +
                                   "utildate.Format() as val1," +
                                   "longdate.Format() as val2" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(string), typeof(string), typeof(string)
            });

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            object[] expected = SupportDateTime.GetArrayCoerced(startTime,
                                                                "str[utc]", "str[utc]", "str[utc]");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, expected);

            epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {
                SupportDateTime.GetValueCoerced(startTime, "str[utc]"), null, null
            });

            stmtFragment.Dispose();
        }
Beispiel #2
0
        private void RunAssertionInput(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2".Split(',');
            string   eplFragment = "select " +
                                   "utildate.set('month', 1) as val0," +
                                   "longdate.set('month', 1) as val1," +
                                   "caldate.set('month', 1) as val2 " +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[]
            {
                typeof(DateTimeOffset?),
                typeof(long?),
                typeof(DateTimeEx)
            });

            string startTime    = "2002-05-30T09:00:00.000";
            string expectedTime = "2002-1-30T09:00:00.000";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "util", "long", "cal"));

            stmtFragment.Dispose();
        }
Beispiel #3
0
        public void TestFormat()
        {
            String startTime = "2002-05-30 09:00:00.000";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            String[] fields      = "val0,val1,val2".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.format() as val0," +
                                   "utildate.format() as val1," +
                                   "longdate.format() as val2" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(string), typeof(string), typeof(string) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            Object[] expected = SupportDateTime.GetArrayCoerced(startTime, "str[utc]", "str[utc]", "str[utc]");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, expected);

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { SupportDateTime.GetValueCoerced(startTime, "str[utc]"), null, null });
        }
Beispiel #4
0
        public void TestPlusMinusTimePeriod()
        {
            String startTime = "2002-05-30 9:00:00.000";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            String[] fields      = "val0,val1,val2,val4,val5,val6".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.plus(1 hour 10 sec 20 msec) as val0," +
                                   "utildate.plus(1 hour 10 sec 20 msec) as val1," +
                                   "msecdate.plus(1 hour 10 sec 20 msec) as val2," +
                                   "current_timestamp.minus(1 hour 10 sec 20 msec) as val4," +
                                   "utildate.minus(1 hour 10 sec 20 msec) as val5," +
                                   "msecdate.minus(1 hour 10 sec 20 msec) as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(long?), typeof(DateTimeOffset?), typeof(long?), typeof(long?), typeof(DateTimeOffset?), typeof(long?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            Object[] expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30 10:00:10.020", "msec", "util", "msec");
            Object[] expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30 07:59:49.980", "msec", "util", "msec");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30 10:00:10.020", "msec", "null", "null");
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30 07:59:49.980", "msec", "null", "null");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));
        }
Beispiel #5
0
        public void TestFields()
        {
            String[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7".Split(',');
            String   eplFragment = "select " +
                                   "utildate.withMax('msec') as val0," +
                                   "utildate.withMax('sec') as val1," +
                                   "utildate.withMax('minutes') as val2," +
                                   "utildate.withMax('hour') as val3," +
                                   "utildate.withMax('day') as val4," +
                                   "utildate.withMax('month') as val5," +
                                   "utildate.withMax('year') as val6," +
                                   "utildate.withMax('week') as val7" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?) });

            String[] expected =
            {
                "2002-5-30 09:00:00.999",
                "2002-5-30 09:00:59.000",
                "2002-5-30 09:59:00.000",
                "2002-5-30 23:00:00.000",
                "2002-5-31 09:00:00.000",
                "2002-12-30 09:00:00.000",
                "9999-05-30 09:00:00.000",
                "2002-12-26 09:00:00.000"
            };
            String startTime = "2002-05-30 09:00:00.000";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expected, "util"));
        }
Beispiel #6
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2", "val3" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTime.withMax('month') as val0," +
                                  "DateTimeOffset.withMax('month') as val1," +
                                  "DateTimeEx.withMax('month') as val2," +
                                  "LongDate.withMax('month') as val3" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTime?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeEx),
                        typeof(long?)
                    });

                var startTime = "2002-05-30T09:00:00.000";
                var expectedTime = "2002-12-30T09:00:00.000";
                env.SendEventBean(SupportDateTime.Make(startTime));

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    SupportDateTime.GetArrayCoerced(expectedTime, "datetime", "dto", "dtx", "long"));

                env.UndeployAll();
            }
Beispiel #7
0
        public void TestRoundCeil()
        {
            String[] fields      = "val0,val1,val2,val3,val4,val5,val6".Split(',');
            String   eplFragment = "select " +
                                   "utildate.roundCeiling('msec') as val0," +
                                   "utildate.roundCeiling('sec') as val1," +
                                   "utildate.roundCeiling('minutes') as val2," +
                                   "utildate.roundCeiling('hour') as val3," +
                                   "utildate.roundCeiling('day') as val4," +
                                   "utildate.roundCeiling('month') as val5," +
                                   "utildate.roundCeiling('year') as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?) });

            String[] expected =
            {
                "2002-05-30 09:01:02.003",
                "2002-05-30 09:01:03.000",
                "2002-05-30 09:02:00.000",
                "2002-05-30 10:00:00.000",
                "2002-05-31 00:00:00.000",
                "2002-06-1 00:00:00.000",
                "2003-01-1 00:00:00.000",
            };
            String startTime = "2002-05-30 09:01:02.003";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expected, "util"));
        }
Beispiel #8
0
        public void TestCalOps()
        {
            String[] fields      = "val0,val1".Split(',');
            String   eplFragment = "select " +
                                   "utildate.set('hour', 1).set('minute', 2).set('second', 3) as val0," +
                                   "msecdate.set('hour', 1).set('minute', 2).set('second', 3) as val1" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(long?) });

            String startTime    = "2002-05-30 09:00:00.000";
            String expectedTime = "2002-05-30 1:02:03.000";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expectedTime, "util", "msec"));

            stmtFragment.Dispose();
            eplFragment = "select " +
                          "utildate.set('hour', 1).set('minute', 2).set('second', 3).toCalendar() as val0," +
                          "msecdate.set('hour', 1).set('minute', 2).set('second', 3).toCalendar() as val1" +
                          " from SupportDateTime";
            stmtFragment         = _epService.EPAdministrator.CreateEPL(eplFragment);
            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(DateTimeOffset?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expectedTime, "cal", "cal"));
        }
Beispiel #9
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create variable int varhour");
            epService.EPAdministrator.CreateEPL("create variable int varmin");
            epService.EPAdministrator.CreateEPL("create variable int varsec");
            epService.EPAdministrator.CreateEPL("create variable int varmsec");
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            string[] fields      = "val0,val1,val2,val3".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.WithTime(varhour, varmin, varsec, varmsec) as val0," +
                                   "utildate.WithTime(varhour, varmin, varsec, varmsec) as val1," +
                                   "longdate.WithTime(varhour, varmin, varsec, varmsec) as val2," +
                                   "caldate.WithTime(varhour, varmin, varsec, varmsec) as val3" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(long?), typeof(DateTimeOffset?), typeof(long?), typeof(DateTimeEx)
            });

            epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {
                SupportDateTime.GetValueCoerced(startTime, "long"), null, null, null
            });

            string expectedTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SetVariableValue("varhour", null); // variable is null
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "long", "util", "long", "cal"));

            expectedTime = "2002-05-30T01:02:03.004";
            epService.EPRuntime.SetVariableValue("varhour", 1);
            epService.EPRuntime.SetVariableValue("varmin", 2);
            epService.EPRuntime.SetVariableValue("varsec", 3);
            epService.EPRuntime.SetVariableValue("varmsec", 4);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "long", "util", "long", "cal"));

            expectedTime = "2002-05-30T00:00:00.006";
            epService.EPRuntime.SetVariableValue("varhour", 0);
            epService.EPRuntime.SetVariableValue("varmin", null);
            epService.EPRuntime.SetVariableValue("varsec", null);
            epService.EPRuntime.SetVariableValue("varmsec", 6);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "long", "util", "long", "cal"));
        }
Beispiel #10
0
        private void RunAssertionRoundHalf(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2,val3,val4,val5,val6".Split(',');
            string   eplFragment = "select " +
                                   "utildate.RoundHalf('msec') as val0," +
                                   "utildate.RoundHalf('sec') as val1," +
                                   "utildate.RoundHalf('minutes') as val2," +
                                   "utildate.RoundHalf('hour') as val3," +
                                   "utildate.RoundHalf('day') as val4," +
                                   "utildate.RoundHalf('month') as val5," +
                                   "utildate.RoundHalf('year') as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[]
            {
                typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?)
            });

            string[] expected =
            {
                "2002-05-30T15:30:02.550",
                "2002-05-30T15:30:03.000",
                "2002-05-30T15:30:00.000",
                "2002-05-30T16:00:00.00",
                "2002-05-31T00:00:00.000",
                "2002-06-01T00:00:00.000",
                "2002-01-01T00:00:00.000",
            };
            string startTime = "2002-05-30T15:30:02.550";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expected, "util"));

            // test rounding up/down
            stmtFragment.Dispose();
            fields               = "val0".Split(',');
            eplFragment          = "select Utildate.RoundHalf('min') as val0 from SupportDateTime";
            stmtFragment         = epService.EPAdministrator.CreateEPL(eplFragment);
            stmtFragment.Events += listener.Update;

            epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T15:30:29.999"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { SupportDateTime.GetValueCoerced("2002-05-30T15:30:00.000", "util") });

            epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T15:30:30.000"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { SupportDateTime.GetValueCoerced("2002-05-30T15:31:00.000", "util") });

            epService.EPRuntime.SendEvent(SupportDateTime.Make("2002-05-30T15:30:30.001"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { SupportDateTime.GetValueCoerced("2002-05-30T15:31:00.000", "util") });

            stmtFragment.Dispose();
        }
Beispiel #11
0
        private void RunAssertionPlusMinus(EPServiceProvider epService)
        {
            epService.EPAdministrator.CreateEPL("create variable long varmsec");
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            string[] fields      = "val0,val1,val2,val3,val4,val5".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.Plus(varmsec) as val0," +
                                   "utildate.Plus(varmsec) as val1," +
                                   "longdate.Plus(varmsec) as val2," +
                                   "current_timestamp.minus(varmsec) as val3," +
                                   "utildate.Minus(varmsec) as val4," +
                                   "longdate.Minus(varmsec) as val5" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(long?), typeof(DateTimeOffset?), typeof(long?),
                typeof(long?), typeof(DateTimeOffset?), typeof(long?)
            });

            epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {
                SupportDateTime.GetValueCoerced(startTime, "long"), null, null,
                SupportDateTime.GetValueCoerced(startTime, "long"), null, null
            });

            object[] expectedPlus  = SupportDateTime.GetArrayCoerced(startTime, "long", "util", "long");
            object[] expectedMinus = SupportDateTime.GetArrayCoerced(startTime, "long", "util", "long");
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            epService.EPRuntime.SetVariableValue("varmsec", 1000);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            //Log.Info("===> " + SupportDateTime.Print(listener.AssertOneGetNew().Get("val4")));
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30T09:00:01.000", "long", "util", "long");
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30T08:59:59.000", "long", "util", "long");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            epService.EPRuntime.SetVariableValue("varmsec", 2 * 24 * 60 * 60 * 1000);
            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-28T09:00:00.000", "long", "util", "long");
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-06-1T09:00:00.000", "long", "util", "long");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            stmtFragment.Dispose();
        }
Beispiel #12
0
        private void RunAssertionFields(EPServiceProvider epService)
        {
            string[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7".Split(',');
            string   eplFragment = "select " +
                                   "utildate.WithMax('msec') as val0," +
                                   "utildate.WithMax('sec') as val1," +
                                   "utildate.WithMax('minutes') as val2," +
                                   "utildate.WithMax('hour') as val3," +
                                   "utildate.WithMax('day') as val4," +
                                   "utildate.WithMax('month') as val5," +
                                   "utildate.WithMax('year') as val6," +
                                   "utildate.WithMax('week') as val7" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[]
            {
                typeof(DateTimeOffset?),
                typeof(DateTimeOffset?),
                typeof(DateTimeOffset?),
                typeof(DateTimeOffset?),
                typeof(DateTimeOffset?),
                typeof(DateTimeOffset?),
                typeof(DateTimeOffset?),
                typeof(DateTimeOffset?)
            });

            string[] expected =
            {
                "2002-5-30T09:00:00.999",
                "2002-5-30T09:00:59.000",
                "2002-5-30T09:59:00.000",
                "2002-5-30T23:00:00.000",
                "2002-5-31T09:00:00.000",
                "2002-12-30T09:00:00.000",
                "9999-05-30T09:00:00.000",
                "2002-12-26T09:00:00.000"
            };
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expected, "util"));

            stmtFragment.Dispose();
        }
Beispiel #13
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2","val3","val4","val5","val6" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTimeOffset.set('msec', 1) as val0," +
                                  "DateTimeOffset.set('sec', 2) as val1," +
                                  "DateTimeOffset.set('minutes', 3) as val2," +
                                  "DateTimeOffset.set('hour', 13) as val3," +
                                  "DateTimeOffset.set('day', 5) as val4," +
                                  "DateTimeOffset.set('month', 6) as val5," +
                                  "DateTimeOffset.set('year', 7) as val6" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTimeOffset?), // val0
                        typeof(DateTimeOffset?), // val1
                        typeof(DateTimeOffset?), // val2
                        typeof(DateTimeOffset?), // val3
                        typeof(DateTimeOffset?), // val4
                        typeof(DateTimeOffset?), // val5
                        typeof(DateTimeOffset?)  // val6
                    });

                string[] expected = {
                    "2002-05-30T09:00:00.001", // val0
                    "2002-05-30T09:00:02.000", // val1
                    "2002-05-30T09:03:00.000", // val2
                    "2002-05-30T13:00:00.000", // val3
                    "2002-05-05T09:00:00.000", // val4
                    "2002-06-30T09:00:00.000", // val5
                    "0007-05-30T09:00:00.000"  // val6
                };
                var startTime = "2002-05-30T09:00:00.000";
                env.SendEventBean(SupportDateTime.Make(startTime));
                var datesCoerced = SupportDateTime.GetArrayCoerced(expected, "dto");
                
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    datesCoerced);

                env.UndeployAll();
            }
Beispiel #14
0
        public void TestPlusMinus()
        {
            _epService.EPAdministrator.CreateEPL("create variable long varmsec");
            String startTime = "2002-05-30 9:00:00.000";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            String[] fields      = "val0,val1,val2,val4,val5,val6".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.plus(varmsec) as val0," +
                                   "utildate.plus(varmsec) as val1," +
                                   "msecdate.plus(varmsec) as val2," +
                                   "current_timestamp.minus(varmsec) as val4," +
                                   "utildate.minus(varmsec) as val5," +
                                   "msecdate.minus(varmsec) as val6" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(long?), typeof(DateTimeOffset?), typeof(long?), typeof(long?), typeof(DateTimeOffset?), typeof(long?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] {
                SupportDateTime.GetValueCoerced(startTime, "msec"), null, null,
                SupportDateTime.GetValueCoerced(startTime, "msec"), null, null,
            });

            Object[] expectedPlus  = SupportDateTime.GetArrayCoerced(startTime, "msec", "util", "msec");
            Object[] expectedMinus = SupportDateTime.GetArrayCoerced(startTime, "msec", "util", "msec");
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            _epService.EPRuntime.SetVariableValue("varmsec", 1000);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            //Console.WriteLine("===> " + SupportDateTime.Print(listener.AssertOneGetNew().Get("val4")));
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30 09:00:01.000", "msec", "util", "msec");
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30 08:59:59.000", "msec", "util", "msec");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            _epService.EPRuntime.SetVariableValue("varmsec", 2 * 24 * 60 * 60 * 1000);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-28 09:00:00.000", "msec", "util", "msec");
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-06-1 09:00:00.000", "msec", "util", "msec");
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));
        }
Beispiel #15
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2","val3","val4","val5","val6" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTimeOffset.withMin('msec') as val0," +
                                  "DateTimeOffset.withMin('sec') as val1," +
                                  "DateTimeOffset.withMin('minutes') as val2," +
                                  "DateTimeOffset.withMin('hour') as val3," +
                                  "DateTimeOffset.withMin('day') as val4," +
                                  "DateTimeOffset.withMin('month') as val5," +
                                  "DateTimeOffset.withMin('year') as val6" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?)
                    });

                string[] expected = {
                    "2002-05-30T09:01:02.000",
                    "2002-05-30T09:01:00.003",
                    "2002-05-30T09:00:02.003",
                    "2002-05-30T00:01:02.003",
                    "2002-05-01T09:01:02.003",
                    "2002-01-30T09:01:02.003",
                    "0001-05-30T09:01:02.003"
                };
                var startTime = "2002-05-30T09:01:02.003";
                env.SendEventBean(SupportDateTime.Make(startTime));
                //System.out.println("==-> " + SupportDateTime.print(env.Listener("s0").assertOneGetNew().Get("val7")));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    SupportDateTime.GetArrayCoerced(expected, "dto"));

                env.UndeployAll();
            }
Beispiel #16
0
        public void TestInput()
        {
            String[] fields      = "val0,val1".Split(',');
            String   eplFragment = "select " +
                                   "utildate.roundCeiling('hour') as val0," +
                                   "msecdate.roundCeiling('hour') as val1" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(DateTimeOffset?), typeof(long?) });

            String startTime    = "2002-05-30 09:01:02.003";
            String expectedTime = "2002-5-30 10:00:00.000";

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expectedTime, "util", "msec"));
        }
Beispiel #17
0
            public void Run(RegressionEnvironment env)
            {
                var startTime = "2002-05-30T09:00:00.000";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

                var fields = new [] { "val0","val1","val2","val3", "val4" };
                var eplFragment = "@Name('s0') select " +
                                  "current_timestamp.format() as val0," +
                                  "DateTimeEx.format() as val1," +
                                  "DateTimeOffset.format() as val2," +
                                  "DateTime.format() as val3," +
                                  "LongDate.format() as val4" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(string), // val0
                        typeof(string), // val1
                        typeof(string), // val2
                        typeof(string), // val3
                        typeof(string)  // val4
                    });

                env.SendEventBean(SupportDateTime.Make(startTime));
                var expected = SupportDateTime.GetArrayCoerced(startTime, "iso", "iso", "iso", "iso", "iso");
                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, expected);

                env.SendEventBean(SupportDateTime.Make(null));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new[] {
                        SupportDateTime.GetValueCoerced(startTime, "iso"),
                        null,
                        null,
                        null,
                        null
                    });

                env.UndeployAll();
            }
Beispiel #18
0
        public void TestWithDate()
        {
            _epService.EPAdministrator.CreateEPL("create variable int varyear");
            _epService.EPAdministrator.CreateEPL("create variable int varmonth");
            _epService.EPAdministrator.CreateEPL("create variable int varday");

            String startTime = "2002-05-30 09:00:00.000";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            String[] fields      = "val0,val1,val2".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.withDate(varyear, varmonth, varday) as val0," +
                                   "utildate.withDate(varyear, varmonth, varday) as val1," +
                                   "msecdate.withDate(varyear, varmonth, varday) as val2" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] { typeof(long?), typeof(DateTimeOffset?), typeof(long?) });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        new Object[] { SupportDateTime.GetValueCoerced(startTime, "msec"), null, null });

            String expectedTime = "2004-09-03 09:00:00.000";

            _epService.EPRuntime.SetVariableValue("varyear", 2004);
            _epService.EPRuntime.SetVariableValue("varmonth", 9);
            _epService.EPRuntime.SetVariableValue("varday", 3);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "msec", "util", "msec"));

            expectedTime = "2002-09-30 09:00:00.000";
            _epService.EPRuntime.SetVariableValue("varyear", null);
            _epService.EPRuntime.SetVariableValue("varmonth", 9);
            _epService.EPRuntime.SetVariableValue("varday", null);
            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields,
                                        SupportDateTime.GetArrayCoerced(expectedTime, "msec", "util", "msec"));
        }
Beispiel #19
0
        public override void Run(EPServiceProvider epService)
        {
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            string[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7,val8".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.toDate() as val0," +
                                   "utildate.toDate() as val1," +
                                   "longdate.toDate() as val2," +
                                   "current_timestamp.toCalendar() as val3," +
                                   "utildate.toCalendar() as val4," +
                                   "longdate.toCalendar() as val5," +
                                   "current_timestamp.toMillisec() as val6," +
                                   "utildate.toMillisec() as val7," +
                                   "longdate.toMillisec() as val8" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(DateTimeOffset), typeof(DateTimeOffset), typeof(DateTimeOffset),
                typeof(DateTimeEx), typeof(DateTimeEx), typeof(DateTimeEx),
                typeof(long), typeof(long), typeof(long)
            });

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            object[] expectedUtil = SupportDateTime.GetArrayCoerced(startTime, "util", "util", "util");
            object[] expectedCal  = SupportDateTime.GetArrayCoerced(startTime, "cal", "cal", "cal");
            object[] expectedMsec = SupportDateTime.GetArrayCoerced(startTime, "long", "long", "long");
            object[] expected     = EPAssertionUtil.ConcatenateArray(expectedUtil, expectedCal, expectedMsec);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, expected);

            epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] {
                SupportDateTime.GetValueCoerced(startTime, "util"), null, null,
                SupportDateTime.GetValueCoerced(startTime, "cal"), null, null,
                SupportDateTime.GetValueCoerced(startTime, "long"), null, null
            });
        }
Beispiel #20
0
        public void TestFields()
        {
            String[] fields      = "val0,val1,val2,val3,val4,val5,val6,val7".Split(',');
            String   eplFragment = "select " +
                                   "utildate.WithMin('msec') as val0," +
                                   "utildate.WithMin('sec') as val1," +
                                   "utildate.WithMin('minutes') as val2," +
                                   "utildate.WithMin('hour') as val3," +
                                   "utildate.WithMin('day') as val4," +
                                   "utildate.WithMin('month') as val5," +
                                   "utildate.WithMin('year') as val6," +
                                   "utildate.WithMin('week') as val7" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[]
            {
                typeof(DateTimeOffset?), typeof(DateTimeOffset?),
                typeof(DateTimeOffset?), typeof(DateTimeOffset?),
                typeof(DateTimeOffset?), typeof(DateTimeOffset?),
                typeof(DateTimeOffset?), typeof(DateTimeOffset?)
            });

            String[] expected =
            {
                "2002-05-30 09:01:02.000",
                "2002-05-30 09:01:00.003",
                "2002-05-30 09:00:02.003",
                "2002-05-30 00:01:02.003",
                "2002-05-01 09:01:02.003",
                "2002-01-30 09:01:02.003",
                "0001-05-30 09:01:02.003",
                "2002-01-03 09:01:02.003",
            };
            String startTime = "2002-05-30 09:01:02.003";

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            //Console.Out.WriteLine("===> " + SupportDateTime.Print(listener.AssertOneGetNew().Get("val7")));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, SupportDateTime.GetArrayCoerced(expected, "util"));
        }
        public void TestToDateCalMilli()
        {
            String startTime = "2002-05-30 09:00:00.000";

            _epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            String[] fields      = "val0,val1,val2,val4,val5,val6,val8,val9,val10".Split(',');
            String   eplFragment = "select " +
                                   "current_timestamp.ToDate() as val0," +
                                   "utildate.ToDate() as val1," +
                                   "msecdate.ToDate() as val2," +
                                   "current_timestamp.ToCalendar() as val4," +
                                   "utildate.ToCalendar() as val5," +
                                   "msecdate.ToCalendar() as val6," +
                                   "current_timestamp.ToMillisec() as val8," +
                                   "utildate.ToMillisec() as val9," +
                                   "msecdate.ToMillisec() as val10" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?),
                typeof(DateTimeOffset?), typeof(DateTimeOffset?), typeof(DateTimeOffset?),
                typeof(long?), typeof(long?), typeof(long?)
            });

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            Object[] expectedUtil = SupportDateTime.GetArrayCoerced(startTime, "util", "util", "util");
            Object[] expectedCal  = SupportDateTime.GetArrayCoerced(startTime, "cal", "cal", "cal");
            Object[] expectedMsec = SupportDateTime.GetArrayCoerced(startTime, "msec", "msec", "msec");
            Object[] expected     = EPAssertionUtil.ConcatenateArray(expectedUtil, expectedCal, expectedMsec);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, expected);

            _epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] {
                SupportDateTime.GetValueCoerced(startTime, "util"), null, null,
                SupportDateTime.GetValueCoerced(startTime, "cal"), null, null,
                SupportDateTime.GetValueCoerced(startTime, "msec"), null, null,
            });
        }
Beispiel #22
0
        private void RunAssertionPlusMinusTimePeriod(EPServiceProvider epService)
        {
            string startTime = "2002-05-30T09:00:00.000";

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeParser.ParseDefaultMSec(startTime)));

            string[] fields      = "val0,val1,val2,val3,val4,val5".Split(',');
            string   eplFragment = "select " +
                                   "current_timestamp.Plus(1 hour 10 sec 20 msec) as val0," +
                                   "utildate.Plus(1 hour 10 sec 20 msec) as val1," +
                                   "longdate.Plus(1 hour 10 sec 20 msec) as val2," +
                                   "current_timestamp.Minus(1 hour 10 sec 20 msec) as val3," +
                                   "utildate.Minus(1 hour 10 sec 20 msec) as val4," +
                                   "longdate.Minus(1 hour 10 sec 20 msec) as val5" +
                                   " from SupportDateTime";
            EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var         listener     = new SupportUpdateListener();

            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, fields, new Type[] {
                typeof(long?), typeof(DateTimeOffset?), typeof(long?),
                typeof(long?), typeof(DateTimeOffset?), typeof(long?)
            });

            epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime));
            object[] expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30T010:00:10.020", "long", "util", "long");
            object[] expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30T07:59:49.980", "long", "util", "long");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            epService.EPRuntime.SendEvent(SupportDateTime.Make(null));
            expectedPlus  = SupportDateTime.GetArrayCoerced("2002-05-30T010:00:10.020", "long", "null", "null");
            expectedMinus = SupportDateTime.GetArrayCoerced("2002-05-30T07:59:49.980", "long", "null", "null");
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

            stmtFragment.Dispose();
        }
Beispiel #23
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy("select current_timestamp.toDateTimeEx().AddDays(1) from SupportBean");

                var startTime = "2002-05-30T09:00:00.000";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

                string[] fields = {
                    "val1a", "val1b", "val1c", "val1d", "val1e",
                    "val2a", "val2b", "val2c", "val2d", "val2e",
                    "val3a", "val3b", "val3c", "val3d", "val3e",
                    "val4a", "val4b", "val4c", "val4d", "val4e",
                };

                var eplFragment =
                    "@Name('s0') select " +

                    "current_timestamp.toDateTime() as val1a," +
                    "LongDate.toDateTime() as val1b," +
                    "DateTimeEx.toDateTime() as val1c," +
                    "DateTimeOffset.toDateTime() as val1d," +
                    "DateTimeEx.toDateTime() as val1e," +

                    "current_timestamp.toDateTimeOffset() as val2a," +
                    "LongDate.toDateTimeOffset() as val2b," +
                    "DateTime.toDateTimeOffset() as val2c," +
                    "DateTimeOffset.toDateTimeOffset() as val2d," +
                    "DateTimeEx.toDateTimeOffset() as val2e," +

                    "current_timestamp.toDateTimeEx() as val3a," +
                    "LongDate.toDateTimeEx() as val3b," +
                    "DateTime.toDateTimeEx() as val3c," +
                    "DateTimeOffset.toDateTimeEx() as val3d," +
                    "DateTimeEx.toDateTimeEx() as val3e," +

                    "current_timestamp.toMillisec() as val4a," +
                    "LongDate.toMillisec() as val4b," +
                    "DateTime.toMillisec() as val4c," +
                    "DateTimeOffset.toMillisec() as val4d," +
                    "DateTimeEx.toMillisec() as val4e" +

                    " from SupportDateTime";

                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTime?),
                        typeof(DateTime?),
                        typeof(DateTime?),
                        typeof(DateTime?),
                        typeof(DateTime?),

                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),

                        typeof(DateTimeEx),
                        typeof(DateTimeEx),
                        typeof(DateTimeEx),
                        typeof(DateTimeEx),
                        typeof(DateTimeEx),

                        typeof(long?),
                        typeof(long?),
                        typeof(long?),
                        typeof(long?),
                        typeof(long?)
                    });

                env.SendEventBean(SupportDateTime.Make(startTime));

                var expected = EPAssertionUtil.ConcatenateArray(
                    SupportDateTime.GetArrayCoerced(startTime, "date".Repeat(5)),
                    SupportDateTime.GetArrayCoerced(startTime, "dto".Repeat(5)),
                    SupportDateTime.GetArrayCoerced(startTime, "dtx".Repeat(5)),
                    SupportDateTime.GetArrayCoerced(startTime, "long".Repeat(5)));

                EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, expected);

                env.SendEventBean(SupportDateTime.Make(null));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new[] {
                        SupportDateTime.GetValueCoerced(startTime, "date"), null, null, null, null,
                        SupportDateTime.GetValueCoerced(startTime, "dto"), null, null, null, null,
                        SupportDateTime.GetValueCoerced(startTime, "dtx"), null, null, null, null,
                        SupportDateTime.GetValueCoerced(startTime, "long"), null, null, null, null
                    });

                env.UndeployAll();
            }
Beispiel #24
0
        public void Run(RegressionEnvironment env)
        {
            var path = new RegressionPath();
            var epl = "@Name('variables') create variable int varhour;\n" +
                      "create variable int varmin;\n" +
                      "create variable int varsec;\n" +
                      "create variable int varmsec;\n";
            env.CompileDeploy(epl, path);
            var variablesDepId = env.DeploymentId("variables");

            var startTime = "2002-05-30T09:00:00.000";
            env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

            var fields = new [] { "val0","val1","val2","val3", "val4" };
            epl = "@Name('s0') select " +
                  "current_timestamp.withTime(varhour, varmin, varsec, varmsec) as val0," +
                  "LongDate.withTime(varhour, varmin, varsec, varmsec) as val1," +
                  "DateTime.withTime(varhour, varmin, varsec, varmsec) as val2," +
                  "DateTimeOffset.withTime(varhour, varmin, varsec, varmsec) as val3," +
                  "DateTimeEx.withTime(varhour, varmin, varsec, varmsec) as val4" +
                  " from SupportDateTime";
            env.CompileDeploy(epl, path).AddListener("s0");
            
            LambdaAssertionUtil.AssertTypes(
                env.Statement("s0").EventType,
                fields,
                new[] {
                    typeof(long?),
                    typeof(long?),
                    typeof(DateTime?),
                    typeof(DateTimeOffset?),
                    typeof(DateTimeEx)
                });

            env.SendEventBean(SupportDateTime.Make(null));

            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new[] {
                    SupportDateTime.GetValueCoerced(startTime, "long"),
                    null,
                    null,
                    null,
                    null
                });

            var expectedTime = "2002-05-30T09:00:00.000";
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varhour", null); // variable is null
            env.SendEventBean(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                SupportDateTime.GetArrayCoerced(expectedTime, "long", "long", "date", "dto", "dtx"));

            expectedTime = "2002-05-30T01:02:03.004";
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varhour", 1);
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varmin", 2);
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varsec", 3);
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varmsec", 4);
            env.SendEventBean(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                SupportDateTime.GetArrayCoerced(expectedTime, "long", "long", "date", "dto", "dtx"));

            expectedTime = "2002-05-30T00:00:00.006";
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varhour", 0);
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varmin", null);
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varsec", null);
            env.Runtime.VariableService.SetVariableValue(variablesDepId, "varmsec", 6);
            env.SendEventBean(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                SupportDateTime.GetArrayCoerced(expectedTime, "long", "long", "date", "dto", "dtx"));

            env.UndeployAll();
        }
Beispiel #25
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("@Name('var') create variable long varmsec", path);
                var startTime = "2002-05-30T09:00:00.000";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

                var fields = new[] {
                    "val1a", "val1b", "val1c", "val1d", "val1e",
                    "val2a", "val2b", "val2c", "val2d", "val2e",
                };
                var epl = "@Name('s0') select " +
                          
                          "current_timestamp.plus(varmsec) as val1a," +
                          "DateTimeEx.plus(varmsec) as val1b," +
                          "DateTimeOffset.plus(varmsec) as val1c," +
                          "DateTime.plus(varmsec) as val1d," +
                          "LongDate.plus(varmsec) as val1e," +

                          "current_timestamp.minus(varmsec) as val2a," +
                          "DateTimeEx.minus(varmsec) as val2b," +
                          "DateTimeOffset.minus(varmsec) as val2c," +
                          "DateTime.minus(varmsec) as val2d," +
                          "LongDate.minus(varmsec) as val2e" +

                          " from SupportDateTime";

                env.CompileDeploy(epl, path).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(long?), typeof(DateTimeEx), typeof(DateTimeOffset?), typeof(DateTime?), typeof(long?),
                        typeof(long?), typeof(DateTimeEx), typeof(DateTimeOffset?), typeof(DateTime?), typeof(long?)
                    });

                env.SendEventBean(SupportDateTime.Make(null));

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new[] {
                        SupportDateTime.GetValueCoerced(startTime, "long"), null, null, null, null,
                        SupportDateTime.GetValueCoerced(startTime, "long"), null, null, null, null,
                    });

                var expectedPlus = SupportDateTime.GetArrayCoerced(startTime, "long", "dtx", "dto", "date", "long");
                var expectedMinus = SupportDateTime.GetArrayCoerced(startTime, "long", "dtx", "dto", "date", "long");
                env.SendEventBean(SupportDateTime.Make(startTime));

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    EPAssertionUtil.ConcatenateArray(
                        expectedPlus,
                        expectedMinus));

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("var"), "varmsec", 1000);
                env.SendEventBean(SupportDateTime.Make(startTime));

                //System.out.println("==-> " + SupportDateTime.print(env.Listener("s0").assertOneGetNew().Get("val4")));
                expectedPlus = SupportDateTime.GetArrayCoerced(
                    "2002-05-30T09:00:01.000",
                    "long",
                    "dtx", 
                    "dto",
                    "date",
                    "long");
                expectedMinus = SupportDateTime.GetArrayCoerced(
                    "2002-05-30T08:59:59.000",
                    "long",
                    "dtx",
                    "dto",
                    "date",
                    "long");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    EPAssertionUtil.ConcatenateArray(
                        expectedPlus,
                        expectedMinus));

                env.Runtime.VariableService.SetVariableValue(
                    env.DeploymentId("var"),
                    "varmsec",
                    2 * 24 * 60 * 60 * 1000);
                env.SendEventBean(SupportDateTime.Make(startTime));
                expectedMinus = SupportDateTime.GetArrayCoerced(
                    "2002-05-28T09:00:00.000",
                    "long", 
                    "dtx",
                    "dto",
                    "date",
                    "long");
                expectedPlus = SupportDateTime.GetArrayCoerced(
                    "2002-06-1T09:00:00.000",
                    "long",
                    "dtx",
                    "dto",
                    "date",
                    "long");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    EPAssertionUtil.ConcatenateArray(
                        expectedPlus,
                        expectedMinus));

                env.UndeployAll();
            }
Beispiel #26
0
            public void Run(RegressionEnvironment env)
            {
                var startTime = "2002-05-30T09:00:00.000";
                env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

                var fields = new[] {
                    "val1a",
                    "val1b",
                    "val1c",
                    "val1d",
                    "val1e",

                    "val2a",
                    "val2b",
                    "val2c",
                    "val2d",
                    "val2e"
                };
                var eplFragment = "@Name('s0') select " +
                                  
                                  "current_timestamp.plus(1 hour 10 sec 20 msec) as val1a," +
                                  "DateTimeEx.plus(1 hour 10 sec 20 msec) as val1b," +
                                  "DateTimeOffset.plus(1 hour 10 sec 20 msec) as val1c," +
                                  "DateTime.plus(1 hour 10 sec 20 msec) as val1d," +
                                  "LongDate.plus(1 hour 10 sec 20 msec) as val1e," +

                                  "current_timestamp.minus(1 hour 10 sec 20 msec) as val2a," +
                                  "DateTimeEx.minus(1 hour 10 sec 20 msec) as val2b," +
                                  "DateTimeOffset.minus(1 hour 10 sec 20 msec) as val2c," +
                                  "DateTime.minus(1 hour 10 sec 20 msec) as val2d," +
                                  "LongDate.minus(1 hour 10 sec 20 msec) as val2e" +

                                  " from SupportDateTime";

                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(long?), typeof(DateTimeEx), typeof(DateTimeOffset?), typeof(DateTime?), typeof(long?),
                        typeof(long?), typeof(DateTimeEx), typeof(DateTimeOffset?), typeof(DateTime?), typeof(long?)
                    });

                env.SendEventBean(SupportDateTime.Make(startTime));
                var expectedPlus = SupportDateTime.GetArrayCoerced(
                    "2002-05-30T10:00:10.020",
                    "long",
                    "dtx",
                    "dto",
                    "date",
                    "long");
                var expectedMinus = SupportDateTime.GetArrayCoerced(
                    "2002-05-30T07:59:49.980",
                    "long",
                    "dtx",
                    "dto",
                    "date",
                    "long");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

                env.SendEventBean(SupportDateTime.Make(null));
                expectedPlus = SupportDateTime.GetArrayCoerced(
                    "2002-05-30T10:00:10.020",
                    "long",
                    "null",
                    "null",
                    "null",
                    "null");
                expectedMinus = SupportDateTime.GetArrayCoerced(
                    "2002-05-30T07:59:49.980",
                    "long",
                    "null",
                    "null",
                    "null",
                    "null");

                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    EPAssertionUtil.ConcatenateArray(expectedPlus, expectedMinus));

                env.UndeployAll();
            }
Beispiel #27
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new [] { "val0","val1","val2","val3","val4","val5","val6" };
                var eplFragment = "@Name('s0') select " +
                                  "DateTimeOffset.roundHalf('msec') as val0," +
                                  "DateTimeOffset.roundHalf('sec') as val1," +
                                  "DateTimeOffset.roundHalf('minutes') as val2," +
                                  "DateTimeOffset.roundHalf('hour') as val3," +
                                  "DateTimeOffset.roundHalf('day') as val4," +
                                  "DateTimeOffset.roundHalf('month') as val5," +
                                  "DateTimeOffset.roundHalf('year') as val6" +
                                  " from SupportDateTime";
                env.CompileDeploy(eplFragment).AddListener("s0");
                LambdaAssertionUtil.AssertTypes(
                    env.Statement("s0").EventType,
                    fields,
                    new[] {
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?),
                        typeof(DateTimeOffset?)
                    });

                string[] expected = {
                    "2002-05-30T15:30:02.550",
                    "2002-05-30T15:30:03.000",
                    "2002-05-30T15:30:00.000",
                    "2002-05-30T16:00:00.00",
                    "2002-05-31T00:00:00.000",
                    "2002-06-01T00:00:00.000",
                    "2002-01-01T00:00:00.000"
                };
                var startTime = "2002-05-30T15:30:02.550";
                env.SendEventBean(SupportDateTime.Make(startTime));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    SupportDateTime.GetArrayCoerced(expected, "dto"));

                // test rounding up/down
                env.UndeployAll();
                fields = new [] { "val0" };
                eplFragment = "@Name('s0') select DateTimeOffset.roundHalf('min') as val0 from SupportDateTime";
                env.CompileDeployAddListenerMile(eplFragment, "s0", 1);

                env.SendEventBean(SupportDateTime.Make("2002-05-30T15:30:29.999"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new[] {SupportDateTime.GetValueCoerced("2002-05-30T15:30:00.000", "dto")});

                env.SendEventBean(SupportDateTime.Make("2002-05-30T15:30:30.000"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new[] {SupportDateTime.GetValueCoerced("2002-05-30T15:31:00.000", "dto")});

                env.SendEventBean(SupportDateTime.Make("2002-05-30T15:30:30.001"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new[] {SupportDateTime.GetValueCoerced("2002-05-30T15:31:00.000", "dto")});

                env.UndeployAll();
            }
Beispiel #28
0
        public void Run(RegressionEnvironment env)
        {
            var startTime = "2002-05-30T09:00:00.000";
            env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSec(startTime));

            var fields = new [] { "val0","val1","val2","val3", "val4" };
            var epl = "" +
                      "create variable int varyear;\n" +
                      "create variable int varmonth;\n" +
                      "create variable int varday;\n" +
                      "@Name('s0') select " +
                      "current_timestamp.withDate(varyear, varmonth, varday) as val0," +
                      "LongDate.withDate(varyear, varmonth, varday) as val1," +
                      "DateTimeEx.withDate(varyear, varmonth, varday) as val2," + 
                      "DateTimeOffset.withDate(varyear, varmonth, varday) as val3," +
                      "DateTime.withDate(varyear, varmonth, varday) as val4" +
                      " from SupportDateTime";
            env.CompileDeploy(epl).AddListener("s0");
            var deployId = env.DeploymentId("s0");
            LambdaAssertionUtil.AssertTypes(
                env.Statement("s0").EventType,
                fields,
                new[] {
                    typeof(long?),
                    typeof(long?),
                    typeof(DateTimeEx),
                    typeof(DateTimeOffset?),
                    typeof(DateTime?),
                });

            env.SendEventBean(SupportDateTime.Make(null));

            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new[] {
                    SupportDateTime.GetValueCoerced(startTime, "long"),
                    null,
                    null,
                    null,
                    null
                });

            var expectedTime = "2004-09-03T09:00:00.000";
            env.Runtime.VariableService.SetVariableValue(deployId, "varyear", 2004);
            env.Runtime.VariableService.SetVariableValue(deployId, "varmonth", 9);
            env.Runtime.VariableService.SetVariableValue(deployId, "varday", 3);
            env.SendEventBean(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                SupportDateTime.GetArrayCoerced(expectedTime, "long", "long", "dtx", "dto", "date"));

            expectedTime = "2002-09-30T09:00:00.000";
            env.Runtime.VariableService.SetVariableValue(deployId, "varyear", null);
            env.Runtime.VariableService.SetVariableValue(deployId, "varmonth", 9);
            env.Runtime.VariableService.SetVariableValue(deployId, "varday", null);
            env.SendEventBean(SupportDateTime.Make(startTime));
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                SupportDateTime.GetArrayCoerced(expectedTime, "long", "long", "dtx", "dto", "date"));

            env.UndeployAll();
        }