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