protocols/src/test/java/eu/internetofus/common/protocols/Ask4HelpV1_2ProtocolITC.java
/**
   * Check that create a second task.
   *
   * @param vertx       event bus to use.
   * @param testContext context to do the test.
   */
Check that create a second task.
@param vertx       event bus to use.
@param testContext context to do the test.
Check that create a second task . @param vertx event bus to use . @param testContext context to do the test .
@Test
  @Order(13)
  public void shouldCreateSecondTask(final Vertx vertx, final VertxTestContext testContext) {
    this.assertLastSuccessfulTestWas(5, testContext);
    this.lastSuccessfulTest = 12;
    final var source = this.createTaskForProtocol();
    final var checkMessages = new ArrayList<Predicate<Message>>();
    for (final var user : this.users) {
      if (!user.id.equals(source.requesterId)) {
        checkMessages.add(this.createMessagePredicate().and(MessagePredicates.labelIs("QuestionToAnswerMessage"))
            .and(MessagePredicates.receiverIs(user.id))
            .and(MessagePredicates.attributesSimilarTo(
                new JsonObject().put("question", source.goal.name).put("userId", source.requesterId)))
            .and(MessagePredicates.attributesAre(target -> {
              return this.task.id.equals(target.getString("taskId"));
            })));
      }
    }
    final var createTransaction = new TaskTransaction();
    createTransaction.label = TaskTransaction.CREATE_TASK_LABEL;
    createTransaction.actioneerId = source.requesterId;
    final var checkTask = this.createTaskPredicate().and(TaskPredicates.similarTo(source))
        .and(TaskPredicates.transactionSizeIs(1))
        .and(TaskPredicates.transactionAt(0,
            this.createTaskTransactionPredicate().and(TaskTransactionPredicates.similarTo(createTransaction))
                .and(TaskTransactionPredicates.messagesSizeIs(this.users.size() - 1))
                .and(TaskTransactionPredicates.containsMessages(checkMessages))));
    final var checkStatus = new ArrayList<Predicate<TaskTypeStatusBody>>();
    checkStatus.add(this.createIncentiveServerTaskTypeStatusPredicate().and(TaskTypeStatusBodyPredicates.countIs(2))
        .and(TaskTypeStatusBodyPredicates.userIs(source.requesterId)));
    final var future = this.waitUntilTaskCreated(source, vertx, testContext, checkTask)
        .compose(ignored -> this.waitUntilCallbacks(vertx, testContext, checkMessages))
        .compose(ignored -> this.waitUntilIncentiveServerHasTaskTypeStatus(vertx, testContext, checkStatus));
    future.onComplete(testContext.succeeding(ignored -> this.assertSuccessfulCompleted(testContext)));
  }
@ Test @ Order ( 13 ) public void shouldCreateSecondTask ( final Vertx vertx , final VertxTestContext testContext ) { this . assertLastSuccessfulTestWas ( 5 , testContext ) ; this . lastSuccessfulTest = 12 ; final var source = this . createTaskForProtocol ( ) ; final var checkMessages = new ArrayList < Predicate < Message > > ( ) ; for ( final var user : this . users ) { if ( ! user . id . equals ( source . requesterId ) ) { checkMessages . add ( this . createMessagePredicate ( ) . and ( MessagePredicates . labelIs ( "QuestionToAnswerMessage" ) ) . and ( MessagePredicates . receiverIs ( user . id ) ) . and ( MessagePredicates . attributesSimilarTo ( new JsonObject ( ) . put ( "question" , source . goal . name ) . put ( "userId" , source . requesterId ) ) ) . and ( MessagePredicates . attributesAre ( target -> { return this . task . id . equals ( target . getString ( "taskId" ) ) ; } ) ) ) ; } } final var createTransaction = new TaskTransaction ( ) ; createTransaction . label = TaskTransaction . CREATE_TASK_LABEL ; createTransaction . actioneerId = source . requesterId ; final var checkTask = this . createTaskPredicate ( ) . and ( TaskPredicates . similarTo ( source ) ) . and ( TaskPredicates . transactionSizeIs ( 1 ) ) . and ( TaskPredicates . transactionAt ( 0 , this . createTaskTransactionPredicate ( ) . and ( TaskTransactionPredicates . similarTo ( createTransaction ) ) . and ( TaskTransactionPredicates . messagesSizeIs ( this . users . size ( ) - 1 ) ) . and ( TaskTransactionPredicates . containsMessages ( checkMessages ) ) ) ) ; final var checkStatus = new ArrayList < Predicate < TaskTypeStatusBody > > ( ) ; checkStatus . add ( this . createIncentiveServerTaskTypeStatusPredicate ( ) . and ( TaskTypeStatusBodyPredicates . countIs ( 2 ) ) . and ( TaskTypeStatusBodyPredicates . userIs ( source . requesterId ) ) ) ; final var future = this . waitUntilTaskCreated ( source , vertx , testContext , checkTask ) . compose ( ignored -> this . waitUntilCallbacks ( vertx , testContext , checkMessages ) ) . compose ( ignored -> this . waitUntilIncentiveServerHasTaskTypeStatus ( vertx , testContext , checkStatus ) ) ; future . onComplete ( testContext . succeeding ( ignored -> this . assertSuccessfulCompleted ( testContext ) ) ) ; }
Check that create a second task.
Check that create a second task .