public void TestMixed()
        {
            _index.Remove(new[] {_testEvents[1]});
            ICollection<EventBean> result = _index.Lookup(new Object[] {1, "b"});
            Assert.AreEqual(1, result.Count);
            Assert.IsTrue(result.Contains(_testEvents[4]));

            // iterate
            Object[] underlying = ArrayAssertionUtil.EnumeratorToArrayUnderlying(_index.GetEnumerator());
            EPAssertionUtil.AssertEqualsAnyOrder(
                new[] {_testEventsUnd[0], _testEventsUnd[2], _testEventsUnd[3], _testEventsUnd[4], _testEventsUnd[5]},
                underlying);

            _index.Remove(new[] {_testEvents[4]});
            result = _index.Lookup(new Object[] {1, "b"});
            Assert.IsNull(result);

            // iterate
            underlying = ArrayAssertionUtil.EnumeratorToArrayUnderlying(_index.GetEnumerator());
            EPAssertionUtil.AssertEqualsAnyOrder(
                new[] {_testEventsUnd[0], _testEventsUnd[2], _testEventsUnd[3], _testEventsUnd[5]}, underlying);

            _index.Add(new[] {_testEvents[1]});
            result = _index.Lookup(new Object[] {1, "b"});
            Assert.AreEqual(1, result.Count);
            Assert.IsTrue(result.Contains(_testEvents[1]));

            // iterate
            underlying = ArrayAssertionUtil.EnumeratorToArrayUnderlying(_index.GetEnumerator());
            EPAssertionUtil.AssertEqualsAnyOrder(
                new[] {_testEventsUnd[0], _testEventsUnd[1], _testEventsUnd[2], _testEventsUnd[3], _testEventsUnd[5]},
                underlying);
        }
예제 #2
0
        public void TestToMap()
        {
            // - duplicate value allowed, latest value wins
            // - null key & value allowed

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

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

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,5"));
            ArrayAssertionUtil.AssertPropsMap(ToDataMap(_listener.AssertOneGetNewAndReset().Get("val")), "E1,E2,E3".Split(','), new Object[] { 1, 5, 12 });

            _epService.EPRuntime.SendEvent(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,12", "E1,2"));
            ArrayAssertionUtil.AssertPropsMap(ToDataMap(_listener.AssertOneGetNewAndReset().Get("val")), "E1,E2,E3".Split(','), new Object[] { 2, 12, 12 });

            _epService.EPRuntime.SendEvent(new SupportBean_ST0_Container(new SupportBean_ST0[] { new SupportBean_ST0(null, null) }));
            ArrayAssertionUtil.AssertPropsMap(ToDataMap(_listener.AssertOneGetNewAndReset().Get("val")), "E1,E2,E3".Split(','), new Object[] { null, null, null });

            stmtFragment.Dispose();

            // test scalar-coll with lambda
            String[] fields = "val0".SplitCsv();
            _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("extractNum", typeof(TestEnumMinMax.MyService).FullName, "ExtractNum");
            String      eplLambda  = "select Strvals.toMap(c => c, c => extractNum(c)) as val0 from SupportCollection";
            EPStatement stmtLambda = _epService.EPAdministrator.CreateEPL(eplLambda);

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

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString("E2,E1,E3"));
            EPAssertionUtil.AssertPropsMap((AnyMap)_listener.AssertOneGetNewAndReset().Get("val0"), "E1,E2,E3".SplitCsv(), new Object[] { 1, 2, 3 });

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString("E1"));
            EPAssertionUtil.AssertPropsMap((AnyMap)_listener.AssertOneGetNewAndReset().Get("val0"), "E1".SplitCsv(), new Object[] { 1 });

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

            _epService.EPRuntime.SendEvent(SupportCollection.MakeString(""));
            Assert.AreEqual(0, ((AnyMap)_listener.AssertOneGetNewAndReset().Get("val0")).Count);
        }
