protocols/src/test/java/eu/internetofus/common/protocols/Ask4HelpV2ProtocolWithAllFiltersITC.java
/**
   * Check that the requester can ask for more answers.
   *
   * @param vertx       event bus to use.
   * @param testContext context to do the test.
   */
Check that the requester can ask for more answers.
@param vertx       event bus to use.
@param testContext context to do the test.
Check that the requester can ask for more answers . @param vertx event bus to use . @param testContext context to do the test .
@Test
  @Order(9)
  public void shouldAskForMoreAnswers(final Vertx vertx, final VertxTestContext testContext) {
    this.assertLastSuccessfulTestWas(8, testContext);
    final var checkMessages = new ArrayList<Predicate<Message>>();
    final var usersToAskIds = this.expectedState.getJsonArray("unaskedUserIds");
    for (var i = 0; i < usersToAskIds.size(); i++) {
      final var receiverId = usersToAskIds.getString(i);
      checkMessages.add(this.createMessagePredicateForQuestionToAnswerMessageBy(receiverId));
    }
    final var moreAnswerTransaction = new TaskTransaction();
    moreAnswerTransaction.taskId = this.task.id;
    moreAnswerTransaction.actioneerId = this.task.requesterId;
    moreAnswerTransaction.label = "moreAnswerTransaction";
    final var checkTask = this.createTaskPredicate()
        .and(TaskPredicates.lastTransactionIs(
            this.createTaskTransactionPredicate().and(TaskTransactionPredicates.similarTo(moreAnswerTransaction))
                .and(TaskTransactionPredicates.messagesSizeIs(checkMessages.size()))
                .and(TaskTransactionPredicates.containsMessages(checkMessages))));
    final Future<?> future = WeNetTaskManager.createProxy(vertx).doTaskTransaction(moreAnswerTransaction)
        .compose(ignored -> this.waitUntilTask(vertx, testContext, checkTask))
        .compose(ignored -> this.waitUntilCallbacks(vertx, testContext, checkMessages))
        .compose(ignored -> this.waitUntilUserTaskState(this.task.requesterId, vertx, testContext, userTaskState -> {
          if (userTaskState.attributes != null) {
            final var unaskedUserIds = userTaskState.attributes.getJsonArray("unaskedUserIds");
            return unaskedUserIds != null && unaskedUserIds.size() == 0;
          } else {
            return false;
          }
        }));
    future.onComplete(testContext.succeeding(ignored -> this.assertSuccessfulCompleted(testContext)));
  }
@ Test @ Order ( 9 ) public void shouldAskForMoreAnswers ( final Vertx vertx , final VertxTestContext testContext ) { this . assertLastSuccessfulTestWas ( 8 , testContext ) ; final var checkMessages = new ArrayList < Predicate < Message > > ( ) ; final var usersToAskIds = this . expectedState . getJsonArray ( "unaskedUserIds" ) ; for ( var i = 0 ; i < usersToAskIds . size ( ) ; i ++ ) { final var receiverId = usersToAskIds . getString ( i ) ; checkMessages . add ( this . createMessagePredicateForQuestionToAnswerMessageBy ( receiverId ) ) ; } final var moreAnswerTransaction = new TaskTransaction ( ) ; moreAnswerTransaction . taskId = this . task . id ; moreAnswerTransaction . actioneerId = this . task . requesterId ; moreAnswerTransaction . label = "moreAnswerTransaction" ; final var checkTask = this . createTaskPredicate ( ) . and ( TaskPredicates . lastTransactionIs ( this . createTaskTransactionPredicate ( ) . and ( TaskTransactionPredicates . similarTo ( moreAnswerTransaction ) ) . and ( TaskTransactionPredicates . messagesSizeIs ( checkMessages . size ( ) ) ) . and ( TaskTransactionPredicates . containsMessages ( checkMessages ) ) ) ) ; final Future < ? > future = WeNetTaskManager . createProxy ( vertx ) . doTaskTransaction ( moreAnswerTransaction ) . compose ( ignored -> this . waitUntilTask ( vertx , testContext , checkTask ) ) . compose ( ignored -> this . waitUntilCallbacks ( vertx , testContext , checkMessages ) ) . compose ( ignored -> this . waitUntilUserTaskState ( this . task . requesterId , vertx , testContext , userTaskState -> { if ( userTaskState . attributes != null ) { final var unaskedUserIds = userTaskState . attributes . getJsonArray ( "unaskedUserIds" ) ; return unaskedUserIds != null && unaskedUserIds . size ( ) == 0 ; } else { return false ; } } ) ) ; future . onComplete ( testContext . succeeding ( ignored -> this . assertSuccessfulCompleted ( testContext ) ) ) ; }
Check that the requester can ask for more answers.
Check that the requester can ask for more answers .