components/src/test/java/eu/internetofus/common/components/service/WeNetServiceSimulatorMocker.java
/**
   * Create the handler to add a new application.
   *
   * @return the handler to post a new application.
   */
Create the handler to add a new application.
@return the handler to post a new application.
Create the handler to add a new application . @return the handler to post a new application .
protected Handler<RoutingContext> createPostAppHandler() {
    return ctx -> {
      final var app = Model.fromBuffer(ctx.getBody(), App.class);
      if (app == null) {
        final var response = ctx.response();
        response.setStatusCode(Status.BAD_REQUEST.getStatusCode());
        response.end(new ErrorMessage("bad_app", "The content is not an application").toBuffer());
      } else if (app.appId == null || this.indexOf(app.appId) < 0) {
        this.data.add(this.createDataElement(app));
        final var response = ctx.response();
        response.setStatusCode(Status.CREATED.getStatusCode());
        response.end(app.toBuffer());
      } else {
        final var response = ctx.response();
        response.setStatusCode(Status.BAD_REQUEST.getStatusCode());
        response.end(new ErrorMessage("dulicated_id", "The application already exist").toBuffer());
      }
    };
  }
protected Handler < RoutingContext > createPostAppHandler ( ) { return ctx -> { final var app = Model . fromBuffer ( ctx . getBody ( ) , App . class ) ; if ( app == null ) { final var response = ctx . response ( ) ; response . setStatusCode ( Status . BAD_REQUEST . getStatusCode ( ) ) ; response . end ( new ErrorMessage ( "bad_app" , "The content is not an application" ) . toBuffer ( ) ) ; } else if ( app . appId == null || this . indexOf ( app . appId ) < 0 ) { this . data . add ( this . createDataElement ( app ) ) ; final var response = ctx . response ( ) ; response . setStatusCode ( Status . CREATED . getStatusCode ( ) ) ; response . end ( app . toBuffer ( ) ) ; } else { final var response = ctx . response ( ) ; response . setStatusCode ( Status . BAD_REQUEST . getStatusCode ( ) ) ; response . end ( new ErrorMessage ( "dulicated_id" , "The application already exist" ) . toBuffer ( ) ) ; } } ; }
Create the handler to add a new application.
Create the handler to add a new application .