Beispiel #1
0
        private void RunAssertionKeySelectorOnly(EPServiceProvider epService)
        {
            // - duplicate key allowed, creates a list of values
            // - null key & value allowed

            var eplFragment = "select Contained.GroupBy(c => id) as val from Bean";
            var stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment);
            var listener = new SupportUpdateListener();
            stmtFragment.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, "val".Split(','), new[] {
                typeof(IDictionary<object, ICollection<object>>)
            });
            var extractorEvents = new EPAssertionUtil.ProxyAssertionCollectionValueString
            {
                ProcExtractValue = collectionItem =>
                {
                    var p00 = ((SupportBean_ST0) collectionItem).P00;
                    return Convert.ToString(p00);
                }
            };

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E1,2", "E2,5"));
            EPAssertionUtil.AssertMapOfCollection(
                (IDictionary<object, ICollection<object>>) listener.AssertOneGetNewAndReset().Get("val"),
                "E1,E2".Split(','), new[] {"1,2", "5"},
                extractorEvents);

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val"));

            epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            Assert.AreEqual(0, listener.AssertOneGetNewAndReset().Get("val").UnwrapEnumerable<object>().Count());
            stmtFragment.Dispose();

            // test scalar
            var eplScalar = "select Strvals.GroupBy(c => extractAfterUnderscore(c)) as val from SupportCollection";
            var stmtScalar = epService.EPAdministrator.CreateEPL(eplScalar);
            stmtScalar.Events += listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtScalar.EventType, "val".Split(','), new[] {
                typeof(IDictionary<object, ICollection<object>>)
            });

            epService.EPRuntime.SendEvent(SupportCollection.MakeString("E1_2,E2_1,E3_2"));
            EPAssertionUtil.AssertMapOfCollection(
                listener.AssertOneGetNewAndReset().Get("val").UnwrapStringDictionary(),
                "2,1".Split(','),
                new[] {"E1_2,E3_2", "E2_1"}, GetExtractorScalar());

            epService.EPRuntime.SendEvent(SupportCollection.MakeString(null));
            Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val"));

            epService.EPRuntime.SendEvent(SupportCollection.MakeString(""));
            Assert.AreEqual(0, listener.AssertOneGetNewAndReset().Get("val").Unwrap<object>().Count);

            stmtScalar.Dispose();
        }
Beispiel #2
0
        private static void CompareMaps(
            object val,
            string keyCSV,
            string[] values,
            EPAssertionUtil.AssertionCollectionValueString extractorEvents)
        {
            var keys       = string.IsNullOrWhiteSpace(keyCSV) ? new string[0] : keyCSV.SplitCsv();
            var dictionary = val.UnwrapDictionary();

            EPAssertionUtil.AssertMapOfCollection(dictionary, keys, values, extractorEvents);
        }
Beispiel #3
0
        public void TestKeySelectorOnly()
        {
            // - duplicate key allowed, creates a list of values
            // - null key & value allowed

            String      eplFragment  = "select contained.GroupBy(c => id) as val from Bean";
            EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment);

            stmtFragment.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtFragment.EventType, "val".Split(','), new Type[] { typeof(GroupMap) });
            EPAssertionUtil.AssertionCollectionValueString extractorEvents = new EPAssertionUtil.ProxyAssertionCollectionValueString(
                collectionItem =>
            {
                int p00 = ((SupportBean_ST0)collectionItem).P00;
                return(Convert.ToString(p00));
            });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E1,2", "E2,5"));
            EPAssertionUtil.AssertMapOfCollection(
                (GroupMap)_listener.AssertOneGetNewAndReset().Get("val"),
                new string[] { "E1", "E2" },
                new string[] { "1,2", "5" },
                extractorEvents);

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value(null));
            Assert.IsNull(_listener.AssertOneGetNewAndReset().Get("val"));

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value());
            Assert.AreEqual(0, ((GroupMap)_listener.AssertOneGetNewAndReset().Get("val")).Count);
            stmtFragment.Dispose();

            // test scalar
            _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("extractAfterUnderscore", this.GetType().FullName, "ExtractAfterUnderscore");
            String      eplScalar  = "select Strvals.GroupBy(c => extractAfterUnderscore(c)) as val from SupportCollection";
            EPStatement stmtScalar = _epService.EPAdministrator.CreateEPL(eplScalar);

            stmtScalar.Events += _listener.Update;
            LambdaAssertionUtil.AssertTypes(stmtScalar.EventType, "val".Split(','), new Type[] { typeof(GroupMap) });

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString("E1_2,E2_1,E3_2"));
            EPAssertionUtil.AssertMapOfCollection((GroupMap)_listener.AssertOneGetNewAndReset().Get("val"), "2,1".Split(','),
                                                  new String[] { "E1_2,E3_2", "E2_1" }, GetExtractorScalar());

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString(null));
            Assert.IsNull(_listener.AssertOneGetNewAndReset().Get("val"));

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString(""));
            Assert.AreEqual(0, ((GroupMap)_listener.AssertOneGetNewAndReset().Get("val")).Count);
        }