protocols/src/test/java/eu/internetofus/common/protocols/AbstractAsk4HelpV2_2ProtocolRandomUsersITC.java
/**
   * Check that all the user answer the question.
   *
   * @param vertx       event bus to use.
   * @param testContext context to do the test.
   */
Check that all the user answer the question.
@param vertx       event bus to use.
@param testContext context to do the test.
Check that all the user answer the question . @param vertx event bus to use . @param testContext context to do the test .
@Test
  @Order(6)
  public void shouldAnswer(final Vertx vertx, final VertxTestContext testContext) {
    this.assertLastSuccessfulTestWas(5, testContext);
    final var checkMessages = new ArrayList<Predicate<Message>>();
    final var checkIncentiveTransactionStatus = new ArrayList<Predicate<TaskTransactionStatusBody>>();
    final var checkSocialNotification = new ArrayList<Predicate<UserMessage>>();
    final var checkInteractions = new ArrayList<Predicate<Interaction>>();
    Future<?> future = Future.succeededFuture();
    var count = 1;
    for (final var user : this.participants) {
      final var transactionId = count;
      final var transaction = new TaskTransaction();
      transaction.actioneerId = user;
      transaction.taskId = this.task.id;
      transaction.label = "answerTransaction";
      final var answer = "Response question with " + transactionId;
      transaction.attributes = new JsonObject().put("answer", answer).put("anonymous", transactionId % 2 == 0);
      final var checkMessage = this.createMessagePredicate().and(MessagePredicates.labelIs("AnsweredQuestionMessage"))
          .and(MessagePredicates.receiverIs(this.task.requesterId))
          .and(MessagePredicates.attributesSimilarTo(new JsonObject().put("answer", answer).put("taskId", this.task.id)
              .put("question", this.task.goal.name).put("transactionId", String.valueOf(transactionId))
              .put("answer", answer).put("userId", transaction.actioneerId).put("anonymous", transactionId % 2 == 0)));
      checkMessages.add(checkMessage);
      final var checkTask = this.createTaskPredicate().and(TaskPredicates.transactionSizeIs(transactionId + 1))
          .and(TaskPredicates.transactionAt(transactionId,
              this.createTaskTransactionPredicate().and(TaskTransactionPredicates.similarTo(transaction))
                  .and(TaskTransactionPredicates.messagesSizeIs(1))
                  .and(TaskTransactionPredicates.messageAt(0, checkMessage))));
      checkIncentiveTransactionStatus.add(this.createIncentiveServerTaskTransactionStatusPredicate()
          .and(TaskTransactionStatusBodyPredicates.userIs(transaction.actioneerId))
          .and(TaskTransactionStatusBodyPredicates.labelIs(transaction.label))
          .and(TaskTransactionStatusBodyPredicates.countIs(1)));
      checkIncentiveTransactionStatus.add(this.createIncentiveServerTaskTransactionStatusPredicate()
          .and(TaskTransactionStatusBodyPredicates.userIs(this.task.requesterId))
          .and(TaskTransactionStatusBodyPredicates.labelIs("AnsweredQuestionMessage"))
          .and(TaskTransactionStatusBodyPredicates.countIs(transactionId)));
      checkSocialNotification.add(this.createSocialNotificationPredicate().and(UserMessagePredicates.senderId(user))
          .and(UserMessagePredicates.transactionId(String.valueOf(transactionId)))
          .and(UserMessagePredicates.message(checkMessage)));
      checkInteractions
          .add(this.createInteractionPredicate().and(InteractionPredicates.senderIs(transaction.actioneerId))
              .and(InteractionPredicates.transactionLabelIs(transaction.label))
              .and(InteractionPredicates.transactionAttributesAre(transaction.attributes))
              .and(InteractionPredicates.receiverIs(this.task.requesterId))
              .and(InteractionPredicates.messageLabelIs("AnsweredQuestionMessage")));
      future = future.compose(ignored -> WeNetTaskManager.createProxy(vertx).doTaskTransaction(transaction))
          .compose(ignored -> this.waitUntilTask(vertx, testContext, checkTask));
      count++;
    }
    future = future.compose(ignored -> this.waitUntilCallbacks(vertx, testContext, checkMessages))
        .compose(ignored -> this.waitUntilIncentiveServerHasTaskTransactionStatus(vertx, testContext,
            checkIncentiveTransactionStatus))
        .compose(ignored -> this.waitUntilSocialNotification(vertx, testContext, checkSocialNotification))
        .compose(ignored -> this.waitUntilInteractions(vertx, testContext, checkInteractions));
    future.onComplete(testContext.succeeding(ignored -> this.assertSuccessfulCompleted(testContext)));
  }
