components/src/test/java/eu/internetofus/common/components/task_manager/WeNetTaskManagerTestCase.java
/**
   * Should add transaction and message into a task.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should add transaction and message into a task.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should add transaction and message into a task . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldAddTransactionAndMessageIntoTask(final Vertx vertx, final VertxTestContext testContext) {
    new TaskTransactionTest().createModelExample(1, vertx, testContext).onSuccess(taskTransaction -> {
      taskTransaction.id = null;
      final var service = this.createComponentProxy(vertx);
      testContext.assertComplete(service.addTransactionIntoTask(taskTransaction.taskId, taskTransaction))
          .onSuccess(addedTransaction -> {
            testContext.assertComplete(service.retrieveTask(taskTransaction.taskId))
                .onSuccess(retrieve -> testContext.verify(() -> {
                  assertThat(retrieve.transactions).isNotEmpty().contains(addedTransaction);
                  final var message = new MessageTest().createModelExample(1);
                  message.appId = retrieve.appId;
                  message.receiverId = retrieve.requesterId;
                  testContext
                      .assertComplete(service.addMessageIntoTransaction(retrieve.id, addedTransaction.id, message))
                      .onSuccess(addedMessage -> {
                        testContext.assertComplete(service.retrieveTask(addedTransaction.taskId))
                            .onSuccess(retrieve2 -> testContext.verify(() -> {
                              assertThat(retrieve2.transactions).isNotEmpty();
                              final var transaction2 = retrieve2.transactions.get(0);
                              assertThat(transaction2.messages).isNotEmpty().contains(addedMessage);
                              testContext.assertComplete(service.deleteTask(addedTransaction.taskId))
                                  .onSuccess(empty -> testContext.completeNow());
                            }));
                      });
                }));
          });
    });
  }
@ Test public void shouldAddTransactionAndMessageIntoTask ( final Vertx vertx , final VertxTestContext testContext ) { new TaskTransactionTest ( ) . createModelExample ( 1 , vertx , testContext ) . onSuccess ( taskTransaction -> { taskTransaction . id = null ; final var service = this . createComponentProxy ( vertx ) ; testContext . assertComplete ( service . addTransactionIntoTask ( taskTransaction . taskId , taskTransaction ) ) . onSuccess ( addedTransaction -> { testContext . assertComplete ( service . retrieveTask ( taskTransaction . taskId ) ) . onSuccess ( retrieve -> testContext . verify ( ( ) -> { assertThat ( retrieve . transactions ) . isNotEmpty ( ) . contains ( addedTransaction ) ; final var message = new MessageTest ( ) . createModelExample ( 1 ) ; message . appId = retrieve . appId ; message . receiverId = retrieve . requesterId ; testContext . assertComplete ( service . addMessageIntoTransaction ( retrieve . id , addedTransaction . id , message ) ) . onSuccess ( addedMessage -> { testContext . assertComplete ( service . retrieveTask ( addedTransaction . taskId ) ) . onSuccess ( retrieve2 -> testContext . verify ( ( ) -> { assertThat ( retrieve2 . transactions ) . isNotEmpty ( ) ; final var transaction2 = retrieve2 . transactions . get ( 0 ) ; assertThat ( transaction2 . messages ) . isNotEmpty ( ) . contains ( addedMessage ) ; testContext . assertComplete ( service . deleteTask ( addedTransaction . taskId ) ) . onSuccess ( empty -> testContext . completeNow ( ) ) ; } ) ) ; } ) ; } ) ) ; } ) ; } ) ; }
Should add transaction and message into a task.
Should add transaction and message into a task .