private static void assertSelectResultType(EPStatement stmt) { Assert.assertEquals(String.class, stmt.getEventType().getPropertyType("symbol")); Assert.assertEquals(Long.class, stmt.getEventType().getPropertyType("volume")); Assert.assertEquals(Double.class, stmt.getEventType().getPropertyType("mySum")); }
public void run(RegressionEnvironment env) { env.compileDeploy("@name('s0') " + EPL).addListener("s0"); EventType type = env.statement("s0").getEventType(); TestCase.assertEquals(Byte.class, type.getPropertyType("myFirstProperty")); TestCase.assertEquals(Short.class, type.getPropertyType("mySecondProperty")); TestCase.assertEquals(Integer.class, type.getPropertyType("myThirdProperty")); TestCase.assertEquals(Long.class, type.getPropertyType("myFourthProperty")); TestCase.assertEquals(Boolean.class, type.getPropertyType("myFifthProperty")); runBitWiseOperators(env); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String epl = "@name('s0') select " + "count(*, group_by:(theString, intPrimitive)), " + "count(group_by:theString, *) " + "from SupportBean"; env.compileDeploy(epl); assertEquals("count(*,group_by:(theString,intPrimitive))", env.statement("s0").getEventType().getPropertyNames()[0]); assertEquals("count(group_by:theString,*)", env.statement("s0").getEventType().getPropertyNames()[1]); env.undeployAll(); } }
private static void tryInBoolean(RegressionEnvironment env, String expr, Boolean[] input, boolean[] result) { String epl = "@name('s0') select " + expr + " as result from " + SupportBean.class.getSimpleName(); env.compileDeploy(epl).addListener("s0"); assertEquals(Boolean.class, env.statement("s0").getEventType().getPropertyType("result")); for (int i = 0; i < input.length; i++) { sendSupportBeanEvent(env, input[i]); EventBean theEvent = env.listener("s0").assertOneGetNewAndReset(); assertEquals("Wrong result for " + input[i], result[i], theEvent.get("result")); } env.undeployAll(); }
private static void tryPrecedenceNoColumnName(RegressionEnvironment env, String selectColumn, String expectedColumn, Object value) { String epl = "@name('s0') select " + selectColumn + " from SupportBean"; env.compileDeploy(epl).addListener("s0"); if (!env.statement("s0").getEventType().getPropertyNames()[0].equals(expectedColumn)) { fail("Expected '" + expectedColumn + "' but was " + env.statement("s0").getEventType().getPropertyNames()[0]); } env.sendEventBean(new SupportBean("E1", 1)); EventBean event = env.listener("s0").assertOneGetNewAndReset(); Assert.assertEquals(value, event.get(expectedColumn)); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String epl = "@name('s0') select coalesce(longBoxed,intBoxed,shortBoxed) as result" + " from SupportBean#length(1000)"; env.eplToModelCompileDeploy(epl).addListener("s0"); assertEquals(Long.class, env.statement("s0").getEventType().getPropertyType("result")); tryCoalesceLong(env); env.undeployAll(); } }
public void run(RegressionEnvironment env) { setupStatement(env, ""); EventType type = env.statement("s0").getEventType(); assertEquals(SupportBean_S0.class, type.getPropertyType("s0")); assertEquals(SupportBean_S1.class, type.getPropertyType("s1")); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String epl = "@name('s0') select case" + " when symbol=\"GE\" then volume" + " when symbol=\"DELL\" then sum(price) " + "end as p1 from SupportMarketDataBean#length(10)"; env.eplToModelCompileDeploy(epl).addListener("s0").milestone(0); assertEquals(Double.class, env.statement("s0").getEventType().getPropertyType("p1")); runCaseSyntax1Sum(env); env.undeployAll(); } }
private void tryAssertionScalarReturn(RegressionEnvironment env, String epl) { env.compileDeploy(epl).addListener("s0"); LambdaAssertionUtil.assertTypes(env.statement("s0").getEventType(), "val1".split(","), new Class[]{Collection.class}); env.sendEventBean(SupportCollection.makeString("E1,E2,E3,E4")); LambdaAssertionUtil.assertValuesArrayScalar(env.listener("s0"), "val1", "E3", "E4"); env.listener("s0").reset(); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String epl = "@name('s0') select theString.* from SupportBean#length(3) as theString"; env.compileDeploy(epl).addListener("s0"); EventType type = env.statement("s0").getEventType(); assertTrue(type.getPropertyNames().length > 10); Assert.assertEquals(SupportBean.class, type.getUnderlyingType()); Object theEvent = sendBeanEvent(env, "E1"); TestCase.assertSame(theEvent, env.listener("s0").assertOneGetNewAndReset().getUnderlying()); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String epl = "@name('s0') select cast(theString, int) as t0 from SupportBean"; env.compileDeploy(epl).addListener("s0"); assertEquals(Integer.class, env.statement("s0").getEventType().getPropertyType("t0")); env.sendEventBean(new SupportBean("12", 1)); EPAssertionUtil.assertProps(env.listener("s0").assertOneGetNewAndReset(), "t0".split(","), new Object[]{12}); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String eplFragment = "@name('s0') select sales.where(x => x.cost > 1000).min(y => y.buyer.age) as val from PersonSales"; env.compileDeploy(eplFragment).addListener("s0"); LambdaAssertionUtil.assertTypes(env.statement("s0").getEventType(), "val".split(","), new Class[]{Integer.class}); PersonSales bean = PersonSales.make(); env.sendEventBean(bean); assertEquals(50, env.listener("s0").assertOneGetNewAndReset().get("val")); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String stmtText = "@name('s0') select (select * from SupportBean_S1#length(1000)) as events1 from SupportBean_S1"; env.eplToModelCompileDeploy(stmtText).addListener("s0"); EventType type = env.statement("s0").getEventType(); TestCase.assertEquals(SupportBean_S1.class, type.getPropertyType("events1")); Object theEvent = new SupportBean_S1(-1, "Y"); env.sendEventBean(theEvent); EventBean result = env.listener("s0").assertOneGetNewAndReset(); TestCase.assertSame(theEvent, result.get("events1")); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String stmtText = "@name('s0') select (select * from SupportBean_S1#length(1000)) as events1 from SupportBean_S1"; env.compileDeploy(stmtText).addListener("s0"); EventType type = env.statement("s0").getEventType(); TestCase.assertEquals(SupportBean_S1.class, type.getPropertyType("events1")); Object theEvent = new SupportBean_S1(-1, "Y"); env.sendEventBean(theEvent); EventBean result = env.listener("s0").assertOneGetNewAndReset(); TestCase.assertSame(theEvent, result.get("events1")); env.undeployAll(); } }
public void run(RegressionEnvironment env) { RegressionPath path = new RegressionPath(); String stmtOneTxt = "@name('s1') insert into InZoneTwo select null as dummy from SupportBean"; env.compileDeploy(stmtOneTxt, path); assertTrue(env.statement("s1").getEventType().isProperty("dummy")); String stmtTwoTxt = "@name('s2') select dummy from InZoneTwo"; env.compileDeploy(stmtTwoTxt, path).addListener("s2"); env.sendEventBean(new SupportBean()); assertNull(env.listener("s2").assertOneGetNewAndReset().get("dummy")); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String caseSubExpr = "case intPrimitive when 1 then 0 end"; String epl = "@name('s0') select " + caseSubExpr + " from SupportBean#length(10)"; env.compileDeploy(epl).addListener("s0"); assertEquals(Integer.class, env.statement("s0").getEventType().getPropertyType(caseSubExpr)); sendSupportBeanEvent(env, 1); EventBean theEvent = env.listener("s0").getAndResetLastNewData()[0]; assertEquals(0, theEvent.get(caseSubExpr)); env.undeployAll(); } }
public void run(RegressionEnvironment env) { setUpMinMax(env); EventType type = env.statement("s0").getEventType(); Assert.assertEquals(Long.class, type.getPropertyType("myMax")); Assert.assertEquals(Long.class, type.getPropertyType("myMin")); Assert.assertEquals(Long.class, type.getPropertyType("myMinEx")); Assert.assertEquals(Long.class, type.getPropertyType("myMaxEx")); tryMinMaxWindowStats(env); env.undeployAll(); } }
public void run(RegressionEnvironment env) { sendTimer(env, 0); String stmtText = "@name('s0') select current_timestamp() as t0 from SupportBean"; env.eplToModelCompileDeploy(stmtText).addListener("s0").milestone(0); Assert.assertEquals(Long.class, env.statement("s0").getEventType().getPropertyType("t0")); sendTimer(env, 777); env.sendEventBean(new SupportBean()); EventBean theEvent = env.listener("s0").assertOneGetNewAndReset(); assertResults(theEvent, new Object[]{777L}); env.undeployAll(); } }
private static void runAssertionSubquerySelectStar(RegressionEnvironment env, RegressionPath path, Object[] rowValues, String epl) { env.compileDeploy(epl, path).addListener("s0"); assertEquals(Object[].class, env.statement("s0").getEventType().getPropertyType("mt")); env.sendEventBean(new SupportBean_S2(0)); EventBean event = env.listener("s0").assertOneGetNewAndReset(); assertEventUnd(event.get("mt"), rowValues); env.undeployModuleContaining("s0"); }
private static void runAssertionJoinSelectStreamName(RegressionEnvironment env, RegressionPath path, Object[][] expectedType, Object[] rowValues) { String joinEpl = "@name('s0') select mt from MyTable as mt, SupportBean_S2 where key = p20"; env.compileDeploy(joinEpl, path).addListener("s0"); assertEventType(env.statement("s0").getEventType().getFragmentType("mt").getFragmentType(), expectedType); env.sendEventBean(new SupportBean_S2(0, "G1")); EventBean event = env.listener("s0").assertOneGetNewAndReset(); assertEventTypeAndEvent(event.getEventType().getFragmentType("mt").getFragmentType(), expectedType, event.get("mt"), rowValues); env.undeployModuleContaining("s0"); }