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 shouldCreateRetrieveAndDeleteAppCallbacks(final Vertx vertx, final VertxTestContext testContext) {
    final var service = WeNetServiceSimulator.createProxy(vertx);
    testContext.assertComplete(service.createApp(new App())).onSuccess(created -> {
      final var message1 = new JsonObject().put("action", "Name of the action").put("users",
          new JsonArray().add("1").add("43").add("23"));
      testContext.assertComplete(service.addCallBack(created.appId, message1)).onSuccess(create1 -> {
        testContext.assertComplete(service.retrieveCallbacks(created.appId))
            .onSuccess(retrieve -> testContext.verify(() -> {
              assertThat(retrieve).isEqualTo(new JsonArray().add(message1));
              final var message2 = new JsonObject().put("action", "Name of the action2").put("users",
                  new JsonArray().add("21").add("243").add("223"));
              testContext.assertComplete(service.addCallBack(created.appId, message2)).onSuccess(create2 -> {
                testContext.assertComplete(service.retrieveCallbacks(created.appId))
                    .onSuccess(retrieve2 -> testContext.verify(() -> {
                      assertThat(retrieve2).isEqualTo(new JsonArray().add(message1).add(message2));
                      testContext.assertComplete(service.deleteCallbacks(created.appId)).onSuccess(empty -> {
                        testContext.assertComplete(service.retrieveCallbacks(created.appId))
                            .onSuccess(retrieve3 -> testContext.verify(() -> {
                              assertThat(retrieve3).isEqualTo(new JsonArray());
                              testContext.assertComplete(service.deleteApp(created.appId))
                                  .onSuccess(emptyApp -> testContext.completeNow());
                            }));
                      });
                    }));
              });
            }));
      });
    });
  }
@ Test public void shouldCreateRetrieveAndDeleteAppCallbacks ( final Vertx vertx , final VertxTestContext testContext ) { final var service = WeNetServiceSimulator . createProxy ( vertx ) ; testContext . assertComplete ( service . createApp ( new App ( ) ) ) . onSuccess ( created -> { final var message1 = new JsonObject ( ) . put ( "action" , "Name of the action" ) . put ( "users" , new JsonArray ( ) . add ( "1" ) . add ( "43" ) . add ( "23" ) ) ; testContext . assertComplete ( service . addCallBack ( created . appId , message1 ) ) . onSuccess ( create1 -> { testContext . assertComplete ( service . retrieveCallbacks ( created . appId ) ) . onSuccess ( retrieve -> testContext . verify ( ( ) -> { assertThat ( retrieve ) . isEqualTo ( new JsonArray ( ) . add ( message1 ) ) ; final var message2 = new JsonObject ( ) . put ( "action" , "Name of the action2" ) . put ( "users" , new JsonArray ( ) . add ( "21" ) . add ( "243" ) . add ( "223" ) ) ; testContext . assertComplete ( service . addCallBack ( created . appId , message2 ) ) . onSuccess ( create2 -> { testContext . assertComplete ( service . retrieveCallbacks ( created . appId ) ) . onSuccess ( retrieve2 -> testContext . verify ( ( ) -> { assertThat ( retrieve2 ) . isEqualTo ( new JsonArray ( ) . add ( message1 ) . add ( message2 ) ) ; testContext . assertComplete ( service . deleteCallbacks ( created . appId ) ) . onSuccess ( empty -> { testContext . assertComplete ( service . retrieveCallbacks ( created . appId ) ) . onSuccess ( retrieve3 -> testContext . verify ( ( ) -> { assertThat ( retrieve3 ) . isEqualTo ( new JsonArray ( ) ) ; 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 .