protocols/src/test/java/eu/internetofus/common/protocols/EchoV1ProtocolITC.java
/**
   * Should send transaction echo.
   *
   * @param vertx       event bus to use.
   * @param testContext context to do the test.
   */
Should send transaction echo.
@param vertx       event bus to use.
@param testContext context to do the test.
Should send transaction echo . @param vertx event bus to use . @param testContext context to do the test .
@Test
  @Order(6)
  public void shouldDoTransactionEcho(final Vertx vertx, final VertxTestContext testContext) {
    this.assertLastSuccessfulTestWas(5, testContext);
    final var transaction = new TaskTransaction();
    transaction.actioneerId = this.task.requesterId;
    transaction.taskId = this.task.id;
    transaction.label = "echo";
    final var message = UUID.randomUUID().toString();
    transaction.attributes = new JsonObject().put("message", message);
    final var checkMessages = new ArrayList<Predicate<Message>>();
    final var checkMessage = MessagePredicates.labelIs("echo")
        .and(MessagePredicates.receiverIs(transaction.actioneerId))
        .and(MessagePredicates.attributesAre(new JsonObject().put("message", message).put("taskId", this.task.id)));
    checkMessages.add(checkMessage);
    final var checkTask = TaskPredicates.transactionSizeIs(2)
        .and(TaskPredicates.transactionAt(1,
            TaskTransactionPredicates.similarTo(transaction).and(TaskTransactionPredicates.messagesSizeIs(1))
                .and(TaskTransactionPredicates.messageAt(0, checkMessage))));
    final var checkIncentiveTransactionStatus = new ArrayList<Predicate<TaskTransactionStatusBody>>();
    checkIncentiveTransactionStatus.add(this.createIncentiveServerTaskTransactionStatusPredicate()
        .and(TaskTransactionStatusBodyPredicates.userIs(transaction.actioneerId))
        .and(TaskTransactionStatusBodyPredicates.labelIs("echo")).and(TaskTransactionStatusBodyPredicates.countIs(1)));
    checkIncentiveTransactionStatus.add(this.createIncentiveServerTaskTransactionStatusPredicate()
        .and(TaskTransactionStatusBodyPredicates.userIs(transaction.actioneerId))
        .and(TaskTransactionStatusBodyPredicates.labelIs("echo")).and(TaskTransactionStatusBodyPredicates.countIs(2)));
    final var future = WeNetTaskManager.createProxy(vertx).doTaskTransaction(transaction)
        .compose(ignored -> this.waitUntilCallbacks(vertx, testContext, checkMessages))
        .compose(ignored -> this.waitUntilTask(vertx, testContext, checkTask)).compose(ignored -> this
            .waitUntilIncentiveServerHasTaskTransactionStatus(vertx, testContext, checkIncentiveTransactionStatus));
    future.onComplete(testContext.succeeding(ignored -> this.assertSuccessfulCompleted(testContext)));
  }
@ Test @ Order ( 6 ) public void shouldDoTransactionEcho ( final Vertx vertx , final VertxTestContext testContext ) { this . assertLastSuccessfulTestWas ( 5 , testContext ) ; final var transaction = new TaskTransaction ( ) ; transaction . actioneerId = this . task . requesterId ; transaction . taskId = this . task . id ; transaction . label = "echo" ; final var message = UUID . randomUUID ( ) . toString ( ) ; transaction . attributes = new JsonObject ( ) . put ( "message" , message ) ; final var checkMessages = new ArrayList < Predicate < Message > > ( ) ; final var checkMessage = MessagePredicates . labelIs ( "echo" ) . and ( MessagePredicates . receiverIs ( transaction . actioneerId ) ) . and ( MessagePredicates . attributesAre ( new JsonObject ( ) . put ( "message" , message ) . put ( "taskId" , this . task . id ) ) ) ; checkMessages . add ( checkMessage ) ; final var checkTask = TaskPredicates . transactionSizeIs ( 2 ) . and ( TaskPredicates . transactionAt ( 1 , TaskTransactionPredicates . similarTo ( transaction ) . and ( TaskTransactionPredicates . messagesSizeIs ( 1 ) ) . and ( TaskTransactionPredicates . messageAt ( 0 , checkMessage ) ) ) ) ; final var checkIncentiveTransactionStatus = new ArrayList < Predicate < TaskTransactionStatusBody > > ( ) ; checkIncentiveTransactionStatus . add ( this . createIncentiveServerTaskTransactionStatusPredicate ( ) . and ( TaskTransactionStatusBodyPredicates . userIs ( transaction . actioneerId ) ) . and ( TaskTransactionStatusBodyPredicates . labelIs ( "echo" ) ) . and ( TaskTransactionStatusBodyPredicates . countIs ( 1 ) ) ) ; checkIncentiveTransactionStatus . add ( this . createIncentiveServerTaskTransactionStatusPredicate ( ) . and ( TaskTransactionStatusBodyPredicates . userIs ( transaction . actioneerId ) ) . and ( TaskTransactionStatusBodyPredicates . labelIs ( "echo" ) ) . and ( TaskTransactionStatusBodyPredicates . countIs ( 2 ) ) ) ; final var future = WeNetTaskManager . createProxy ( vertx ) . doTaskTransaction ( transaction ) . compose ( ignored -> this . waitUntilCallbacks ( vertx , testContext , checkMessages ) ) . compose ( ignored -> this . waitUntilTask ( vertx , testContext , checkTask ) ) . compose ( ignored -> this . waitUntilIncentiveServerHasTaskTransactionStatus ( vertx , testContext , checkIncentiveTransactionStatus ) ) ; future . onComplete ( testContext . succeeding ( ignored -> this . assertSuccessfulCompleted ( testContext ) ) ) ; }
Should send transaction echo.
Should send transaction echo .