@Test void testAverage(Vertx vertx, VertxTestContext ctx) { EventBus bus = vertx.eventBus(); vertx.deployVerticle(new SensorData(), ctx.succeeding(id -> { bus.publish("sensor.updates", new JsonObject() .put("id", "a").put("temp", 20.0d)); bus.publish("sensor.updates", new JsonObject() .put("id", "b").put("temp", 22.0d)); bus.request("sensor.average", "", ctx.succeeding(reply -> ctx.verify(() -> { JsonObject json = (JsonObject) reply.body(); assertEquals(21.0d, (double) json.getDouble("average")); ctx.completeNow(); }))); })); }
private void average(Message<JsonObject> message) { double avg = lastValues.values().stream() .collect(Collectors.averagingDouble(Double::doubleValue)); JsonObject json = new JsonObject().put("average", avg); message.reply(json); }
SensorData extends AbstractVerticle { private void average(Message<JsonObject> message) { double avg = lastValues.values().stream() .collect(Collectors.averagingDouble(Double::doubleValue)); JsonObject json = new JsonObject().put("average", avg); message.reply(json); } }
SensorData extends AbstractVerticle { private void average(Message<JsonObject> message) { double avg = lastValues.values().stream() .collect(Collectors.averagingDouble(Double::doubleValue)); JsonObject json = new JsonObject().put("average", avg); message.reply(json); }  }
SensorData extends AbstractVerticle { private void average(Message<JsonObject> message) { double avg = lastValues.values().stream() .collect(Collectors.averagingDouble(Double::doubleValue)); JsonObject json = new JsonObject().put("average", avg); message.reply(json); }  @Override void start(); }
SensorData extends AbstractVerticle { private void average(Message<JsonObject> message) { double avg = lastValues.values().stream() .collect(Collectors.averagingDouble(Double::doubleValue)); JsonObject json = new JsonObject().put("average", avg); message.reply(json); }  @Override void start();  }