예제 #3
0
        public void TestOrderByWildcard()
        {
            String stmtText = "select * from " + typeof(SupportMarketDataBean).FullName +
                              "#length(5) order by Symbol, Volume";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            Assert.IsFalse(stmt.HasFirst());

            Object eventOne = SendEvent("SYM", 1);

            ArrayAssertionUtil.AreEqualExactOrderUnderlying(stmt.GetEnumerator(), new[] { eventOne });

            Object eventTwo = SendEvent("OCC", 2);

            ArrayAssertionUtil.AreEqualExactOrderUnderlying(stmt.GetEnumerator(), new[] { eventTwo, eventOne });

            Object eventThree = SendEvent("TOC", 3);

            ArrayAssertionUtil.AreEqualExactOrderUnderlying(stmt.GetEnumerator(),
                                                            new[] { eventTwo, eventOne, eventThree });

            Object eventFour = SendEvent("SYM", 0);

            ArrayAssertionUtil.AreEqualExactOrderUnderlying(stmt.GetEnumerator(),
                                                            new[] { eventTwo, eventFour, eventOne, eventThree });

            Object eventFive = SendEvent("SYM", 10);

            ArrayAssertionUtil.AreEqualExactOrderUnderlying(stmt.GetEnumerator(),
                                                            new[]
                                                            { eventTwo, eventFour, eventOne, eventFive, eventThree });

            Object eventSix = SendEvent("SYM", 4);

            ArrayAssertionUtil.AreEqualExactOrderUnderlying(stmt.GetEnumerator(),
                                                            new[]
                                                            { eventTwo, eventFour, eventSix, eventFive, eventThree });
        }
 public void TestEnumerator()
 {
     Object[] underlying = ArrayAssertionUtil.EnumeratorToArrayUnderlying(_index.GetEnumerator());
     EPAssertionUtil.AssertEqualsAnyOrder(_testEventsUnd, underlying);
 }
예제 #5
0
        public void TestFlowReportActive()
        {
            var rep = new StatementMetricArray("uri", "name", 3, false);

            Assert.AreEqual(0, rep.SizeLastElement);

            Assert.AreEqual(0, rep.AddStatementGetIndex("001"));
            Assert.AreEqual(1, rep.SizeLastElement);

            Assert.AreEqual(1, rep.AddStatementGetIndex("002"));
            Assert.AreEqual(2, rep.AddStatementGetIndex("003"));
            Assert.AreEqual(3, rep.SizeLastElement);

            rep.RemoveStatement("002");

            Assert.AreEqual(3, rep.AddStatementGetIndex("004"));
            Assert.AreEqual(4, rep.AddStatementGetIndex("005"));

            rep.RemoveStatement("005");
            Assert.AreEqual(5, rep.AddStatementGetIndex("006"));

            var metrics = new StatementMetric[6];

            for (int i = 0; i < 6; i++)
            {
                metrics[i] = rep.GetAddMetric(i);
            }

            StatementMetric[] flushed = rep.FlushMetrics();
            ArrayAssertionUtil.AssertSameExactOrder(metrics, flushed);

            Assert.AreEqual(1, rep.AddStatementGetIndex("007"));
            Assert.AreEqual(4, rep.AddStatementGetIndex("008"));

            rep.RemoveStatement("001");
            rep.RemoveStatement("003");
            rep.RemoveStatement("004");
            rep.RemoveStatement("006");
            rep.RemoveStatement("007");
            Assert.AreEqual(6, rep.SizeLastElement);
            rep.RemoveStatement("008");
            Assert.AreEqual(6, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.AreEqual(6, flushed.Length);
            Assert.AreEqual(0, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.IsNull(flushed);
            Assert.AreEqual(0, rep.SizeLastElement);

            Assert.AreEqual(0, rep.AddStatementGetIndex("009"));
            Assert.AreEqual(1, rep.SizeLastElement);

            flushed = rep.FlushMetrics();
            Assert.AreEqual(6, flushed.Length);
            for (int i = 0; i < flushed.Length; i++)
            {
                Assert.IsNull(flushed[i]);
            }
            Assert.AreEqual(1, rep.SizeLastElement);
        }