public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { long count = (Long) countEvents.iterator().next().get("size"); log.info(".update Info, error rate in the last 10 minutes is " + count); } });
private static void tryUnsupportedIterator(EPStatement stmt) { try { stmt.iterator(); fail(); } catch (UnsupportedOperationException ex) { assertEquals("Iteration over a unidirectional join is not supported", ex.getMessage()); } } }
private void assertValues(RegressionEnvironment env, final String group, Object[][] expected) { Iterator<EventBean> it = env.statement("table").iterator(new ContextPartitionSelectorSegmented() { public List<Object[]> getPartitionKeys() { return Collections.singletonList(new Object[]{group}); } }); EPAssertionUtil.assertPropsPerRowAnyOrder(it, "theString,intPrimitive".split(","), expected); } }
private static void assertResults(EPStatement stmt, String[] fields, Object[] values) { EventBean event = stmt.iterator().next(); Map map = (Map) event.get("varagg"); EPAssertionUtil.assertPropsMap(map, fields, values); }
private void checkMeanIterator(RegressionEnvironment env, double meanExpected) { Iterator<EventBean> iterator = env.statement("s0").iterator(); checkValue(iterator.next(), meanExpected); assertTrue(!iterator.hasNext()); }
public static Map<String, Integer> getScores(EPRuntime runtime) { EPStatement stmt = runtime.getDeploymentService().getStatement("trivia", "Score window"); Map<String, Integer> result = new LinkedHashMap<String, Integer>(); for (Iterator<EventBean> it = stmt.iterator(); it.hasNext(); ) { EventBean next = it.next(); String playerId = (String) next.get("playerId"); Integer score = (Integer) next.get("score"); result.put(playerId, score); } return result; }
private static void assertCount(EPStatement stmt, long count) { assertEquals(count, EPAssertionUtil.iteratorCount(stmt.iterator())); }
private static void assertCount(EPStatement stmt, long count) { Assert.assertEquals(count, EPAssertionUtil.iteratorCount(stmt.iterator())); } }
private static void runAssertionIterateCreateTable(RegressionEnvironment env, Object[][] expectedType, Object[] rowValues, EPStatement stmtCreate) { assertEventTypeAndEvent(stmtCreate.getEventType(), expectedType, stmtCreate.iterator().next().getUnderlying(), rowValues); }
private static void assertRowsNamedWindow(RegressionEnvironment env, String deploymentId, String ident) { EPAssertionUtil.assertPropsPerRow(env.runtime().getDeploymentService().getStatement(deploymentId, "create").iterator(), "col1,myident".split(","), new Object[][]{{"E1", ident}, {"E2", ident}}); } }
public void run(RegressionEnvironment env) { String epl = "@name('s0') select * from SupportBean#unique(Math.abs(intPrimitive))"; env.compileDeployAddListenerMileZero(epl, "s0"); sendSupportBean(env, "E1", 10); sendSupportBean(env, "E2", -10); sendSupportBean(env, "E3", -5); sendSupportBean(env, "E4", 5); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), "theString".split(","), new Object[][]{{"E2"}, {"E4"}}); env.undeployAll(); } }
public void run(RegressionEnvironment env) { String[] fields = new String[]{"k1", "v1"}; String statementText = "@name('s0') select distinct * from MyMapTypeKVDistinct#keepall"; env.compileDeploy(statementText).addListener("s0"); sendMapEvent(env, "E1", 1); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), fields, new Object[][]{{"E1", 1}}); sendMapEvent(env, "E2", 2); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), fields, new Object[][]{{"E1", 1}, {"E2", 2}}); env.milestone(0); sendMapEvent(env, "E1", 1); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), fields, new Object[][]{{"E1", 1}, {"E2", 2}}); env.undeployAll(); } }
private void runAssertionInvalidPropertyExpression(RegressionEnvironment env) { String epl = "@name('s0') @IterableUnbound select * from SupportBean"; env.compileDeploy(epl); env.sendEventBean(new SupportBean()); EventBean theEvent = env.statement("s0").iterator().next(); String exceptionText = getSyntaxExceptionProperty("", theEvent); assertTrue(exceptionText.startsWith("Property named '' is not a valid property name for this type")); exceptionText = getSyntaxExceptionProperty("-", theEvent); assertTrue(exceptionText.startsWith("Property named '-' is not a valid property name for this type")); exceptionText = getSyntaxExceptionProperty("a[]", theEvent); assertTrue(exceptionText.startsWith("Property named 'a[]' is not a valid property name for this type")); env.undeployAll(); }
public static void tryInvalidIterate(RegressionEnvironment env, String epl, String message) { env.compileDeploy(epl); try { env.statement("s0").iterator(); fail(); } catch (UnsupportedOperationException ex) { assertMessage(ex, message); } env.undeployAll(); }
public void run(RegressionEnvironment env) { env.advanceTime(startTime); String[] fields = "theString".split(","); String epl = "@name('s0') select * from SupportBean#time(" + size + ")"; env.compileDeploy(epl).addListener("s0"); env.sendEventBean(new SupportBean("E1", 1)); env.advanceTime(flipTime - 1); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), fields, new Object[][]{{"E1"}}); env.advanceTime(flipTime); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), fields, null); env.undeployAll(); } }
private static void checkNew(RegressionEnvironment env, long countE, double sumE, double avgE, double stdevpaE, double stdevE, double varianceE) { Iterator<EventBean> iterator = env.statement("s0").iterator(); checkValues(iterator.next(), false, false, countE, sumE, avgE, stdevpaE, stdevE, varianceE); assertFalse(iterator.hasNext()); assertTrue(env.listener("s0").getLastNewData().length == 1); EventBean childViewValues = env.listener("s0").getLastNewData()[0]; checkValues(childViewValues, false, false, countE, sumE, avgE, stdevpaE, stdevE, varianceE); env.listener("s0").reset(); }
private void checkValue(RegressionEnvironment env, double avgE) { Iterator<EventBean> iterator = env.statement("s0").iterator(); checkValue(iterator.next(), avgE); assertTrue(!iterator.hasNext()); assertTrue(env.listener("s0").getLastNewData().length == 1); EventBean listenerValues = env.listener("s0").getLastNewData()[0]; checkValue(listenerValues, avgE); env.listener("s0").reset(); }
public void run(RegressionEnvironment env) { String[] fields = "c0,c1".split(","); String epl = "@name('s0') @IterableUnbound select theString as c0, sum(intPrimitive) as c1 from SupportBean group by theString"; env.compileDeploy(epl).addListener("s0"); env.sendEventBean(new SupportBean("E1", 10)); env.milestone(0); env.sendEventBean(new SupportBean("E2", 20)); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), fields, new Object[][]{{"E1", 10}, {"E2", 20}}); env.milestone(1); env.sendEventBean(new SupportBean("E1", 11)); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("s0").iterator(), fields, new Object[][]{{"E1", 21}, {"E2", 20}}); env.undeployAll(); } }
public void run(RegressionEnvironment env) { sendCurrentTime(env, "2002-02-01T09:00:00.000"); env.compileDeployAddListenerMileZero("@name('s0') select * from SupportBean#firsttime(1 month)", "s0"); sendCurrentTime(env, "2002-02-15T09:00:00.000"); env.sendEventBean(new SupportBean("E1", 1)); sendCurrentTimeWithMinus(env, "2002-03-01T09:00:00.000", 1); env.sendEventBean(new SupportBean("E2", 2)); sendCurrentTime(env, "2002-03-01T09:00:00.000"); env.sendEventBean(new SupportBean("E3", 3)); EPAssertionUtil.assertPropsPerRow(env.statement("s0").iterator(), "theString".split(","), new Object[][]{{"E1"}, {"E2"}}); env.undeployAll(); } }
public void run(RegressionEnvironment env) { RegressionPath path = new RegressionPath(); String[] fields = "p0,p1".split(","); env.compileDeploy("@Name('TheTable') create table MyTableUPD as (p0 string primary key, p1 string, thesum sum(int))", path); env.compileDeploy("into table MyTableUPD select theString, sum(intPrimitive) as thesum from SupportBean group by theString", path); env.sendEventBean(new SupportBean("E1", 1)); env.sendEventBean(new SupportBean("E2", 2)); env.compileExecuteFAF("update MyTableUPD set p1 = 'ABC'", path); EPAssertionUtil.assertPropsPerRowAnyOrder(env.statement("TheTable").iterator(), fields, new Object[][]{{"E1", "ABC"}, {"E2", "ABC"}}); env.undeployAll(); } }