private void TryAssertionMapTranspose(EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum) { var innerTypeOne = new Dictionary <string, object>(); innerTypeOne.Put("i1", typeof(int)); var innerTypeTwo = new Dictionary <string, object>(); innerTypeTwo.Put("i2", typeof(int)); var outerType = new Dictionary <string, object>(); outerType.Put("one", "T1"); outerType.Put("two", "T2"); epService.EPAdministrator.Configuration.AddEventType("T1", innerTypeOne); epService.EPAdministrator.Configuration.AddEventType("T2", innerTypeTwo); epService.EPAdministrator.Configuration.AddEventType("OuterType", outerType); // create window string stmtTextCreate = eventRepresentationEnum.GetAnnotationText() + " create window MyWindowMT#keepall as select one, two from OuterType"; EPStatement stmtCreate = epService.EPAdministrator.CreateEPL(stmtTextCreate); Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtCreate.EventType.UnderlyingType)); var listenerWindow = new SupportUpdateListener(); stmtCreate.Events += listenerWindow.Update; EPAssertionUtil.AssertEqualsAnyOrder(stmtCreate.EventType.PropertyNames, new string[] { "one", "two" }); EventType eventType = stmtCreate.EventType; Assert.AreEqual("T1", eventType.GetFragmentType("one").FragmentType.Name); Assert.AreEqual("T2", eventType.GetFragmentType("two").FragmentType.Name); // create insert into string stmtTextInsertOne = "insert into MyWindowMT select one, two from OuterType"; epService.EPAdministrator.CreateEPL(stmtTextInsertOne); var innerDataOne = new Dictionary <string, object>(); innerDataOne.Put("i1", 1); var innerDataTwo = new Dictionary <string, object>(); innerDataTwo.Put("i2", 2); var outerData = new Dictionary <string, object>(); outerData.Put("one", innerDataOne); outerData.Put("two", innerDataTwo); epService.EPRuntime.SendEvent(outerData, "OuterType"); EPAssertionUtil.AssertProps(listenerWindow.AssertOneGetNewAndReset(), "one.i1,two.i2".Split(','), new object[] { 1, 2 }); epService.EPAdministrator.DestroyAllStatements(); epService.EPAdministrator.Configuration.RemoveEventType("MyWindowMT", true); }
public void Run(RegressionEnvironment env) { var stmtTxtOne = "@Name('s0') select * from pattern [[2] a=SupportBean_A -> b=SupportBean_B]"; env.CompileDeploy(stmtTxtOne).AddListener("s0"); EPAssertionUtil.AssertEqualsAnyOrder( new EventPropertyDescriptor[] { new EventPropertyDescriptor( "a", typeof(SupportBean_A[]), typeof(SupportBean_A), false, false, true, false, true), new EventPropertyDescriptor("b", typeof(SupportBean_B), null, false, false, false, false, true) }, env.Statement("s0").EventType.PropertyDescriptors); env.SendEventBean(new SupportBean_A("A1")); env.SendEventBean(new SupportBean_A("A2")); env.SendEventBean(new SupportBean_B("B1")); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.That(theEvent.Underlying, Is.InstanceOf<IDictionary<string, object>>()); // test fragment B type and event var typeFragB = theEvent.EventType.GetFragmentType("b"); Assert.IsFalse(typeFragB.IsIndexed); Assert.AreEqual("SupportBean_B", typeFragB.FragmentType.Name); Assert.AreEqual(typeof(string), typeFragB.FragmentType.GetPropertyType("Id")); var eventFragB = (EventBean) theEvent.GetFragment("b"); Assert.AreEqual("SupportBean_B", eventFragB.EventType.Name); // test fragment A type and event var typeFragA = theEvent.EventType.GetFragmentType("a"); Assert.IsTrue(typeFragA.IsIndexed); Assert.AreEqual("SupportBean_A", typeFragA.FragmentType.Name); Assert.AreEqual(typeof(string), typeFragA.FragmentType.GetPropertyType("Id")); Assert.IsTrue(theEvent.GetFragment("a") is EventBean[]); var eventFragA1 = (EventBean) theEvent.GetFragment("a[0]"); Assert.AreEqual("SupportBean_A", eventFragA1.EventType.Name); Assert.AreEqual("A1", eventFragA1.Get("Id")); var eventFragA2 = (EventBean) theEvent.GetFragment("a[1]"); Assert.AreEqual("SupportBean_A", eventFragA2.EventType.Name); Assert.AreEqual("A2", eventFragA2.Get("Id")); env.UndeployAll(); }
public void TestContextPartitionSelection() { var fields = "c0,c1,c2,c3".Split(','); _epService.EPAdministrator.CreateEPL("create context MyCtx as group by IntPrimitive < -5 as grp1, group by IntPrimitive between -5 and +5 as grp2, group by IntPrimitive > 5 as grp3 from SupportBean"); var stmt = _epService.EPAdministrator.CreateEPL("context MyCtx select context.id as c0, context.label as c1, TheString as c2, Sum(IntPrimitive) as c3 from SupportBean#keepall group by TheString"); _epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); _epService.EPRuntime.SendEvent(new SupportBean("E2", -5)); _epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); _epService.EPRuntime.SendEvent(new SupportBean("E3", -100)); _epService.EPRuntime.SendEvent(new SupportBean("E3", -8)); _epService.EPRuntime.SendEvent(new SupportBean("E1", 60)); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), stmt.GetSafeEnumerator(), fields, new Object[][] { new Object[] { 0, "grp1", "E3", -108 }, new Object[] { 1, "grp2", "E1", 3 }, new Object[] { 1, "grp2", "E2", -5 }, new Object[] { 2, "grp3", "E1", 60 } }); // test iterator targeted by context partition id var selectorById = new SupportSelectorById(Collections.SingletonList(1)); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(selectorById), stmt.GetSafeEnumerator(selectorById), fields, new Object[][] { new Object[] { 1, "grp2", "E1", 3 }, new Object[] { 1, "grp2", "E2", -5 } }); // test iterator targeted for a given category var selector = new SupportSelectorCategory(new HashSet <String> { "grp1", "grp3" }); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(selector), stmt.GetSafeEnumerator(selector), fields, new Object[][] { new Object[] { 0, "grp1", "E3", -108 }, new Object[] { 2, "grp3", "E1", 60 } }); // test iterator targeted for a given filtered category var filtered = new MySelectorFilteredCategory("grp1"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(filtered), stmt.GetSafeEnumerator(filtered), fields, new Object[][] { new Object[] { 0, "grp1", "E3", -108 } }); Assert.IsFalse(stmt.GetEnumerator(new SupportSelectorCategory((ICollection <String>)null)).MoveNext()); Assert.IsFalse(stmt.GetEnumerator(new SupportSelectorCategory(Collections.GetEmptySet <String>())).MoveNext()); // test always-false filter - compare context partition INFO filtered = new MySelectorFilteredCategory(null); Assert.IsFalse(stmt.GetEnumerator(filtered).MoveNext()); EPAssertionUtil.AssertEqualsAnyOrder(new Object[] { "grp1", "grp2", "grp3" }, filtered.Categories); try { stmt.GetEnumerator(new ProxyContextPartitionSelectorSegmented { ProcPartitionKeys = () => null }); Assert.Fail(); } catch (InvalidContextPartitionSelector ex) { Assert.IsTrue(ex.Message.StartsWith("Invalid context partition selector, expected an implementation class of any of [ContextPartitionSelectorAll, ContextPartitionSelectorFiltered, ContextPartitionSelectorById, ContextPartitionSelectorCategory] interfaces but received com."), "message: " + ex.Message); } }
public void TestSuperTypesInterfaces() { _epService.EPAdministrator.Configuration.AddEventType("SupportBeanVariantOne", typeof(SupportBeanVariantOne)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanVariantTwo", typeof(SupportBeanVariantTwo)); ConfigurationVariantStream variant = new ConfigurationVariantStream(); variant.AddEventTypeName("SupportBeanVariantOne"); variant.AddEventTypeName("SupportBeanVariantTwo"); _epService.EPAdministrator.Configuration.AddVariantStream("MyVariantStream", variant); _epService.EPAdministrator.CreateEPL("insert into MyVariantStream select * from SupportBeanVariantOne"); _epService.EPAdministrator.CreateEPL("insert into MyVariantStream select * from SupportBeanVariantTwo"); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from MyVariantStream"); stmt.Events += _listenerOne.Update; EventType eventType = stmt.EventType; var expected = "P0,P1,P2,P3,P4,P5,Indexed,Mapped,Inneritem".Split(','); var propertyNames = eventType.PropertyNames; EPAssertionUtil.AssertEqualsAnyOrder(expected, propertyNames); Assert.AreEqual(typeof(ISupportBaseAB), eventType.GetPropertyType("P0")); Assert.AreEqual(typeof(ISupportAImplSuperG), eventType.GetPropertyType("P1")); Assert.AreEqual(typeof(object), eventType.GetPropertyType("P2")); Assert.AreEqual(typeof(IList <object>), eventType.GetPropertyType("P3")); Assert.AreEqual(typeof(ICollection <object>), eventType.GetPropertyType("P4")); Assert.AreEqual(typeof(ICollection <object>), eventType.GetPropertyType("P5")); Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("Indexed")); Assert.AreEqual(typeof(IDictionary <string, string>), eventType.GetPropertyType("Mapped")); Assert.AreEqual(typeof(SupportBeanVariantOne.SupportBeanVariantOneInner), eventType.GetPropertyType("Inneritem")); stmt.Dispose(); stmt = _epService.EPAdministrator.CreateEPL("select P0,P1,P2,P3,P4,P5,Indexed[0] as P6,indexArr[1] as P7,mappedKey('a') as P8,Inneritem as P9,Inneritem.val as P10 from MyVariantStream"); stmt.Events += _listenerOne.Update; eventType = stmt.EventType; Assert.AreEqual(typeof(int?), eventType.GetPropertyType("P6")); Assert.AreEqual(typeof(int?), eventType.GetPropertyType("P7")); Assert.AreEqual(typeof(string), eventType.GetPropertyType("P8")); Assert.AreEqual(typeof(SupportBeanVariantOne.SupportBeanVariantOneInner), eventType.GetPropertyType("P9")); Assert.AreEqual(typeof(string), eventType.GetPropertyType("P10")); SupportBeanVariantOne ev1 = new SupportBeanVariantOne(); _epService.EPRuntime.SendEvent(ev1); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), "P6,P7,P8,P9,P10".Split(','), new Object[] { 1, 2, "val1", ev1.Inneritem, ev1.Inneritem.Val }); SupportBeanVariantTwo ev2 = new SupportBeanVariantTwo(); _epService.EPRuntime.SendEvent(ev2); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), "P6,P7,P8,P9,P10".Split(','), new Object[] { 10, 20, "val2", ev2.Inneritem, ev2.Inneritem.Val }); }
private void AssertIndexesRef(bool isNamedWindow, string csvNames) { var entry = GetIndexEntry(isNamedWindow); if (string.IsNullOrWhiteSpace(csvNames)) { Assert.IsNull(entry); } else { EPAssertionUtil.AssertEqualsAnyOrder(csvNames.Split(','), entry.ReferringStatements); } }
public void TestArrayOpAdd() { var testEvent = MakeEventArray(new[] { "a1", "a2", "a3" }); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { testEvent[0], testEvent[1], testEvent[2] }, EventBeanUtility.AddToArray(new[] { testEvent[0] }, Arrays.AsList(new[] { testEvent[1], testEvent[2] }))); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { testEvent[1], testEvent[2] }, EventBeanUtility.AddToArray(new EventBean[] { }, Arrays.AsList(new[] { testEvent[1], testEvent[2] }))); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { testEvent[0] }, EventBeanUtility.AddToArray(new[] { testEvent[0] }, Arrays.AsList(new EventBean[0]))); }
public void TestGetNavigableStreams() { _queryGraph = new QueryGraph(5, null, false); _queryGraph.AddStrictEquals(3, "p3", null, 4, "p4", null); _queryGraph.AddStrictEquals(2, "p2", null, 3, "p3", null); _queryGraph.AddStrictEquals(1, "p1", null, 2, "p2", null); Assert.AreEqual(0, _queryGraph.GetNavigableStreams(0).Count); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 2 }, _queryGraph.GetNavigableStreams(1)); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 1, 3 }, _queryGraph.GetNavigableStreams(2)); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 2, 4 }, _queryGraph.GetNavigableStreams(3)); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 3 }, _queryGraph.GetNavigableStreams(4)); }
public void TestGetResultEventType() { var type = _methodOne.GetEvaluator().ResultEventType; EPAssertionUtil.AssertEqualsAnyOrder(type.PropertyNames, new string[] { "resultOne", "resultTwo" }); Assert.AreEqual(typeof(double?), type.GetPropertyType("resultOne")); Assert.AreEqual(typeof(int?), type.GetPropertyType("resultTwo")); type = _methodTwo.GetEvaluator().ResultEventType; EPAssertionUtil.AssertEqualsAnyOrder(type.PropertyNames, new string[] { "a", "b" }); Assert.AreEqual(typeof(double?), type.GetPropertyType("a")); Assert.AreEqual(typeof(int?), type.GetPropertyType("b")); }
private void RunAssertionFragment(EPServiceProvider epService) { string stmtTxtOne = "select * from pattern [[2] a=A -> b=B]"; EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtTxtOne); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] { new EventPropertyDescriptor("a", typeof(SupportBean_A[]), typeof(SupportBean_A), false, false, true, false, true), new EventPropertyDescriptor("b", typeof(SupportBean_B), null, false, false, false, false, true) }, stmt.EventType.PropertyDescriptors); epService.EPRuntime.SendEvent(new SupportBean_A("A1")); epService.EPRuntime.SendEvent(new SupportBean_A("A2")); epService.EPRuntime.SendEvent(new SupportBean_B("B1")); EventBean theEvent = listener.AssertOneGetNewAndReset(); Assert.IsTrue(theEvent.Underlying is IDictionary <string, object>); // test fragment B type and event FragmentEventType typeFragB = theEvent.EventType.GetFragmentType("b"); Assert.IsFalse(typeFragB.IsIndexed); Assert.AreEqual("B", typeFragB.FragmentType.Name); Assert.AreEqual(typeof(string), typeFragB.FragmentType.GetPropertyType("id")); EventBean eventFragB = (EventBean)theEvent.GetFragment("b"); Assert.AreEqual("B", eventFragB.EventType.Name); // test fragment A type and event FragmentEventType typeFragA = theEvent.EventType.GetFragmentType("a"); Assert.IsTrue(typeFragA.IsIndexed); Assert.AreEqual("A", typeFragA.FragmentType.Name); Assert.AreEqual(typeof(string), typeFragA.FragmentType.GetPropertyType("id")); Assert.IsTrue(theEvent.GetFragment("a") is EventBean[]); EventBean eventFragA1 = (EventBean)theEvent.GetFragment("a[0]"); Assert.AreEqual("A", eventFragA1.EventType.Name); Assert.AreEqual("A1", eventFragA1.Get("id")); EventBean eventFragA2 = (EventBean)theEvent.GetFragment("a[1]"); Assert.AreEqual("A", eventFragA2.EventType.Name); Assert.AreEqual("A2", eventFragA2.Get("id")); stmt.Dispose(); }
private void RunAssertionIsolateFilter(EPServiceProvider epService) { if (SupportConfigFactory.SkipTest(typeof(ExecClientIsolationUnit))) { return; } EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from pattern [every a=SupportBean -> b=SupportBean(TheString=a.TheString)]"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); Assert.IsFalse(listener.GetAndClearIsInvoked()); EPServiceProviderIsolated unit = epService.GetEPServiceIsolated("i1"); EPAssertionUtil.AssertEqualsAnyOrder(new string[] { "i1" }, epService.EPServiceIsolatedNames); // send fake to wrong place unit.EPRuntime.SendEvent(new SupportBean("E1", -1)); unit.EPAdministrator.AddStatement(stmt); // send to 'wrong' engine epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); Assert.IsFalse(listener.GetAndClearIsInvoked()); // send to 'right' engine unit.EPRuntime.SendEvent(new SupportBean("E1", 3)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a.TheString,a.IntPrimitive,b.IntPrimitive".Split(','), new object[] { "E1", 1, 3 }); // send second pair, and a fake to the wrong place unit.EPRuntime.SendEvent(new SupportBean("E2", 4)); epService.EPRuntime.SendEvent(new SupportBean("E2", -1)); unit.EPAdministrator.RemoveStatement(stmt); // send to 'wrong' engine unit.EPRuntime.SendEvent(new SupportBean("E2", 5)); Assert.IsFalse(listener.GetAndClearIsInvoked()); // send to 'right' engine epService.EPRuntime.SendEvent(new SupportBean("E2", 6)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "a.TheString,a.IntPrimitive,b.IntPrimitive".Split(','), new object[] { "E2", 4, 6 }); epService.EPAdministrator.DestroyAllStatements(); EPAssertionUtil.AssertEqualsAnyOrder(new string[] { "i1" }, epService.EPServiceIsolatedNames); epService.GetEPServiceIsolated("i1").Dispose(); EPAssertionUtil.AssertEqualsAnyOrder(new string[0], epService.EPServiceIsolatedNames); }
public void TestSchemaXPathGetter() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "simpleEvent"; String schemaUri = ResourceManager.ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString(); desc.SchemaResource = schemaUri; desc.IsXPathPropertyExpr = true; desc.IsEventSenderValidatesRoot = false; desc.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); desc.DefaultNamespace = "samples:schemas:simpleSchema"; configuration.AddEventType("MyEvent", desc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } String stmtText = "select type?,dyn[1]?,nested.nes2?,map('a')? from MyEvent"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.Events += _listener.Update; EPAssertionUtil.AssertEqualsAnyOrder(new[] { new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("nested.nes2?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false), }, stmt.EventType.PropertyDescriptors); EventTypeAssertionUtil.AssertConsistency(stmt.EventType); EventSender sender = _epService.EPRuntime.GetEventSender("MyEvent"); XmlDocument root = SupportXML.SendEvent(sender, SCHEMA_XML); EventBean theEvent = _listener.AssertOneGetNewAndReset(); Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(2), theEvent.Get("dyn[1]?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?")); EventTypeAssertionUtil.AssertConsistency(theEvent); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestExpressionPrimitiveArray() { var eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; eventTypeMeta.SchemaResource = _schemaURI; _epService.EPAdministrator.Configuration.AddEventType("ABCType", eventTypeMeta); eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "//nested2"; eventTypeMeta.SchemaResource = _schemaURI; eventTypeMeta.IsEventSenderValidatesRoot = false; _epService.EPAdministrator.Configuration.AddEventType("TestNested2", eventTypeMeta); // try array property in select var stmtInsert = _epService.EPAdministrator.CreateEPL("select * from TestNested2.std:lastevent()"); stmtInsert.Events += _listener.Update; EPAssertionUtil.AssertEqualsAnyOrder(new [] { new EventPropertyDescriptor("prop3", typeof(int?[]), typeof(int?), false, false, true, false, false) }, stmtInsert.EventType.PropertyDescriptors); EventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType); SupportXML.SendDefaultEvent(_epService.EPRuntime, "test"); Assert.IsFalse(_listener.IsInvoked); var sender = _epService.EPRuntime.GetEventSender("TestNested2"); sender.SendEvent(SupportXML.GetDocument("<nested2><prop3>2</prop3><prop3></prop3><prop3>4</prop3></nested2>")); var theEvent = stmtInsert.First(); EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("prop3"), new int?[] { 2, null, 4 }); EventTypeAssertionUtil.AssertConsistency(theEvent); // try array property nested var stmtSelect = _epService.EPAdministrator.CreateEPL("select nested3.* from ABCType.std:lastevent()"); SupportXML.SendDefaultEvent(_epService.EPRuntime, "test"); var stmtSelectResult = stmtSelect.First(); EventTypeAssertionUtil.AssertConsistency(stmtSelectResult); Assert.AreEqual(typeof(String[]), stmtSelectResult.EventType.GetPropertyType("nested4[2].prop5")); Assert.AreEqual("SAMPLE_V8", stmtSelectResult.Get("nested4[0].prop5[1]")); EPAssertionUtil.AssertEqualsExactOrder((String[])stmtSelectResult.Get("nested4[2].prop5"), new Object[] { "SAMPLE_V10", "SAMPLE_V11" }); var fragmentNested4 = (EventBean)stmtSelectResult.GetFragment("nested4[2]"); EPAssertionUtil.AssertEqualsExactOrder((String[])fragmentNested4.Get("prop5"), new Object[] { "SAMPLE_V10", "SAMPLE_V11" }); Assert.AreEqual("SAMPLE_V11", fragmentNested4.Get("prop5[1]")); EventTypeAssertionUtil.AssertConsistency(fragmentNested4); }
public void Run(RegressionEnvironment env) { var @base = env.Compile("@Name('basevar') @public create constant variable int basevar = 1"); var child0 = env.Compile("@Name('s0') select basevar from SupportBean", new RegressionPath().Add(@base)); var child1 = env.Compile( "@Name('child1var') create constant variable int child1var = 2;\n" + "@Name('s1') select basevar, child1var from SupportBean;\n", new RegressionPath().Add(@base)); var child11 = env.Compile("@Name('s2') select basevar, child1var from SupportBean;\n", new RegressionPath().Add(@base).Add(child1)); env.Rollout(ToRolloutItems(@base, child0, child1, child11), null); env.AddListener("s0").AddListener("s1").AddListener("s2"); SendAssert(env, "s1,s2"); env.Milestone(0); SendAssert(env, "s1,s2"); AssertStatementIds(env, "basevar,s0,child1var,s1,s2", 1, 2, 3, 4, 5); var item = new EPDeploymentRolloutCompiled( env.Compile("@Name('s3') select basevar, child1var from SupportBean", new RegressionPath().Add(@base).Add(child1)), null); env.Rollout(Collections.SingletonList(item), null).AddListener("s3"); var deploymentChild11 = env.Deployment.GetDeployment(env.DeploymentId("s2")); EPAssertionUtil.AssertEqualsAnyOrder( new string[] { env.DeploymentId("basevar"), env.DeploymentId("child1var") }, deploymentChild11.DeploymentIdDependencies); env.Milestone(1); SendAssert(env, "s1,s2,s3"); AssertStatementIds(env, "basevar,s0,child1var,s1,s2,s3", 1, 2, 3, 4, 5, 6); env.UndeployAll(); env.Milestone(2); env.CompileDeploy("@Name('s1') select * from SupportBean"); TryInvalidRollout( env, "A precondition is not satisfied: Required dependency variable 'basevar' cannot be found", 0, typeof(EPDeployPreconditionException), child0); AssertStatementIds(env, "s1", 7); env.UndeployAll(); }
private void RunAssertionContextPartitionSelection(EPServiceProvider epService) { var fields = "c0,c1,c2,c3".Split(','); epService.EPRuntime.SendEvent(new CurrentTimeEvent(0)); epService.EPAdministrator.CreateEPL("create context MyCtx as start SupportBean_S0 s0 end SupportBean_S1(id=s0.id)"); var stmt = epService.EPAdministrator.CreateEPL("context MyCtx select context.id as c0, context.s0.p00 as c1, TheString as c2, sum(IntPrimitive) as c3 from SupportBean#keepall group by TheString"); epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000)); epService.EPRuntime.SendEvent(new SupportBean_S0(1, "S0_1")); epService.EPRuntime.SendEvent(new SupportBean("E1", 1)); epService.EPRuntime.SendEvent(new SupportBean("E2", 10)); epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); epService.EPRuntime.SendEvent(new SupportBean("E3", 100)); epService.EPRuntime.SendEvent(new SupportBean("E3", 101)); epService.EPRuntime.SendEvent(new SupportBean("E1", 3)); var expected = new object[][] { new object[] { 0, "S0_1", "E1", 6 }, new object[] { 0, "S0_1", "E2", 10 }, new object[] { 0, "S0_1", "E3", 201 } }; EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), stmt.GetSafeEnumerator(), fields, expected); // test iterator targeted by context partition id var selectorById = new SupportSelectorById(Collections.SingletonSet(0)); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(selectorById), stmt.GetSafeEnumerator(selectorById), fields, expected); // test iterator targeted by property on triggering event var filtered = new SupportSelectorFilteredInitTerm("S0_1"); EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(filtered), stmt.GetSafeEnumerator(filtered), fields, expected); filtered = new SupportSelectorFilteredInitTerm("S0_2"); Assert.IsFalse(stmt.GetEnumerator(filtered).MoveNext()); // test always-false filter - compare context partition info filtered = new SupportSelectorFilteredInitTerm(null); Assert.IsFalse(stmt.GetEnumerator(filtered).MoveNext()); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { 1000L }, filtered.ContextsStartTimes); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { "S0_1" }, filtered.P00PropertyValues); try { stmt.GetEnumerator(new ProxyContextPartitionSelectorSegmented() { ProcPartitionKeys = () => null }); Assert.Fail(); } catch (InvalidContextPartitionSelector ex) { Assert.IsTrue(ex.Message.StartsWith("Invalid context partition selector, expected an implementation class of any of [ContextPartitionSelectorAll, ContextPartitionSelectorFiltered, ContextPartitionSelectorById] interfaces but received com."), "message: " + ex.Message); } epService.EPAdministrator.DestroyAllStatements(); }
public void Run(RegressionEnvironment env) { env.CompileDeploy("insert into MyVariantStreamTwo select * from SupportBeanVariantOne"); env.CompileDeploy("insert into MyVariantStreamTwo select * from SupportBeanVariantTwo"); env.CompileDeploy("@Name('s0') select * from MyVariantStreamTwo").AddListener("s0"); var eventType = env.Statement("s0").EventType; var expected = new [] { "P0","P1","P2","P3","P4","P5","Indexed","Mapped","Inneritem" }; var propertyNames = eventType.PropertyNames; EPAssertionUtil.AssertEqualsAnyOrder(expected, propertyNames); Assert.AreEqual(typeof(ISupportBaseAB), eventType.GetPropertyType("P0")); Assert.AreEqual(typeof(ISupportAImplSuperG), eventType.GetPropertyType("P1")); Assert.AreEqual(typeof(LinkedList<object>), eventType.GetPropertyType("P2")); Assert.AreEqual(typeof(IList<object>), eventType.GetPropertyType("P3")); Assert.AreEqual(typeof(ICollection<object>), eventType.GetPropertyType("P4")); Assert.AreEqual(typeof(ICollection<object>), eventType.GetPropertyType("P5")); Assert.AreEqual(typeof(int[]), eventType.GetPropertyType("Indexed")); Assert.AreEqual(typeof(IDictionary<string, string>), eventType.GetPropertyType("Mapped")); Assert.AreEqual(typeof(SupportBeanVariantOne.SupportBeanVariantOneInner), eventType.GetPropertyType("Inneritem")); env.UndeployModuleContaining("s0"); env.CompileDeploy( "@Name('s0') select P0,P1,P2,P3,P4,P5,Indexed[0] as P6,IndexArr[1] as P7,MappedKey('a') as P8,Inneritem as P9,Inneritem.Val as P10 from MyVariantStreamTwo"); env.AddListener("s0"); eventType = env.Statement("s0").EventType; Assert.AreEqual(typeof(int?), eventType.GetPropertyType("P6")); Assert.AreEqual(typeof(int?), eventType.GetPropertyType("P7")); Assert.AreEqual(typeof(string), eventType.GetPropertyType("P8")); Assert.AreEqual( typeof(SupportBeanVariantOne.SupportBeanVariantOneInner), eventType.GetPropertyType("P9")); Assert.AreEqual(typeof(string), eventType.GetPropertyType("P10")); var ev1 = new SupportBeanVariantOne(); env.SendEventBean(ev1); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), new [] { "P6","P7","P8","P9","P10" }, new object[] {1, 2, "val1", ev1.Inneritem, ev1.Inneritem.Val}); var ev2 = new SupportBeanVariantTwo(); env.SendEventBean(ev2); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), new [] { "P6","P7","P8","P9","P10" }, new object[] {10, 20, "val2", ev2.Inneritem, ev2.Inneritem.Val}); env.UndeployAll(); }
public void TestArrayOp() { EventBean[] testEvent = MakeEventArray(new[] { "a1", "a2", "a3" }); EPAssertionUtil.AssertEqualsAnyOrder(new Object[] { testEvent[0] }, EventBeanUtility.AddToArray(new EventBean[0], testEvent[0])); EPAssertionUtil.AssertEqualsAnyOrder(new Object[] { testEvent[0], testEvent[1] }, EventBeanUtility.AddToArray(new[] { testEvent[0] }, testEvent[1])); EPAssertionUtil.AssertEqualsAnyOrder(new Object[] { testEvent[0], testEvent[1], testEvent[2] }, EventBeanUtility.AddToArray(new[] { testEvent[0], testEvent[1] }, testEvent[2])); }
private static void AssertIndexesRef( RegressionEnvironment env, bool namedWindow, string name, string csvNames) { var entry = GetIndexEntry(env, namedWindow, name); if (string.IsNullOrEmpty(csvNames)) { Assert.IsNull(entry); } else { EPAssertionUtil.AssertEqualsAnyOrder(csvNames.SplitCsv(), entry.ReferringDeployments); } }
private void RunAssertionMapTranspose(EventRepresentationEnum eventRepresentationEnum) { IDictionary <String, object> innerTypeOne = new Dictionary <string, object>(); innerTypeOne.Put("i1", typeof(int)); IDictionary <String, object> innerTypeTwo = new Dictionary <string, object>(); innerTypeTwo.Put("i2", typeof(int)); IDictionary <String, object> outerType = new Dictionary <string, object>(); outerType.Put("one", "T1"); outerType.Put("two", "T2"); _epService.EPAdministrator.Configuration.AddEventType("T1", innerTypeOne); _epService.EPAdministrator.Configuration.AddEventType("T2", innerTypeTwo); _epService.EPAdministrator.Configuration.AddEventType("OuterType", outerType); // create window var stmtTextCreate = eventRepresentationEnum.GetAnnotationText() + " create window MyWindow.win:keepall() as select one, two from OuterType"; var stmtCreate = _epService.EPAdministrator.CreateEPL(stmtTextCreate); Assert.AreEqual(eventRepresentationEnum.GetOutputClass(), stmtCreate.EventType.UnderlyingType); stmtCreate.AddListener(_listenerWindow); EPAssertionUtil.AssertEqualsAnyOrder(stmtCreate.EventType.PropertyNames, new string[] { "one", "two" }); var eventType = stmtCreate.EventType; Assert.AreEqual("T1", eventType.GetFragmentType("one").FragmentType.Name); Assert.AreEqual("T2", eventType.GetFragmentType("two").FragmentType.Name); // create insert into var stmtTextInsertOne = "insert into MyWindow select one, two from OuterType"; _epService.EPAdministrator.CreateEPL(stmtTextInsertOne); IDictionary <String, object> innerDataOne = new Dictionary <string, object>(); innerDataOne.Put("i1", 1); IDictionary <String, object> innerDataTwo = new Dictionary <string, object>(); innerDataTwo.Put("i2", 2); IDictionary <String, object> outerData = new Dictionary <string, object>(); outerData.Put("one", innerDataOne); outerData.Put("two", innerDataTwo); _epService.EPRuntime.SendEvent(outerData, "OuterType"); EPAssertionUtil.AssertProps(_listenerWindow.AssertOneGetNewAndReset(), "one.i1,two.i2".Split(','), new object[] { 1, 2 }); _epService.EPAdministrator.DestroyAllStatements(); _epService.EPAdministrator.Configuration.RemoveEventType("MyWindow", true); }
public void TestJoinUniquePerId() { String joinStatement = "select * from " + typeof(SupportMarketDataBean).FullName + "(Symbol='IBM').win:length(3) s0, " + typeof(SupportMarketDataBean).FullName + "(Symbol='CSCO').win:length(3) s1" + " where s0.Volume=s1.Volume"; EPStatement joinView = _epService.EPAdministrator.CreateEPL(joinStatement, "MyJoin"); joinView.Events += _updateListener.Update; SendEvent(setOne[0]); SendEvent(setTwo[0]); Assert.NotNull(_updateListener.LastNewData); _updateListener.Reset(); joinView.Stop(); SendEvent(setOne[1]); SendEvent(setTwo[1]); Assert.IsFalse(_updateListener.IsInvoked); joinView.Start(); SendEvent(setOne[2]); Assert.IsFalse(_updateListener.IsInvoked); joinView.Stop(); SendEvent(setOne[3]); SendEvent(setOne[4]); SendEvent(setTwo[3]); joinView.Start(); SendEvent(setTwo[4]); Assert.IsFalse(_updateListener.IsInvoked); // assert type-statement reference EPServiceProviderSPI spi = (EPServiceProviderSPI)_epService; Assert.IsTrue(spi.StatementEventTypeRef.IsInUse(typeof(SupportMarketDataBean).FullName)); ICollection <String> stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportMarketDataBean).FullName); Assert.IsTrue(stmtNames.Contains("MyJoin")); joinView.Dispose(); Assert.IsFalse(spi.StatementEventTypeRef.IsInUse(typeof(SupportMarketDataBean).FullName)); stmtNames = spi.StatementEventTypeRef.GetStatementNamesForType(typeof(SupportMarketDataBean).FullName); EPAssertionUtil.AssertEqualsAnyOrder(null, stmtNames.ToArray()); Assert.IsFalse(stmtNames.Contains("MyJoin")); }
public void TestAddArraySetSemantics() { var e = new EventBean[10]; for (var i = 0; i < e.Length; i++) { e[i] = new MapEventBean(null); } Assert.IsFalse(e[0].Equals(e[1])); object[][] testData = { new object[] {new EventBean[] { }, new EventBean[] { }, "P2"}, new object[] {new EventBean[] { }, new[] {e[0], e[1]}, "P2"}, new object[] {new[] {e[0]}, new EventBean[] { }, "P1"}, new object[] {new[] {e[0]}, new[] {e[0]}, "P1"}, new object[] {new[] {e[0]}, new[] {e[1]}, new[] {e[0], e[1]}}, new object[] {new[] {e[0], e[1]}, new[] {e[1]}, "P1"}, new object[] {new[] {e[0], e[1]}, new[] {e[0]}, "P1"}, new object[] {new[] {e[0]}, new[] {e[0], e[1]}, "P2"}, new object[] {new[] {e[1]}, new[] {e[0], e[1]}, "P2"}, new object[] {new[] {e[2]}, new[] {e[0], e[1]}, new[] {e[0], e[1], e[2]}}, new object[] {new[] {e[2], e[0]}, new[] {e[0], e[1]}, new[] {e[0], e[1], e[2]}}, new object[] {new[] {e[2], e[0]}, new[] {e[0], e[1], e[2]}, new[] {e[0], e[1], e[2]}} }; for (var i = 0; i < testData.Length; i++) { var p1 = (EventBean[]) testData[i][0]; var p2 = (EventBean[]) testData[i][1]; var expectedObj = testData[i][2]; object result = CollectionUtil.AddArrayWithSetSemantics(p1, p2); if (expectedObj.Equals("P1")) { Assert.IsTrue(result == p1); } else if (expectedObj.Equals("P2")) { Assert.IsTrue(result == p2); } else { var resultArray = (EventBean[]) result; var expectedArray = (EventBean[]) result; EPAssertionUtil.AssertEqualsAnyOrder(resultArray, expectedArray); } } }
private void RunAssertionMultirowUnderlyingCorrelated(EPServiceProvider epService) { string stmtText = "select p00, " + "(select window(sb.*) from SupportBean#keepall sb where TheString = s0.p00) as val " + "from S0 as s0"; EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var rows = new object[][] { new object[] { "p00", typeof(string) }, new object[] { "val", typeof(SupportBean[]) } }; for (int i = 0; i < rows.Length; i++) { string message = "Failed assertion for " + rows[i][0]; EventPropertyDescriptor prop = stmt.EventType.PropertyDescriptors[i]; Assert.AreEqual(rows[i][0], prop.PropertyName, message); Assert.AreEqual(rows[i][1], prop.PropertyType, message); } epService.EPRuntime.SendEvent(new SupportBean_S0(1, "T1")); Assert.IsNull(listener.AssertOneGetNewAndReset().Get("val")); var sb1 = new SupportBean("T1", 10); epService.EPRuntime.SendEvent(sb1); epService.EPRuntime.SendEvent(new SupportBean_S0(2, "T1")); EventBean received = listener.AssertOneGetNewAndReset(); Assert.AreEqual(typeof(SupportBean[]), received.Get("val").GetType()); EPAssertionUtil.AssertEqualsAnyOrder((object[])received.Get("val"), new object[] { sb1 }); var sb2 = new SupportBean("T2", 20); epService.EPRuntime.SendEvent(sb2); var sb3 = new SupportBean("T2", 30); epService.EPRuntime.SendEvent(sb3); epService.EPRuntime.SendEvent(new SupportBean_S0(3, "T2")); received = listener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertEqualsAnyOrder((object[])received.Get("val"), new object[] { sb2, sb3 }); stmt.Dispose(); }
private void RunAssertionTwoParameterArithmetic(EPStatement stmt, string[] fields) { var props = stmt.EventType.PropertyNames; EPAssertionUtil.AssertEqualsAnyOrder(props, fields); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType(fields[0])); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType(fields[1])); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType(fields[2])); Assert.AreEqual(typeof(int?), stmt.EventType.GetPropertyType(fields[3])); var getter = stmt.EventType.GetGetter(fields[3]); _epService.EPRuntime.SendEvent(new SupportBean("E1", 11)); EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), fields, new object[] { 10, 11, 22, 111 }); Assert.AreEqual(111, getter.Get(_listener.AssertOneGetNewAndReset())); }
public void TestGetNavigableStreams() { ExprIdentNode fake = supportExprNodeFactory.MakeIdentNode("TheString", "s0"); queryGraph = new QueryGraphForge(5, null, false); queryGraph.AddStrictEquals(3, "p3", fake, 4, "p4", fake); queryGraph.AddStrictEquals(2, "P2", fake, 3, "p3", fake); queryGraph.AddStrictEquals(1, "P1", fake, 2, "P2", fake); Assert.AreEqual(0, queryGraph.GetNavigableStreams(0).Count); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 2 }, queryGraph.GetNavigableStreams(1)); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 1, 3 }, queryGraph.GetNavigableStreams(2)); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 2, 4 }, queryGraph.GetNavigableStreams(3)); EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 3 }, queryGraph.GetNavigableStreams(4)); }
public void TestLookup() { var result = new List <EventBean[]>(); var prefill = new EventBean[4]; prefill[2] = _streamEvents[2][0]; _exec.Process(_streamEvents[2][0], prefill, result, null); Assert.AreEqual(8, result.Count); EventBean[][] received = MakeArray(result); EventBean[][] expected = MakeExpected(); EPAssertionUtil.AssertEqualsAnyOrder(expected, received); }
public void TestAddMappedProperties() { IList<PropertyStem> result = new List<PropertyStem>(); PropertyHelper.AddMappedProperties( MagicType.GetCachedType<SupportBeanPropertyNames>(), result); Assert.AreEqual(6, result.Count); IList<string> propertyNames = new List<string>(); foreach (PropertyStem desc in result) { log.Debug("desc=" + desc.PropertyName); propertyNames.Add(desc.PropertyName); } EPAssertionUtil.AssertEqualsAnyOrder(new object[] { "a", "AB", "ABC", "ab", "abc", "fooBah" }, propertyNames.ToArray()); }
private void RunAssertionStatementArray(EPServiceProvider epService) { Assert.AreEqual(0, epService.EPAdministrator.StatementNames.Count); var names = new string[] { "s1" }; CreateStmts(epService, names); EPAssertionUtil.AssertEqualsAnyOrder(names, epService.EPAdministrator.StatementNames); names = new string[] { "s1", "s2" }; CreateStmts(epService, names); EPAssertionUtil.AssertEqualsAnyOrder(new string[] { "s1", "s1--0", "s2" }, epService.EPAdministrator.StatementNames); epService.EPAdministrator.DestroyAllStatements(); }
public void TestArrayOp() { var testEvent = MakeEventArray(new[] { "a1", "a2", "a3" }); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { testEvent[0] }, EventBeanUtility.AddToArray(new EventBean[0], testEvent[0])); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { testEvent[0], testEvent[1] }, EventBeanUtility.AddToArray(new[] { testEvent[0] }, testEvent[1])); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { testEvent[0], testEvent[1], testEvent[2] }, EventBeanUtility.AddToArray(new[] { testEvent[0], testEvent[1] }, testEvent[2])); Console.Out.WriteLine(EventBeanUtility.PrintEvents(testEvent)); }
public void TestNoSchemaDOMGetter() { var configuration = SupportConfigFactory.GetConfiguration(); var desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "simpleEvent"; configuration.AddEventType("MyEvent", desc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } var stmtText = "select type?,dyn[1]?,nested.nes2?,map('a')? from MyEvent"; var stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.Events += _listener.Update; EPAssertionUtil.AssertEqualsAnyOrder( new[] { new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("nested.nes2?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false), }, stmt.EventType.PropertyDescriptors); EventTypeAssertionUtil.AssertConsistency(stmt.EventType); XmlDocument root = SupportXML.SendEvent(_epService.EPRuntime, NOSCHEMA_XML); EventBean theEvent = _listener.AssertOneGetNewAndReset(); Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(2), theEvent.Get("dyn[1]?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?")); EventTypeAssertionUtil.AssertConsistency(theEvent); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
private void RunAssertionRangeNullAndDupAndInvalid(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); epService.EPAdministrator.Configuration.AddEventType("SupportBeanRange", typeof(SupportBeanRange)); epService.EPAdministrator.Configuration.AddEventType("SupportBeanComplexProps", typeof(SupportBeanComplexProps)); string eplOne = "select sb.* from SupportBean#keepall sb, SupportBeanRange#lastevent where IntBoxed between rangeStart and rangeEnd"; EPStatement stmtOne = epService.EPAdministrator.CreateEPL(eplOne); var listener = new SupportUpdateListener(); stmtOne.Events += listener.Update; string eplTwo = "select sb.* from SupportBean#keepall sb, SupportBeanRange#lastevent where TheString = key and IntBoxed in [rangeStart: rangeEnd]"; EPStatement stmtTwo = epService.EPAdministrator.CreateEPL(eplTwo); var listenerTwo = new SupportUpdateListener(); stmtTwo.Events += listenerTwo.Update; // null join lookups SendEvent(epService, new SupportBeanRange("R1", "G", (int?)null, null)); SendEvent(epService, new SupportBeanRange("R2", "G", null, 10)); SendEvent(epService, new SupportBeanRange("R3", "G", 10, null)); SendSupportBean(epService, "G", -1, null); // range invalid SendEvent(epService, new SupportBeanRange("R4", "G", 10, 0)); Assert.IsFalse(listener.IsInvoked); Assert.IsFalse(listenerTwo.IsInvoked); // duplicates Object eventOne = SendSupportBean(epService, "G", 100, 5); Object eventTwo = SendSupportBean(epService, "G", 101, 5); SendEvent(epService, new SupportBeanRange("R4", "G", 0, 10)); EventBean[] events = listener.GetAndResetLastNewData(); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { eventOne, eventTwo }, EPAssertionUtil.GetUnderlying(events)); events = listenerTwo.GetAndResetLastNewData(); EPAssertionUtil.AssertEqualsAnyOrder(new object[] { eventOne, eventTwo }, EPAssertionUtil.GetUnderlying(events)); // test string compare string eplThree = "select sb.* from SupportBeanRange#keepall sb, SupportBean#lastevent where TheString in [rangeStartStr:rangeEndStr]"; epService.EPAdministrator.CreateEPL(eplThree); SendSupportBean(epService, "P", 1, 1); SendEvent(epService, new SupportBeanRange("R5", "R5", "O", "Q")); Assert.IsTrue(listener.IsInvoked); }
private EPStatement AssertFilterMulti(string epl, FilterItem[][] expected) { var statementSPI = (EPStatementSPI)_epService.EPAdministrator.CreateEPL(epl); var filterServiceSPI = (FilterServiceSPI)statementSPI.StatementContext.FilterService; var set = filterServiceSPI.Take(Collections.SingletonList(statementSPI.StatementId)); var valueSet = set.Filters[0].FilterValueSet; var @params = valueSet.Parameters; var comparison = new Comparison <FilterItem>((o1, o2) => { if (o1.Name == o2.Name) { if (o1.Op > o2.Op) { return(1); } if (o1.Op < o2.Op) { return(-1); } return(0); } return(string.CompareOrdinal(o1.Name, o2.Name)); }); var found = new FilterItem[@params.Length][]; for (var i = 0; i < found.Length; i++) { found[i] = new FilterItem[@params[i].Length]; for (var j = 0; j < @params[i].Length; j++) { found[i][j] = new FilterItem(@params[i][j].Lookupable.Expression.ToString(), @params[i][j].FilterOperator); } Array.Sort(found[i], comparison); } for (var i = 0; i < expected.Length; i++) { Array.Sort(expected[i], comparison); } EPAssertionUtil.AssertEqualsAnyOrder(expected, found); filterServiceSPI.Apply(set); return(statementSPI); }