components/src/test/java/eu/internetofus/common/components/service/WeNetServiceSimulatorTest.java
/**
   * Should create, retrieve and delete a app callbacks.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should create, retrieve and delete a app callbacks.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should create retrieve and delete a app callbacks . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldPostMessageToAppCallbacks(final Vertx vertx, final VertxTestContext testContext) {
    final var service = WeNetServiceSimulator.createProxy(vertx);
    testContext.assertComplete(service.createApp(new App())).onSuccess(created -> {
      final var message = new JsonObject().put("action", "Name of the action").put("users",
          new JsonArray().add("1").add("43").add("23"));
      final var client = createClientWithDefaultSession(vertx);
      testContext.assertComplete(client.postAbs(created.messageCallbackUrl).sendJson(message)).onSuccess(create -> {
        testContext.assertComplete(service.retrieveCallbacks(created.appId))
            .onSuccess(retrieve -> testContext.verify(() -> {
              assertThat(retrieve).isEqualTo(new JsonArray().add(message));
              testContext.assertComplete(service.deleteApp(created.appId))
                  .onSuccess(emptyApp -> testContext.completeNow());
            }));
      });
    });
  }
@ Test public void shouldPostMessageToAppCallbacks ( final Vertx vertx , final VertxTestContext testContext ) { final var service = WeNetServiceSimulator . createProxy ( vertx ) ; testContext . assertComplete ( service . createApp ( new App ( ) ) ) . onSuccess ( created -> { final var message = new JsonObject ( ) . put ( "action" , "Name of the action" ) . put ( "users" , new JsonArray ( ) . add ( "1" ) . add ( "43" ) . add ( "23" ) ) ; final var client = createClientWithDefaultSession ( vertx ) ; testContext . assertComplete ( client . postAbs ( created . messageCallbackUrl ) . sendJson ( message ) ) . onSuccess ( create -> { testContext . assertComplete ( service . retrieveCallbacks ( created . appId ) ) . onSuccess ( retrieve -> testContext . verify ( ( ) -> { assertThat ( retrieve ) . isEqualTo ( new JsonArray ( ) . add ( message ) ) ; testContext . assertComplete ( service . deleteApp ( created . appId ) ) . onSuccess ( emptyApp -> testContext . completeNow ( ) ) ; } ) ) ; } ) ; } ) ; }
Should create, retrieve and delete a app callbacks.
Should create retrieve and delete a app callbacks .