protocols/src/test/java/eu/internetofus/common/protocols/EatTogetherV2ProtocolITC.java
/**
   * Check that an user decline to do a task.
   *
   * @param vertx       event bus to use.
   * @param testContext context to do the test.
   */
Check that an user decline to do a task.
@param vertx       event bus to use.
@param testContext context to do the test.
Check that an user decline to do a task . @param vertx event bus to use . @param testContext context to do the test .
@Test
  @Order(6)
  public void shouldDeclineTask(final Vertx vertx, final VertxTestContext testContext) {
    this.assertLastSuccessfulTestWas(5, testContext);
    final var transaction = new TaskTransaction();
    final var volunteerId = this.users.get(1).id;
    transaction.actioneerId = volunteerId;
    transaction.taskId = this.task.id;
    transaction.label = "refuseTask";
    transaction.attributes = new JsonObject().put("volunteerId", volunteerId);
    final var unanswered = this.task.attributes.getJsonArray("unanswered").copy();
    unanswered.remove(volunteerId);
    final var checkTask = this.createTaskPredicate().and(TaskPredicates.transactionSizeIs(2))
        .and(TaskPredicates.attributesSimilarTo(
            new JsonObject().put("unanswered", unanswered).put("declined", new JsonArray().add(volunteerId))))
        .and(TaskPredicates.transactionAt(1,
            this.createTaskTransactionPredicate().and(TaskTransactionPredicates.similarTo(transaction))));
    final var checkStatus = new ArrayList<Predicate<TaskTransactionStatusBody>>();
    checkStatus.add(this.createIncentiveServerTaskTransactionStatusPredicate()
        .and(TaskTransactionStatusBodyPredicates.labelIs(transaction.label))
        .and(TaskTransactionStatusBodyPredicates.userIs(volunteerId))
        .and(TaskTransactionStatusBodyPredicates.countIs(1)));
    final var future = WeNetTaskManager.createProxy(vertx).doTaskTransaction(transaction)
        .compose(ignored -> this.waitUntilTask(vertx, testContext, checkTask))
        .compose(ignored -> this.waitUntilIncentiveServerHasTaskTransactionStatus(vertx, testContext, checkStatus));
    testContext.assertComplete(future).onComplete(ignored -> this.assertSuccessfulCompleted(testContext));
  }
@ Test @ Order ( 6 ) public void shouldDeclineTask ( final Vertx vertx , final VertxTestContext testContext ) { this . assertLastSuccessfulTestWas ( 5 , testContext ) ; final var transaction = new TaskTransaction ( ) ; final var volunteerId = this . users . get ( 1 ) . id ; transaction . actioneerId = volunteerId ; transaction . taskId = this . task . id ; transaction . label = "refuseTask" ; transaction . attributes = new JsonObject ( ) . put ( "volunteerId" , volunteerId ) ; final var unanswered = this . task . attributes . getJsonArray ( "unanswered" ) . copy ( ) ; unanswered . remove ( volunteerId ) ; final var checkTask = this . createTaskPredicate ( ) . and ( TaskPredicates . transactionSizeIs ( 2 ) ) . and ( TaskPredicates . attributesSimilarTo ( new JsonObject ( ) . put ( "unanswered" , unanswered ) . put ( "declined" , new JsonArray ( ) . add ( volunteerId ) ) ) ) . and ( TaskPredicates . transactionAt ( 1 , this . createTaskTransactionPredicate ( ) . and ( TaskTransactionPredicates . similarTo ( transaction ) ) ) ) ; final var checkStatus = new ArrayList < Predicate < TaskTransactionStatusBody > > ( ) ; checkStatus . add ( this . createIncentiveServerTaskTransactionStatusPredicate ( ) . and ( TaskTransactionStatusBodyPredicates . labelIs ( transaction . label ) ) . and ( TaskTransactionStatusBodyPredicates . userIs ( volunteerId ) ) . and ( TaskTransactionStatusBodyPredicates . countIs ( 1 ) ) ) ; final var future = WeNetTaskManager . createProxy ( vertx ) . doTaskTransaction ( transaction ) . compose ( ignored -> this . waitUntilTask ( vertx , testContext , checkTask ) ) . compose ( ignored -> this . waitUntilIncentiveServerHasTaskTransactionStatus ( vertx , testContext , checkStatus ) ) ; testContext . assertComplete ( future ) . onComplete ( ignored -> this . assertSuccessfulCompleted ( testContext ) ) ; }
Check that an user decline to do a task.
Check that an user decline to do a task .