public void Run(RegressionEnvironment env) { string[] fields = "c0,c1".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.selectFrom( (v, i) => v || '_' || Convert.ToString(i))"); builder.WithExpression(fields[1], "Strvals.selectFrom( (v, i, s) => v || '_' || Convert.ToString(i) || '_' || Convert.ToString(s))"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportCollection.MakeString("E1,E2,E3")) .Verify(fields[0], value => AssertValuesArrayScalar(value, "E1_0", "E2_1", "E3_2")) .Verify(fields[1], value => AssertValuesArrayScalar(value, "E1_0_3", "E2_1_3", "E3_2_3")); builder.WithAssertion(SupportCollection.MakeString("")) .Verify(fields[0], value => AssertValuesArrayScalar(value)) .Verify(fields[1], value => AssertValuesArrayScalar(value)); builder.WithAssertion(SupportCollection.MakeString("E1")) .Verify(fields[0], value => AssertValuesArrayScalar(value, "E1_0")) .Verify(fields[1], value => AssertValuesArrayScalar(value, "E1_0_1")); builder.WithAssertion(SupportCollection.MakeString(null)) .Verify(fields[0], Assert.IsNull) .Verify(fields[1], Assert.IsNull); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.groupBy(c => extractAfterUnderscore(c))"); builder.WithExpression(fields[1], "Strvals.groupBy((c, i) => extractAfterUnderscore(c) || '_' || Convert.ToString(i))"); builder.WithExpression( fields[2], "Strvals.groupBy((c, i, s) => extractAfterUnderscore(c) || '_' || Convert.ToString(i) || '_' || Convert.ToString(s))"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(IDictionary <object, object>))); builder.WithAssertion(SupportCollection.MakeString("E1_2,E2_1,E3_2")) .Verify("c0", val => CompareMaps(val, "2,1", new[] { "E1_2,E3_2", "E2_1" }, GetExtractorScalar())) .Verify("c1", val => CompareMaps(val, "2_0,1_1,2_2", new[] { "E1_2", "E2_1", "E3_2" }, GetExtractorScalar())) .Verify("c2", val => CompareMaps(val, "2_0_3,1_1_3,2_2_3", new[] { "E1_2", "E2_1", "E3_2" }, GetExtractorScalar())); SupportEvalAssertionBuilder assertionNull = builder.WithAssertion(SupportCollection.MakeString(null)); foreach (string field in fields) { assertionNull.Verify(field, Assert.IsNull); } SupportEvalAssertionBuilder assertionEmpty = builder.WithAssertion(SupportCollection.MakeString("")); foreach (string field in fields) { assertionEmpty.Verify(field, val => CompareMaps(val, "", new string[0], GetExtractorScalar())); } builder.Run(env); }
public void Run(RegressionEnvironment env) { env.CompileDeploy("@Name('s0') " + EPL).AddListener("s0"); var type = env.Statement("s0").EventType; Assert.AreEqual(typeof(byte?), type.GetPropertyType("myFirstProperty")); Assert.AreEqual(typeof(short?), type.GetPropertyType("mySecondProperty")); Assert.AreEqual(typeof(int?), type.GetPropertyType("myThirdProperty")); Assert.AreEqual(typeof(long?), type.GetPropertyType("myFourthProperty")); Assert.AreEqual(typeof(bool?), type.GetPropertyType("myFifthProperty")); RunBitWiseOperators(env); env.UndeployAll(); var fields = "c0".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean") .WithExpression(fields[0], "BytePrimitive&ByteBoxed"); builder.WithAssertion(MakeEventBB(1, 1)).Expect(fields, (byte)1); builder.WithAssertion(MakeEventBB(1, null)).Expect(fields, new object[] { null }); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1,c2,c3,c4,c5".SplitCsv(); var builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.minBy(v => extractNum(v))"); builder.WithExpression(fields[1], "Strvals.maxBy(v => extractNum(v))"); builder.WithExpression(fields[2], "Strvals.minBy( (v, i) => extractNum(v) + i*10)"); builder.WithExpression(fields[3], "Strvals.maxBy( (v, i) => extractNum(v) + i*10)"); builder.WithExpression(fields[4], "Strvals.minBy( (v, i, s) => extractNum(v) + (case when s > 2 then i*10 else 0 end))"); builder.WithExpression(fields[5], "Strvals.maxBy( (v, i, s) => extractNum(v) + (case when s > 2 then i*10 else 0 end))"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(String))); builder.WithAssertion(SupportCollection.MakeString("E2,E1,E5,E4")).Expect(fields, "E1", "E5", "E2", "E4", "E2", "E4"); builder.WithAssertion(SupportCollection.MakeString("E1")).Expect(fields, "E1", "E1", "E1", "E1", "E1", "E1"); builder.WithAssertion(SupportCollection.MakeString(null)).Expect(fields, null, null, null, null, null, null); builder.WithAssertion(SupportCollection.MakeString("")).Expect(fields, null, null, null, null, null, null); builder.WithAssertion(SupportCollection.MakeString("E8,E2")).Expect(fields, "E2", "E8", "E8", "E2", "E2", "E8"); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container"); builder.WithExpression(fields[0], "Contained.arrayOf(x => x.P00)"); builder.WithExpression(fields[1], "Contained.arrayOf((x, i) => x.P00 + i*10)"); builder.WithExpression(fields[2], "Contained.arrayOf((x, i, s) => x.P00 + i*10 + s*100)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(int?[]))); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E2,2")) .Expect(fields, IntArray(1, 9, 2), IntArray(1, 19, 22), IntArray(301, 319, 322)); builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()) .Expect(fields, null, null, null); builder.WithAssertion(SupportBean_ST0_Container.Make2Value()) .Expect(fields, IntArray(), IntArray(), IntArray()); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,9")) .Expect(fields, IntArray(9), IntArray(9), IntArray(109)); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2,c3".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.take(2)"); builder.WithExpression(fields[1], "Strvals.take(1)"); builder.WithExpression(fields[2], "Strvals.takeLast(2)"); builder.WithExpression(fields[3], "Strvals.takeLast(1)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportCollection.MakeString("E1,E2,E3")) .Verify("c0", val => AssertValuesArrayScalar(val, "E1", "E2")) .Verify("c1", val => AssertValuesArrayScalar(val, "E1")) .Verify("c2", val => AssertValuesArrayScalar(val, "E2", "E3")) .Verify("c3", val => AssertValuesArrayScalar(val, "E3")); builder.WithAssertion(SupportCollection.MakeString("E1,E2")) .Verify("c0", val => AssertValuesArrayScalar(val, "E1", "E2")) .Verify("c1", val => AssertValuesArrayScalar(val, "E1")) .Verify("c2", val => AssertValuesArrayScalar(val, "E1", "E2")) .Verify("c3", val => AssertValuesArrayScalar(val, "E2")); AssertSingleAndEmptySupportColl(builder, fields); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2,c3".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.arrayOf()"); builder.WithExpression(fields[1], "Strvals.arrayOf(v => v)"); builder.WithExpression(fields[2], "Strvals.arrayOf( (v, i) => v || '_' || Convert.ToString(i))"); builder.WithExpression(fields[3], "Strvals.arrayOf( (v, i, s) => v || '_' || Convert.ToString(i) || '_' || Convert.ToString(s))"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(string[]))); builder.WithAssertion(SupportCollection.MakeString("A,B,C")) .Expect(fields, Csv("A,B,C"), Csv("A,B,C"), Csv("A_0,B_1,C_2"), Csv("A_0_3,B_1_3,C_2_3")); builder.WithAssertion(SupportCollection.MakeString("")) .Expect(fields, Csv(""), Csv(""), Csv(""), Csv("")); builder.WithAssertion(SupportCollection.MakeString("A")) .Expect(fields, Csv("A"), Csv("A"), Csv("A_0"), Csv("A_0_1")); builder.WithAssertion(SupportCollection.MakeString(null)) .Expect(fields, null, null, null, null); builder.Run(env); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1,c2,c3,c4,c5,c6,c7".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean") .WithExpression(fields[0], "instanceof(TheString, string)") .WithExpression(fields[1], "instanceof(IntBoxed, int)") .WithExpression(fields[2], "instanceof(FloatBoxed, System.Single)") .WithExpression(fields[3], "instanceof(TheString, System.Single, char, byte)") .WithExpression(fields[4], "instanceof(IntPrimitive, System.Int32)") .WithExpression(fields[5], "instanceof(IntPrimitive, long)") .WithExpression(fields[6], "instanceof(IntPrimitive, long, long, System.Object)") .WithExpression(fields[7], "instanceof(FloatBoxed, long, float)"); builder.WithStatementConsumer( stmt => { for (var i = 0; i < fields.Length; i++) { Assert.AreEqual(typeof(bool?), stmt.EventType.GetPropertyType(fields[i])); } }); var bean = new SupportBean("abc", 100); bean.FloatBoxed = 100F; builder.WithAssertion(bean).Expect(fields, true, false, true, false, true, false, true, true); bean = new SupportBean(null, 100); bean.FloatBoxed = null; builder.WithAssertion(bean).Expect(fields, false, false, false, false, true, false, true, false); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var fields = new[] { "c0" }; var builder = new SupportEvalBuilder("SupportBean") .WithExpressions( fields, "case IntPrimitive " + " when LongPrimitive then (IntPrimitive + LongPrimitive) " + " when DoublePrimitive then IntPrimitive * DoublePrimitive" + " when FloatPrimitive then FloatPrimitive / DoublePrimitive " + " else (IntPrimitive + LongPrimitive + FloatPrimitive + DoublePrimitive) end") .WithStatementConsumer(stmt => Assert.AreEqual(typeof(double?), stmt.EventType.GetPropertyType("c0"))); // IntPrimitive = longPrimitive // case result is IntPrimitive + longPrimitive builder.WithAssertion(MakeSupportBeanEvent(2, 2L, 1.0f, 1.0)).Expect(fields, 4.0); // IntPrimitive = DoublePrimitive // case result is IntPrimitive * DoublePrimitive builder.WithAssertion(MakeSupportBeanEvent(5, 1L, 1.0f, 5.0)).Expect(fields, 25.0); // IntPrimitive = FloatPrimitive // case result is FloatPrimitive / DoublePrimitive builder.WithAssertion(MakeSupportBeanEvent(12, 1L, 12.0f, 4.0)).Expect(fields, 3.0); // all the properties of the event are different // The else part is computed: 1+2+3+4 = 10 builder.WithAssertion(MakeSupportBeanEvent(1, 2L, 3.0f, 4.0)).Expect(fields, 10.0); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2,c3,c4".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container"); builder.WithExpression(fields[0], "Contained.aggregate(0, (result, item) => result + item.P00)"); builder.WithExpression(fields[1], "Contained.aggregate('', (result, item) => result || ', ' || item.Id)"); builder.WithExpression(fields[2], "Contained.aggregate('', (result, item) => result || (case when result='' then '' else ',' end) || item.Id)"); builder.WithExpression(fields[3], "Contained.aggregate(0, (result, item, i) => result + item.P00 + i*10)"); builder.WithExpression(fields[4], "Contained.aggregate(0, (result, item, i, s) => result + item.P00 + i*10 + s*100)"); builder.WithStatementConsumer( stmt => LambdaAssertionUtil.AssertTypes( stmt.EventType, fields, new[] { typeof(int?), typeof(string), typeof(string), typeof(int?), typeof(int?) })); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,12", "E2,11", "E2,2")) .Expect(fields, 25, ", E1, E2, E2", "E1,E2,E2", 12 + 21 + 22, 312 + 321 + 322); builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()) .Expect(fields, null, null, null, null, null); builder.WithAssertion(SupportBean_ST0_Container.Make2Value(new string[0])) .Expect(fields, 0, "", "", 0, 0); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,12")) .Expect(fields, 12, ", E1", "E1", 12, 112); builder.Run(env); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1,c2".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean_Container"); builder.WithExpression(fields[0], "Beans.sumOf(x => IntBoxed)"); builder.WithExpression(fields[1], "Beans.sumOf( (x, i) => IntBoxed + i*10)"); builder.WithExpression(fields[2], "Beans.sumOf( (x, i, s) => IntBoxed + i*10 + s*100)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(int?))); builder.WithAssertion(new SupportBean_Container(null)).Expect(fields, null, null, null); builder.WithAssertion(new SupportBean_Container(EmptyList <SupportBean> .Instance)).Expect(fields, null, null, null); IList <SupportBean> listOne = new List <SupportBean>() { MakeSB("E1", 10) }; builder.WithAssertion(new SupportBean_Container(listOne)).Expect(fields, 10, 10, 110); IList <SupportBean> listTwo = new List <SupportBean>() { MakeSB("E1", 10), MakeSB("E2", 11) }; builder.WithAssertion(new SupportBean_Container(listTwo)).Expect(fields, 21, 31, 431); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2,c3".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container"); builder.WithExpression(fields[0], "Contained.orderBy( (x, i) => case when i <= 2 then P00 else i-10 end)"); builder.WithExpression(fields[1], "Contained.orderByDesc( (x, i) => case when i <= 2 then P00 else i-10 end)"); builder.WithExpression(fields[2], "Contained.orderBy( (x, i, s) => case when s <= 2 then P00 else i-10 end)"); builder.WithExpression(fields[3], "Contained.orderByDesc( (x, i, s) => case when s <= 2 then P00 else i-10 end)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2")) .Verify("c0", val => AssertST0Id(val, "E1,E2")) .Verify("c1", val => AssertST0Id(val, "E2,E1")) .Verify("c2", val => AssertST0Id(val, "E1,E2")) .Verify("c3", val => AssertST0Id(val, "E2,E1")); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2", "E3,3", "E4,4")) .Verify("c0", val => AssertST0Id(val, "E4,E1,E2,E3")) .Verify("c1", val => AssertST0Id(val, "E3,E2,E1,E4")) .Verify("c2", val => AssertST0Id(val, "E1,E2,E3,E4")) .Verify("c3", val => AssertST0Id(val, "E4,E3,E2,E1")); builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()).Expect(fields, null, null, null, null); builder.WithAssertion(SupportBean_ST0_Container.Make2Value()) .Verify("c0", val => AssertST0Id(val, "")) .Verify("c1", val => AssertST0Id(val, "")) .Verify("c2", val => AssertST0Id(val, "")) .Verify("c3", val => AssertST0Id(val, "")); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2,c3,c4,c5,c6,c7".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.min(v => extractNum(v))"); builder.WithExpression(fields[1], "Strvals.max(v => extractNum(v))"); builder.WithExpression(fields[2], "Strvals.min(v => v)"); builder.WithExpression(fields[3], "Strvals.max(v => v)"); builder.WithExpression(fields[4], "Strvals.min( (v, i) => extractNum(v) + i*10)"); builder.WithExpression(fields[5], "Strvals.max( (v, i) => extractNum(v) + i*10)"); builder.WithExpression(fields[6], "Strvals.min( (v, i, s) => extractNum(v) + i*10 + s*100)"); builder.WithExpression(fields[7], "Strvals.max( (v, i, s) => extractNum(v) + i*10 + s*100)"); builder.WithStatementConsumer( stmt => AssertTypes( stmt.EventType, fields, new[] { typeof(int?), typeof(int?), typeof(string), typeof(string), typeof(int?), typeof(int?), typeof(int?), typeof(int?) })); builder.WithAssertion(SupportCollection.MakeString("E2,E1,E5,E4")).Expect(fields, 1, 5, "E1", "E5", 2, 34, 402, 434); builder.WithAssertion(SupportCollection.MakeString("E1")).Expect(fields, 1, 1, "E1", "E1", 1, 1, 101, 101); builder.WithAssertion(SupportCollection.MakeString(null)).Expect(fields, null, null, null, null, null, null, null, null); builder.WithAssertion(SupportCollection.MakeString("")).Expect(fields, null, null, null, null, null, null, null, null); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.except(Strvalstwo)"); builder.WithExpression(fields[1], "Strvals.intersect(Strvalstwo)"); builder.WithExpression(fields[2], "Strvals.union(Strvalstwo)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportCollection.MakeString("E1,E2", "E3,E4")) .Verify("c0", val => AssertValuesArrayScalar(val, "E1", "E2")) .Verify("c1", val => AssertValuesArrayScalar(val)) .Verify("c2", val => AssertValuesArrayScalar(val, "E1", "E2", "E3", "E4")); builder.WithAssertion(SupportCollection.MakeString(null, "E3,E4")) .Verify("c0", val => AssertValuesArrayScalar(val, (object[])null)) .Verify("c1", val => AssertValuesArrayScalar(val, (object[])null)) .Verify("c2", val => AssertValuesArrayScalar(val, (object[])null)); builder.WithAssertion(SupportCollection.MakeString("", "E3,E4")) .Verify("c0", val => AssertValuesArrayScalar(val)) .Verify("c1", val => AssertValuesArrayScalar(val)) .Verify("c2", val => AssertValuesArrayScalar(val, "E3", "E4")); builder.WithAssertion(SupportCollection.MakeString("E1,E3,E5", "E3,E4")) .Verify("c0", val => AssertValuesArrayScalar(val, "E1", "E5")) .Verify("c1", val => AssertValuesArrayScalar(val, "E3")) .Verify("c2", val => AssertValuesArrayScalar(val, "E1", "E3", "E5", "E3", "E4")); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2,c3,c4,c5".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.orderBy(v => extractNum(v))"); builder.WithExpression(fields[1], "Strvals.orderByDesc(v => extractNum(v))"); builder.WithExpression(fields[2], "Strvals.orderBy( (v, i) => case when i <= 2 then extractNum(v) else i-10 end)"); builder.WithExpression(fields[3], "Strvals.orderByDesc( (v, i) => case when i <= 2 then extractNum(v) else i-10 end)"); builder.WithExpression(fields[4], "Strvals.orderBy( (v, i, s) => case when s <= 2 then extractNum(v) else i-10 end)"); builder.WithExpression(fields[5], "Strvals.orderByDesc( (v, i, s) => case when s <= 2 then extractNum(v) else i-10 end)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportCollection.MakeString("E2,E1,E5,E4")) .Verify("c0", val => AssertValuesArrayScalar(val, "E1", "E2", "E4", "E5")) .Verify("c1", val => AssertValuesArrayScalar(val, "E5", "E4", "E2", "E1")) .Verify("c2", val => AssertValuesArrayScalar(val, "E4", "E1", "E2", "E5")) .Verify("c3", val => AssertValuesArrayScalar(val, "E5", "E2", "E1", "E4")) .Verify("c4", val => AssertValuesArrayScalar(val, "E2", "E1", "E5", "E4")) .Verify("c5", val => AssertValuesArrayScalar(val, "E4", "E5", "E1", "E2")); builder.WithAssertion(SupportCollection.MakeString("E2,E1")) .Verify("c0", val => AssertValuesArrayScalar(val, "E1", "E2")) .Verify("c1", val => AssertValuesArrayScalar(val, "E2", "E1")) .Verify("c2", val => AssertValuesArrayScalar(val, "E1", "E2")) .Verify("c3", val => AssertValuesArrayScalar(val, "E2", "E1")) .Verify("c4", val => AssertValuesArrayScalar(val, "E1", "E2")) .Verify("c5", val => AssertValuesArrayScalar(val, "E2", "E1")); LambdaAssertionUtil.AssertSingleAndEmptySupportColl(builder, fields); builder.Run(env); }
private static void RunAssertion( RegressionEnvironment env, string lhs, string rhs, Consumer <SupportBean> one, Consumer <SupportBean> two, Consumer <SupportBean> three) { var builder = new SupportEvalBuilder("SupportBean"); var fields = "c0,c1,c2,c3".SplitCsv(); builder.WithExpression(fields[0], lhs + ">=" + rhs); builder.WithExpression(fields[1], lhs + ">" + rhs); builder.WithExpression(fields[2], lhs + "<=" + rhs); builder.WithExpression(fields[3], lhs + "<" + rhs); var beanOne = new SupportBean(); one.Invoke(beanOne); builder.WithAssertion(beanOne).Expect(fields, false, false, true, true); var beanTwo = new SupportBean(); two.Invoke(beanTwo); builder.WithAssertion(beanTwo).Expect(fields, true, false, true, false); var beanThree = new SupportBean(); three.Invoke(beanThree); builder.WithAssertion(beanThree).Expect(fields, true, true, false, false); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container"); builder.WithExpression(fields[0], "Contained.toMap(c => Id, d => P00)"); builder.WithExpression(fields[1], "Contained.toMap((c, index) => Id || '_' || Convert.ToString(index), (d, index) => P00 + 10*index)"); builder.WithExpression( fields[2], "Contained.toMap((c, index, size) => Id || '_' || Convert.ToString(index) || '_' || Convert.ToString(size), (d, index, size) => P00 + 10*index + 100*size)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(IDictionary <object, object>))); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E3,12", "E2,5")) .Verify("c0", val => CompareMap(val, "E1,E3,E2", 1, 12, 5)) .Verify("c1", val => CompareMap(val, "E1_0,E3_1,E2_2", 1, 22, 25)) .Verify("c2", val => CompareMap(val, "E1_0_3,E3_1_3,E2_2_3", 301, 322, 325)); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E3,4", "E2,7", "E1,2")) .Verify("c0", val => CompareMap(val, "E1,E3,E2", 2, 4, 7)) .Verify("c1", val => CompareMap(val, "E1_0,E3_1,E2_2,E1_3", 1, 14, 27, 32)) .Verify("c2", val => CompareMap(val, "E1_0_4,E3_1_4,E2_2_4,E1_3_4", 401, 414, 427, 432)); builder.WithAssertion(new SupportBean_ST0_Container(Collections.SingletonList(new SupportBean_ST0(null, null)))) .Verify("c0", val => CompareMap(val, "E1,E2,E3", null, null, null)) .Verify("c1", val => CompareMap(val, "E1,E2,E3", null, null, null)) .Verify("c2", val => CompareMap(val, "E1,E2,E3", null, null, null)); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.toMap(k => k, v => extractNum(v))"); builder.WithExpression(fields[1], "Strvals.toMap((k, i) => k || '_' || Convert.ToString(i), (v, idx) => extractNum(v) + 10*idx)"); builder.WithExpression( fields[2], "Strvals.toMap((k, i, s) => k || '_' || Convert.ToString(i) || '_' || Convert.ToString(s), (v, idx, sz) => extractNum(v) + 10*idx + 100*sz)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(IDictionary <object, object>))); builder.WithAssertion(SupportCollection.MakeString("E2,E1,E3")) .Verify("c0", val => CompareMap(val, "E1,E2,E3", 1, 2, 3)) .Verify("c1", val => CompareMap(val, "E1_1,E2_0,E3_2", 11, 2, 23)) .Verify("c2", val => CompareMap(val, "E1_1_3,E2_0_3,E3_2_3", 311, 302, 323)); builder.WithAssertion(SupportCollection.MakeString("E1")) .Verify("c0", val => CompareMap(val, "E1", 1)) .Verify("c1", val => CompareMap(val, "E1_0", 1)) .Verify("c2", val => CompareMap(val, "E1_0_1", 101)); builder.WithAssertion(SupportCollection.MakeString(null)) .Verify("c0", Assert.IsNull) .Verify("c1", Assert.IsNull) .Verify("c2", Assert.IsNull); builder.WithAssertion(SupportCollection.MakeString("")) .Verify("c0", val => CompareMap(val, "")) .Verify("c1", val => CompareMap(val, "")) .Verify("c2", val => CompareMap(val, "")); builder.Run(env); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1,c2".SplitCsv(); var builder = new SupportEvalBuilder("SupportCollection"); builder.WithExpression(fields[0], "Strvals.where(x => x not like '%1%')"); builder.WithExpression(fields[1], "Strvals.where((x, i) => x not like '%1%' and i >= 1)"); builder.WithExpression(fields[2], "Strvals.where((x, i, s) => x not like '%1%' and i >= 1 and s >= 3)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection<object>))); builder.WithAssertion(SupportCollection.MakeString("E1,E2,E3")) .Verify("c0", val => AssertValuesArrayScalar(val, "E2", "E3")) .Verify("c1", val => AssertValuesArrayScalar(val, "E2", "E3")) .Verify("c2", val => AssertValuesArrayScalar(val, "E2", "E3")); builder.WithAssertion(SupportCollection.MakeString("E4,E2,E1")) .Verify("c0", val => AssertValuesArrayScalar(val, "E4", "E2")) .Verify("c1", val => AssertValuesArrayScalar(val, "E2")) .Verify("c2", val => AssertValuesArrayScalar(val, "E2")); builder.WithAssertion(SupportCollection.MakeString("")) .Verify("c0", val => AssertValuesArrayScalar(val)) .Verify("c1", val => AssertValuesArrayScalar(val)) .Verify("c2", val => AssertValuesArrayScalar(val)); builder.WithAssertion(SupportCollection.MakeString("E4,E2")) .Verify("c0", val => AssertValuesArrayScalar(val, "E4", "E2")) .Verify("c1", val => AssertValuesArrayScalar(val, "E2")) .Verify("c2", val => AssertValuesArrayScalar(val)); builder.Run(env); }
public void Run(RegressionEnvironment env) { string[] fields = "c0".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container"); builder.WithExpression(fields[0], "Contained.reverse()"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,9", "E3,1")) .Verify("c0", val => AssertST0Id(val, "E3,E2,E1")); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E2,9", "E1,1")) .Verify("c0", val => AssertST0Id(val, "E1,E2")); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1")) .Verify("c0", val => AssertST0Id(val, "E1")); builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()) .Verify("c0", val => AssertST0Id(val, null)); builder.WithAssertion(SupportBean_ST0_Container.Make2Value()) .Verify("c0", val => AssertST0Id(val, "")); builder.Run(env); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1,c2,c3,c4,c5,c6,c7".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean_Container"); builder.WithExpression(fields[0], "Beans.average(x => IntBoxed)"); builder.WithExpression(fields[1], "Beans.average(x => DoubleBoxed)"); builder.WithExpression(fields[2], "Beans.average(x => LongBoxed)"); builder.WithExpression(fields[3], "Beans.average(x => DecimalBoxed)"); builder.WithExpression(fields[4], "Beans.average( (x, i) => IntBoxed + i*10)"); builder.WithExpression(fields[5], "Beans.average( (x, i) => DecimalBoxed + i*10)"); builder.WithExpression(fields[6], "Beans.average( (x, i, s) => IntBoxed + i*10 + s*100)"); builder.WithExpression(fields[7], "Beans.average( (x, i, s) => DecimalBoxed + i*10 + s*100)"); builder.WithStatementConsumer( stmt => AssertTypes( stmt.EventType, fields, new[] { typeof(double?), typeof(double?), typeof(double?), typeof(decimal?), typeof(double?), typeof(decimal?), typeof(double?), typeof(decimal?) })); builder.WithAssertion(new SupportBean_Container(null)) .Expect(fields, null, null, null, null, null, null, null, null); builder.WithAssertion(new SupportBean_Container(EmptyList <SupportBean> .Instance)) .Expect(fields, null, null, null, null, null, null, null, null); var listOne = new List <SupportBean>() { Make(2, 3d, 4L, 5) }; builder.WithAssertion(new SupportBean_Container(listOne)) .Expect(fields, 2d, 3d, 4d, 5.0m, 2d, 5.0m, 102d, 105.0m); var listTwo = new List <SupportBean>() { Make(2, 3d, 4L, 5), Make(4, 6d, 8L, 10) }; builder.WithAssertion(new SupportBean_Container(listTwo)) .Expect( fields, (2 + 4) / 2d, (3d + 6d) / 2d, (4L + 8L) / 2d, (5m + 10m) / 2m, (2 + 14) / 2d, (5m + 20m) / 2m, (202 + 214) / 2d, (205m + 220m) / 2m); builder.Run(env); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean").WithExpressions(fields, "LongBoxed % IntBoxed", "IntPrimitive % IntBoxed"); builder.WithAssertion(MakeBoxedEvent(5, 1L, 1)).Expect(fields, 0L, 0); builder.WithAssertion(MakeBoxedEvent(5, 2L, 3)).Expect(fields, 2L, 2); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container"); builder.WithExpression(fields[0], "Contained.selectFrom( (v, i) => new {v0=v.Id,v1=i})"); builder.WithExpression(fields[1], "Contained.selectFrom( (v, i, s) => new {v0=v.Id,v1=i + 100*s})"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportBean_ST0_Container.Make3Value("E1,12,0", "E2,11,0", "E3,2,0")) .Verify( fields[0], value => AssertRows( value, new object[][] { new object[] { "E1", 0 }, new object[] { "E2", 1 }, new object[] { "E3", 2 } })) .Verify( fields[1], value => AssertRows( value, new object[][] { new object[] { "E1", 300 }, new object[] { "E2", 301 }, new object[] { "E3", 302 } })); builder.WithAssertion(SupportBean_ST0_Container.Make3Value("E4,0,1")) .Verify( fields[0], value => AssertRows( value, new object[][] { new object[] { "E4", 0 } })) .Verify( fields[1], value => AssertRows( value, new object[][] { new object[] { "E4", 100 } })); builder.WithAssertion(SupportBean_ST0_Container.Make3ValueNull()) .Verify(fields[0], value => AssertRows(value, null)) .Verify(fields[1], value => AssertRows(value, null)); builder.WithAssertion(SupportBean_ST0_Container.Make3Value()) .Verify(fields[0], value => AssertRows(value, new object[0][])) .Verify(fields[1], value => AssertRows(value, new object[0][])); builder.Run(env); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1,c2,c3,c4,c5,c6,c7".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean") .WithExpression(fields[0], "cast(TheString as string)") .WithExpression(fields[1], "cast(IntBoxed, int)") .WithExpression(fields[2], "cast(FloatBoxed, System.Single)") .WithExpression(fields[3], "cast(TheString, System.String)") .WithExpression(fields[4], "cast(IntPrimitive, System.Int32)") .WithExpression(fields[5], "cast(IntPrimitive, long)") .WithExpression(fields[6], "cast(IntPrimitive, System.Object)") .WithExpression(fields[7], "cast(FloatBoxed, long)"); builder.WithStatementConsumer( stmt => { var type = stmt.EventType; Assert.AreEqual(typeof(string), type.GetPropertyType("c0")); Assert.AreEqual(typeof(int?), type.GetPropertyType("c1")); Assert.AreEqual(typeof(float?), type.GetPropertyType("c2")); Assert.AreEqual(typeof(string), type.GetPropertyType("c3")); Assert.AreEqual(typeof(int?), type.GetPropertyType("c4")); Assert.AreEqual(typeof(long?), type.GetPropertyType("c5")); Assert.AreEqual(typeof(object), type.GetPropertyType("c6")); Assert.AreEqual(typeof(long?), type.GetPropertyType("c7")); }); var bean = new SupportBean("abc", 100); bean.FloatBoxed = 9.5f; bean.IntBoxed = 3; builder.WithAssertion(bean).Expect(fields, "abc", 3, 9.5f, "abc", 100, 100L, 100, 9L); bean = new SupportBean(null, 100); bean.FloatBoxed = null; bean.IntBoxed = null; builder.WithAssertion(bean).Expect(fields, null, null, null, null, 100, 100L, 100, null); builder.Run(env); env.UndeployAll(); // test cast with chained and null var epl = "@Name('s0') select" + " cast(One as " + typeof(SupportBean).FullName + ").GetTheString() as t0," + " cast(null, " + typeof(SupportBean).FullName + ") as t1" + " from SupportBeanObject"; env.CompileDeploy(epl).AddListener("s0"); env.SendEventBean(new SupportBeanObject(new SupportBean("E1", 1))); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), "t0,t1".SplitCsv(), "E1", null); Assert.AreEqual(typeof(SupportBean), env.Statement("s0").EventType.GetPropertyType("t1")); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean") .WithExpressions(fields, "IntPrimitive=LongPrimitive", "IntPrimitive is LongPrimitive"); builder.WithAssertion(MakeBean(1, 1L)).Expect(fields, true, true); builder.WithAssertion(MakeBean(1, 2L)).Expect(fields, false, false); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { string[] fields = "c0,c1,c2,c3,c4,c5".SplitCsv(); SupportEvalBuilder builder = new SupportEvalBuilder("SupportBean_ST0_Container"); builder.WithExpression(fields[0], "Contained.take(2)"); builder.WithExpression(fields[1], "Contained.take(1)"); builder.WithExpression(fields[2], "Contained.take(0)"); builder.WithExpression(fields[3], "Contained.take(-1)"); builder.WithExpression(fields[4], "Contained.takeLast(2)"); builder.WithExpression(fields[5], "Contained.takeLast(1)"); builder.WithStatementConsumer(stmt => AssertTypesAllSame(stmt.EventType, fields, typeof(ICollection <object>))); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2", "E3,3")) .Verify("c0", val => AssertST0Id(val, "E1,E2")) .Verify("c1", val => AssertST0Id(val, "E1")) .Verify("c2", val => AssertST0Id(val, "")) .Verify("c3", val => AssertST0Id(val, "")) .Verify("c4", val => AssertST0Id(val, "E2,E3")) .Verify("c5", val => AssertST0Id(val, "E3")); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1", "E2,2")) .Verify("c0", val => AssertST0Id(val, "E1,E2")) .Verify("c1", val => AssertST0Id(val, "E1")) .Verify("c2", val => AssertST0Id(val, "")) .Verify("c3", val => AssertST0Id(val, "")) .Verify("c4", val => AssertST0Id(val, "E1,E2")) .Verify("c5", val => AssertST0Id(val, "E2")); builder.WithAssertion(SupportBean_ST0_Container.Make2Value("E1,1")) .Verify("c0", val => AssertST0Id(val, "E1")) .Verify("c1", val => AssertST0Id(val, "E1")) .Verify("c2", val => AssertST0Id(val, "")) .Verify("c3", val => AssertST0Id(val, "")) .Verify("c4", val => AssertST0Id(val, "E1")) .Verify("c5", val => AssertST0Id(val, "E1")); SupportEvalAssertionBuilder assertionEmpty = builder.WithAssertion(SupportBean_ST0_Container.Make2Value()); foreach (string field in fields) { assertionEmpty.Verify(field, val => AssertST0Id(val, "")); } SupportEvalAssertionBuilder assertionNull = builder.WithAssertion(SupportBean_ST0_Container.Make2ValueNull()); foreach (string field in fields) { assertionNull.Verify(field, val => AssertST0Id(val, null)); } builder.Run(env); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1,c2".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean_S0") .WithExpressions(fields, "P00 = P01", "Id = Id", "P02 is not null"); builder.WithAssertion(new SupportBean_S0(1, "a", "a", "a")).Expect(fields, true, true, true); builder.WithAssertion(new SupportBean_S0(1, "a", "b", null)).Expect(fields, false, true, false); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var fields = "c0,c1".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean") .WithExpressions(fields, "TheString like 'A%'", "IntPrimitive like '1%'"); builder.WithAssertion(new SupportBean("Bxx", 0)).Expect(fields, false, false); builder.WithAssertion(new SupportBean("Ayyy", 100)).Expect(fields, true, true); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var fields = "c0".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean_S0") .WithExpressions(fields, "P00 regexp '\\\\w*-ABC'"); builder.WithAssertion(new SupportBean_S0(-1, "TBT-ABC")).Expect(fields, true); builder.WithAssertion(new SupportBean_S0(-1, "TBT-BC")).Expect(fields, false); builder.Run(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var fields = "c0".SplitCsv(); var builder = new SupportEvalBuilder("SupportBean").WithExpressions(fields, "IntPrimitive/IntBoxed") .WithStatementConsumer(stmt => Assert.AreEqual(typeof(double?), stmt.EventType.GetPropertyType("c0"))); builder.WithAssertion(MakeEvent(100, 3)).Expect(fields, 100 / 3d); builder.WithAssertion(MakeEvent(100, null)).Expect(fields, new object[] {null}); builder.WithAssertion(MakeEvent(100, 0)).Expect(fields, double.PositiveInfinity); builder.WithAssertion(MakeEvent(-5, 0)).Expect(fields, double.NegativeInfinity); builder.Run(env); env.UndeployAll(); }