components/src/test/java/eu/internetofus/common/components/personal_context_builder/WeNetPersonalContextBuilderSimulatorMocker.java
/**
   * Handler for post a new location for an user.
   *
   * @return the handler to manage an users locations.
   */
Handler for post a new location for an user.
@return the handler to manage an users locations.
Handler for post a new location for an user . @return the handler to manage an users locations .
protected Handler<RoutingContext> createPutLocationHandler() {
    return ctx -> {
      final var id = ctx.pathParam("id");
      final var body = Model.fromJsonObject(ctx.getBodyAsJson(), UserLocation.class);
      if (body == null || id == null) {
        final var response = ctx.response();
        response.setStatusCode(Status.BAD_REQUEST.getStatusCode());
        response.end(new ErrorMessage("unexpected_location", "The put does not contains an user location").toBuffer());
      } else {
        body.userId = id;
        final var max = this.locations.size();
        for (var i = 0; i < max; i++) {
          final var location = this.locations.get(i);
          if (location.userId.equals(id)) {
            this.locations.remove(i);
            break;
          }
        }
        this.locations.add(body);
        final var response = ctx.response();
        response.setStatusCode(Status.OK.getStatusCode());
        response.end(body.toBuffer());
      }
    };
  }
protected Handler < RoutingContext > createPutLocationHandler ( ) { return ctx -> { final var id = ctx . pathParam ( "id" ) ; final var body = Model . fromJsonObject ( ctx . getBodyAsJson ( ) , UserLocation . class ) ; if ( body == null || id == null ) { final var response = ctx . response ( ) ; response . setStatusCode ( Status . BAD_REQUEST . getStatusCode ( ) ) ; response . end ( new ErrorMessage ( "unexpected_location" , "The put does not contains an user location" ) . toBuffer ( ) ) ; } else { body . userId = id ; final var max = this . locations . size ( ) ; for ( var i = 0 ; i < max ; i ++ ) { final var location = this . locations . get ( i ) ; if ( location . userId . equals ( id ) ) { this . locations . remove ( i ) ; break ; } } this . locations . add ( body ) ; final var response = ctx . response ( ) ; response . setStatusCode ( Status . OK . getStatusCode ( ) ) ; response . end ( body . toBuffer ( ) ) ; } } ; }
Handler for post a new location for an user.
Handler for post a new location for an user .