components/src/test/java/eu/internetofus/common/components/task_manager/WeNetTaskManagerTestCase.java
/**
   * Should create, retrieve, update, merge and delete a task.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should create, retrieve, update, merge and delete a task.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should create retrieve update merge and delete a task . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldCreateRetrieveUpdateMergeAndDeleteTask(final Vertx vertx, final VertxTestContext testContext) {
    new TaskTest().createModelExample(1, vertx, testContext).onSuccess(task -> {
      task.id = null;
      final var service = this.createComponentProxy(vertx);
      testContext.assertComplete(service.createTask(task)).onSuccess(createdTask -> {
        final var id = createdTask.id;
        testContext.assertComplete(service.retrieveTask(id)).onSuccess(retrieve -> testContext.verify(() -> {
          assertThat(createdTask).isEqualTo(retrieve);
          new TaskTest().createModelExample(2, vertx, testContext).onSuccess(taskToUpdate -> {
            testContext.assertComplete(service.updateTask(id, taskToUpdate))
                .onSuccess(updatedTask -> testContext.verify(() -> {
                  taskToUpdate.id = createdTask.id;
                  taskToUpdate._creationTs = createdTask._creationTs;
                  taskToUpdate._lastUpdateTs = updatedTask._lastUpdateTs;
                  assertThat(updatedTask).isEqualTo(taskToUpdate);
                  final var taskToMerge = new Task();
                  final var newAttributeValue = UUID.randomUUID().toString();
                  taskToMerge.attributes = new JsonObject().put("a_str", newAttributeValue);
                  testContext.assertComplete(service.mergeTask(id, taskToMerge))
                      .onSuccess(mergedTask -> testContext.verify(() -> {
                        taskToUpdate._lastUpdateTs = mergedTask._lastUpdateTs;
                        taskToUpdate.attributes.put("a_str", newAttributeValue);
                        assertThat(mergedTask).isEqualTo(taskToUpdate);
                        testContext.assertComplete(service.deleteTask(id)).onSuccess(empty -> {
                          testContext.assertFailure(service.retrieveTask(id))
                              .onFailure(handler -> testContext.completeNow());
                        });
                      }));
                }));
          });
        }));
      });
    });
  }
@ Test public void shouldCreateRetrieveUpdateMergeAndDeleteTask ( final Vertx vertx , final VertxTestContext testContext ) { new TaskTest ( ) . createModelExample ( 1 , vertx , testContext ) . onSuccess ( task -> { task . id = null ; final var service = this . createComponentProxy ( vertx ) ; testContext . assertComplete ( service . createTask ( task ) ) . onSuccess ( createdTask -> { final var id = createdTask . id ; testContext . assertComplete ( service . retrieveTask ( id ) ) . onSuccess ( retrieve -> testContext . verify ( ( ) -> { assertThat ( createdTask ) . isEqualTo ( retrieve ) ; new TaskTest ( ) . createModelExample ( 2 , vertx , testContext ) . onSuccess ( taskToUpdate -> { testContext . assertComplete ( service . updateTask ( id , taskToUpdate ) ) . onSuccess ( updatedTask -> testContext . verify ( ( ) -> { taskToUpdate . id = createdTask . id ; taskToUpdate . _creationTs = createdTask . _creationTs ; taskToUpdate . _lastUpdateTs = updatedTask . _lastUpdateTs ; assertThat ( updatedTask ) . isEqualTo ( taskToUpdate ) ; final var taskToMerge = new Task ( ) ; final var newAttributeValue = UUID . randomUUID ( ) . toString ( ) ; taskToMerge . attributes = new JsonObject ( ) . put ( "a_str" , newAttributeValue ) ; testContext . assertComplete ( service . mergeTask ( id , taskToMerge ) ) . onSuccess ( mergedTask -> testContext . verify ( ( ) -> { taskToUpdate . _lastUpdateTs = mergedTask . _lastUpdateTs ; taskToUpdate . attributes . put ( "a_str" , newAttributeValue ) ; assertThat ( mergedTask ) . isEqualTo ( taskToUpdate ) ; testContext . assertComplete ( service . deleteTask ( id ) ) . onSuccess ( empty -> { testContext . assertFailure ( service . retrieveTask ( id ) ) . onFailure ( handler -> testContext . completeNow ( ) ) ; } ) ; } ) ) ; } ) ) ; } ) ; } ) ) ; } ) ; } ) ; }
Should create, retrieve, update, merge and delete a task.
Should create retrieve update merge and delete a task .