components/src/test/java/eu/internetofus/common/components/service/WeNetServiceSimulatorMocker.java
/**
   * Create the handler to add a user message.
   *
   * @return the handler to post a user message.
   */
Create the handler to add a user message.
@return the handler to post a user message.
Create the handler to add a user message . @return the handler to post a user message .
protected DataElementHandler createPostUsersHandler() {
    return (ctx, index) -> {
      final var users = ctx.getBodyAsJsonArray();
      if (users == null) {
        final var response = ctx.response();
        response.setStatusCode(Status.BAD_REQUEST.getStatusCode());
        response.end(new ErrorMessage("unexpected_users", "The post message is not a JsonArray").toBuffer());
      } else {
        this.data.get(index).users = users;
        final var response = ctx.response();
        response.setStatusCode(Status.OK.getStatusCode());
        response.end(users.toBuffer());
      }
    };
  }
protected DataElementHandler createPostUsersHandler ( ) { return ( ctx , index ) -> { final var users = ctx . getBodyAsJsonArray ( ) ; if ( users == null ) { final var response = ctx . response ( ) ; response . setStatusCode ( Status . BAD_REQUEST . getStatusCode ( ) ) ; response . end ( new ErrorMessage ( "unexpected_users" , "The post message is not a JsonArray" ) . toBuffer ( ) ) ; } else { this . data . get ( index ) . users = users ; final var response = ctx . response ( ) ; response . setStatusCode ( Status . OK . getStatusCode ( ) ) ; response . end ( users . toBuffer ( ) ) ; } } ; }
Create the handler to add a user message.
Create the handler to add a user message .