public void TestMakeSubviews() { EventStream eventStream = new SupportStreamImpl(typeof(SupportMarketDataBean), 4); var expressions = SupportExprNodeFactory.MakeIdentNodesMD("Symbol"); GroupByView groupView = new GroupByViewImpl(_agentInstanceContext, expressions, ExprNodeUtility.GetEvaluators(expressions)); eventStream.AddView(groupView); var groupByValue = new Object[] { "IBM" }; // Invalid for no child nodes try { GroupByViewImpl.MakeSubViews(groupView, "Symbol".Split(','), groupByValue, _agentInstanceContext); Assert.IsTrue(false); } catch (EPException) { // Expected exception } // Invalid for child node is a merge node - doesn't make sense to group and merge only var mergeViewOne = new MergeView(_agentInstanceContext, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), null, false); groupView.AddView(mergeViewOne); try { GroupByViewImpl.MakeSubViews(groupView, "Symbol".Split(','), groupByValue, _agentInstanceContext); Assert.IsTrue(false); } catch (EPException) { // Expected exception } // Add a size view parent of merge view groupView = new GroupByViewImpl(_agentInstanceContext, expressions, ExprNodeUtility.GetEvaluators(expressions)); var firstElementView_1 = new FirstElementView(null); groupView.AddView(firstElementView_1); groupView.Parent = eventStream; mergeViewOne = new MergeView(_agentInstanceContext, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), null, false); firstElementView_1.AddView(mergeViewOne); var subViews = GroupByViewImpl.MakeSubViews(groupView, "Symbol".Split(','), groupByValue, _agentInstanceContext); Assert.IsTrue(subViews is FirstElementView); Assert.IsTrue(subViews != firstElementView_1); var firstEleView = (FirstElementView)subViews; Assert.AreEqual(1, firstEleView.Views.Length); Assert.IsTrue(firstEleView.Views[0] is AddPropertyValueView); var md = (AddPropertyValueView)firstEleView.Views[0]; Assert.AreEqual(1, md.Views.Length); Assert.IsTrue(md.Views[0] == mergeViewOne); }
public void SetUp() { // Set up length window view and a test child view ExprNode[] expressions = SupportExprNodeFactory.MakeIdentNodesMD("Volume"); _myView = new SortWindowView(new SortWindowViewFactory(), expressions, ExprNodeUtility.GetEvaluators(expressions), new bool[] { false }, 5, null, false, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
public void TestViewTwoProperties() { // Set up a sort windows that sorts on two properties ExprNode[] expressions = SupportExprNodeFactory.MakeIdentNodesMD("Volume", "Price"); _myView = new SortWindowView(new SortWindowViewFactory(), expressions, ExprNodeUtility.GetEvaluators(expressions), new bool[] { false, true }, 5, null, false, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); // Set up a feed for the view under test - the depth is 10 events so bean[10] will cause bean[0] to go old SupportStreamImpl stream = new SupportStreamImpl(typeof(SupportMarketDataBean), 10); stream.AddView(_myView); EventBean[] bean = new EventBean[12]; bean[0] = MakeBean(20d, 1000); stream.Insert(bean[0]); SupportViewDataChecker.CheckOldData(_childView, null); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { bean[0] }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { bean[0] }, _myView.GetEnumerator()); bean[1] = MakeBean(19d, 800); bean[2] = MakeBean(18d, 1200); stream.Insert(new EventBean[] { bean[1], bean[2] }); SupportViewDataChecker.CheckOldData(_childView, null); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { bean[1], bean[2] }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { bean[1], bean[0], bean[2] }, _myView.GetEnumerator()); bean[3] = MakeBean(17d, 1200); bean[4] = MakeBean(16d, 1000); bean[5] = MakeBean(15d, 1400); bean[6] = MakeBean(14d, 1100); stream.Insert(new EventBean[] { bean[3], bean[4], bean[5], bean[6] }); SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { bean[5], bean[3] }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { bean[3], bean[4], bean[5], bean[6] }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { bean[1], bean[0], bean[4], bean[6], bean[2] }, _myView.GetEnumerator()); bean[7] = MakeBean(13d, 800); bean[8] = MakeBean(12d, 700); bean[9] = MakeBean(11d, 1200); stream.Insert(new EventBean[] { bean[7], bean[8], bean[9] }); SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { bean[9], bean[2], bean[6] }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { bean[7], bean[8], bean[9] }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { bean[8], bean[1], bean[7], bean[0], bean[4] }, _myView.GetEnumerator()); bean[10] = MakeBean(10d, 1050); stream.Insert(new EventBean[] { bean[10] }); // Thus bean[0] will be old data ! SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { bean[0] }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { bean[10] }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { bean[8], bean[1], bean[7], bean[4], bean[10] }, _myView.GetEnumerator()); bean[11] = MakeBean(2000); stream.Insert(new EventBean[] { bean[11] }); // Thus bean[1] will be old data ! SupportViewDataChecker.CheckOldData(_childView, new EventBean[] { bean[1] }); SupportViewDataChecker.CheckNewData(_childView, new EventBean[] { bean[11] }); EPAssertionUtil.AssertEqualsExactOrder(new EventBean[] { bean[8], bean[7], bean[4], bean[10], bean[11] }, _myView.GetEnumerator()); }
public void SetUp() { // Set up length window view and a test child view _myView = new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(), SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)), false); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
public void SetUp() { // Set up length window view and a test child view UniqueByPropertyViewFactory factory = new UniqueByPropertyViewFactory(); factory.CriteriaExpressions = SupportExprNodeFactory.MakeIdentNodesMD("Symbol"); _myView = new UniqueByPropertyView(factory, null); _childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); _myView.AddView(_childView); }
public void TestCanReuse() { StatementContext context = SupportStatementContextFactory.MakeContext(); _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { 100, "Price" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null))); Assert.IsTrue(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price"), new ExprEvaluator[0], new bool[] { false }, 100, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Volume"), new ExprEvaluator[0], new bool[] { true }, 100, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price"), new ExprEvaluator[0], new bool[] { false }, 99, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), new ExprEvaluator[0], new bool[] { false }, 100, null, false, null))); _factory.SetViewParameters(null, TestViewSupport.ToExprListMD(new Object[] { 100, "Price", "Volume" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(), null, null); Assert.IsTrue(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price", "Volume"), new ExprEvaluator[0], new bool[] { false, false }, 100, null, false, null))); Assert.IsFalse(_factory.CanReuse(new SortWindowView(_factory, SupportExprNodeFactory.MakeIdentNodesMD("Price", "Symbol"), new ExprEvaluator[0], new bool[] { true, false }, 100, null, false, null))); }
public void SetUp() { _statementContext = SupportStatementContextFactory.MakeContext(); _agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(); var expressions = SupportExprNodeFactory.MakeIdentNodesMD("Symbol"); _myGroupByView = new GroupByViewImpl(_agentInstanceContext, expressions, ExprNodeUtility.GetEvaluators(expressions)); var childView = new SupportBeanClassView(typeof(SupportMarketDataBean)); var myMergeView = new MergeView(_agentInstanceContext, SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), false); _ultimateChildView = new SupportBeanClassView(typeof(SupportMarketDataBean)); // This is the view hierarchy _myGroupByView.AddView(childView); childView.AddView(myMergeView); myMergeView.AddView(_ultimateChildView); SupportBeanClassView.Instances.Clear(); }
public void TestCanReuse() { AgentInstanceContext agentInstanceContext = SupportStatementContextFactory.MakeAgentInstanceContext(_container); _factory.SetViewParameters(_viewFactoryContext, TestViewSupport.ToExprListMD(new Object[] { "Symbol", "Feed" })); _factory.Attach(SupportEventTypeFactory.CreateBeanType(typeof(SupportMarketDataBean)), SupportStatementContextFactory.MakeContext(_container), null, _parents); Assert.IsFalse(_factory.CanReuse(new FirstElementView(null), agentInstanceContext)); Assert.IsFalse(_factory.CanReuse(new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesMD("Symbol"), null, true), agentInstanceContext)); Assert.IsTrue(_factory.CanReuse(new MergeView(SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(_container), SupportExprNodeFactory.MakeIdentNodesMD("Symbol", "Feed"), null, true), agentInstanceContext)); }