components/src/test/java/eu/internetofus/common/components/task_manager/WeNetTaskManagerTestCase.java
/**
   * Should create, retrieve, update, merge and delete a task type.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should create, retrieve, update, merge and delete a task type.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should create retrieve update merge and delete a task type . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldCreateRetrieveUpdateMergeAndDeleteTaskType(final Vertx vertx, final VertxTestContext testContext) {
    new TaskTypeTest().createModelExample(1, vertx, testContext).onSuccess(taskType -> {
      taskType.id = null;
      final var service = this.createComponentProxy(vertx);
      testContext.assertComplete(service.createTaskType(taskType)).onSuccess(createdTaskType -> {
        final var id = createdTaskType.id;
        testContext.assertComplete(service.retrieveTaskType(id)).onSuccess(retrieve -> testContext.verify(() -> {
          assertThat(createdTaskType).isEqualTo(retrieve);
          new TaskTypeTest().createModelExample(2, vertx, testContext).onSuccess(taskTypeToUpdate -> {
            testContext.assertComplete(service.updateTaskType(id, taskTypeToUpdate))
                .onSuccess(updatedTaskType -> testContext.verify(() -> {
                  taskTypeToUpdate.id = createdTaskType.id;
                  taskTypeToUpdate._creationTs = createdTaskType._creationTs;
                  taskTypeToUpdate._lastUpdateTs = updatedTaskType._lastUpdateTs;
                  assertThat(updatedTaskType).isEqualTo(taskTypeToUpdate);
                  final var taskTypeToMerge = new TaskType();
                  taskTypeToMerge.attributes = new JsonObject().put("type", "object").put("properties",
                      new JsonObject().put("newStringAttribute", new JsonObject().put("type", "string")));
                  testContext.assertComplete(service.mergeTaskType(id, taskTypeToMerge))
                      .onSuccess(mergedTaskType -> testContext.verify(() -> {
                        taskTypeToUpdate._lastUpdateTs = mergedTaskType._lastUpdateTs;
                        taskTypeToUpdate.attributes.getJsonObject("properties").put("newStringAttribute",
                            new JsonObject().put("type", "string"));
                        assertThat(mergedTaskType).isEqualTo(taskTypeToUpdate);
                        testContext.assertComplete(service.deleteTaskType(id)).onSuccess(empty -> {
                          testContext.assertFailure(service.retrieveTaskType(id))
                              .onFailure(handler -> testContext.completeNow());
                        });
                      }));
                }));
          });
        }));
      });
    });
  }
@ Test public void shouldCreateRetrieveUpdateMergeAndDeleteTaskType ( final Vertx vertx , final VertxTestContext testContext ) { new TaskTypeTest ( ) . createModelExample ( 1 , vertx , testContext ) . onSuccess ( taskType -> { taskType . id = null ; final var service = this . createComponentProxy ( vertx ) ; testContext . assertComplete ( service . createTaskType ( taskType ) ) . onSuccess ( createdTaskType -> { final var id = createdTaskType . id ; testContext . assertComplete ( service . retrieveTaskType ( id ) ) . onSuccess ( retrieve -> testContext . verify ( ( ) -> { assertThat ( createdTaskType ) . isEqualTo ( retrieve ) ; new TaskTypeTest ( ) . createModelExample ( 2 , vertx , testContext ) . onSuccess ( taskTypeToUpdate -> { testContext . assertComplete ( service . updateTaskType ( id , taskTypeToUpdate ) ) . onSuccess ( updatedTaskType -> testContext . verify ( ( ) -> { taskTypeToUpdate . id = createdTaskType . id ; taskTypeToUpdate . _creationTs = createdTaskType . _creationTs ; taskTypeToUpdate . _lastUpdateTs = updatedTaskType . _lastUpdateTs ; assertThat ( updatedTaskType ) . isEqualTo ( taskTypeToUpdate ) ; final var taskTypeToMerge = new TaskType ( ) ; taskTypeToMerge . attributes = new JsonObject ( ) . put ( "type" , "object" ) . put ( "properties" , new JsonObject ( ) . put ( "newStringAttribute" , new JsonObject ( ) . put ( "type" , "string" ) ) ) ; testContext . assertComplete ( service . mergeTaskType ( id , taskTypeToMerge ) ) . onSuccess ( mergedTaskType -> testContext . verify ( ( ) -> { taskTypeToUpdate . _lastUpdateTs = mergedTaskType . _lastUpdateTs ; taskTypeToUpdate . attributes . getJsonObject ( "properties" ) . put ( "newStringAttribute" , new JsonObject ( ) . put ( "type" , "string" ) ) ; assertThat ( mergedTaskType ) . isEqualTo ( taskTypeToUpdate ) ; testContext . assertComplete ( service . deleteTaskType ( id ) ) . onSuccess ( empty -> { testContext . assertFailure ( service . retrieveTaskType ( id ) ) . onFailure ( handler -> testContext . completeNow ( ) ) ; } ) ; } ) ) ; } ) ) ; } ) ; } ) ) ; } ) ; } ) ; }
Should create, retrieve, update, merge and delete a task type.
Should create retrieve update merge and delete a task type .