@ Test @ Order ( 6 ) public void shouldAnswer ( final Vertx vertx , final VertxTestContext testContext ) { this . assertLastSuccessfulTestWas ( 5 , testContext ) ; final var checkMessages = new ArrayList < Predicate < Message > > ( ) ; final var checkIncentiveTransactionStatus = new ArrayList < Predicate < TaskTransactionStatusBody > > ( ) ; final var checkSocialNotification = new ArrayList < Predicate < UserMessage > > ( ) ; final var checkInteractions = new ArrayList < Predicate < Interaction > > ( ) ; Future < ? > future = Future . succeededFuture ( ) ; var count = 1 ; for ( final var user : this . participants ) { final var transactionId = count ; final var transaction = new TaskTransaction ( ) ; transaction . actioneerId = user ; transaction . taskId = this . task . id ; transaction . label = "answerTransaction" ; final var answer = "Response question with " + transactionId ; transaction . attributes = new JsonObject ( ) . put ( "answer" , answer ) . put ( "anonymous" , transactionId % 2 == 0 ) ; final var checkMessage = this . createMessagePredicate ( ) . and ( MessagePredicates . labelIs ( "AnsweredQuestionMessage" ) ) . and ( MessagePredicates . receiverIs ( this . task . requesterId ) ) . and ( MessagePredicates . attributesSimilarTo ( new JsonObject ( ) . put ( "answer" , answer ) . put ( "taskId" , this . task . id ) . put ( "question" , this . task . goal . name ) . put ( "transactionId" , String . valueOf ( transactionId ) ) . put ( "answer" , answer ) . put ( "userId" , transaction . actioneerId ) . put ( "anonymous" , transactionId % 2 == 0 ) ) ) ; checkMessages . add ( checkMessage ) ; final var checkTask = this . createTaskPredicate ( ) . and ( TaskPredicates . transactionSizeIs ( transactionId + 1 ) ) . and ( TaskPredicates . transactionAt ( transactionId , this . createTaskTransactionPredicate ( ) . and ( TaskTransactionPredicates . similarTo ( transaction ) ) . and ( TaskTransactionPredicates . messagesSizeIs ( 1 ) ) . and ( TaskTransactionPredicates . messageAt ( 0 , checkMessage ) ) ) ) ; checkIncentiveTransactionStatus . add ( this . createIncentiveServerTaskTransactionStatusPredicate ( ) . and ( TaskTransactionStatusBodyPredicates . userIs ( transaction . actioneerId ) ) . and ( TaskTransactionStatusBodyPredicates . labelIs ( transaction . label ) ) . and ( TaskTransactionStatusBodyPredicates . countIs ( 1 ) ) ) ; checkIncentiveTransactionStatus . add ( this . createIncentiveServerTaskTransactionStatusPredicate ( ) . and ( TaskTransactionStatusBodyPredicates . userIs ( this . task . requesterId ) ) . and ( TaskTransactionStatusBodyPredicates . labelIs ( "AnsweredQuestionMessage" ) ) . and ( TaskTransactionStatusBodyPredicates . countIs ( transactionId ) ) ) ; checkSocialNotification . add ( this . createSocialNotificationPredicate ( ) . and ( UserMessagePredicates . senderId ( user ) ) . and ( UserMessagePredicates . transactionId ( String . valueOf ( transactionId ) ) ) . and ( UserMessagePredicates . message ( checkMessage ) ) ) ; checkInteractions . add ( this . createInteractionPredicate ( ) . and ( InteractionPredicates . senderIs ( transaction . actioneerId ) ) . and ( InteractionPredicates . transactionLabelIs ( transaction . label ) ) . and ( InteractionPredicates . transactionAttributesAre ( transaction . attributes ) ) . and ( InteractionPredicates . receiverIs ( this . task . requesterId ) ) . and ( InteractionPredicates . messageLabelIs ( "AnsweredQuestionMessage" ) ) ) ; future = future . compose ( ignored -> WeNetTaskManager . createProxy ( vertx ) . doTaskTransaction ( transaction ) ) . compose ( ignored -> this . waitUntilTask ( vertx , testContext , checkTask ) ) ; count ++ ; } future = future . compose ( ignored -> this . waitUntilCallbacks ( vertx , testContext , checkMessages ) ) . compose ( ignored -> this . waitUntilIncentiveServerHasTaskTransactionStatus ( vertx , testContext , checkIncentiveTransactionStatus ) ) . compose ( ignored -> this . waitUntilSocialNotification ( vertx , testContext , checkSocialNotification ) ) . compose ( ignored -> this . waitUntilInteractions ( vertx , testContext , checkInteractions ) ) ; future . onComplete ( testContext . succeeding ( ignored -> this . assertSuccessfulCompleted ( testContext ) ) ) ; }
Check that all the user answer the question.
Check that all the user answer the question .