components/src/test/java/eu/internetofus/common/components/personal_context_builder/WeNetPersonalContextBuilderSimulatorMocker.java
/**
   * Handler for post the locations of a set of users.
   *
   * @return the handler to manage an users locations.
   */
Handler for post the locations of a set of users.
@return the handler to manage an users locations.
Handler for post the locations of a set of users . @return the handler to manage an users locations .
protected Handler<RoutingContext> createPostLocationsHandler() {
    return ctx -> {
      final var body = Model.fromJsonObject(ctx.getBodyAsJson(), Users.class);
      if (body == null) {
        final var response = ctx.response();
        response.setStatusCode(Status.BAD_REQUEST.getStatusCode());
        response.end(new ErrorMessage("unexpected_users", "The post does not contains the users").toBuffer());
      } else {
        final var usersLocation = new UsersLocations();
        if (!this.locations.isEmpty()) {
          for (final var userId : body.userids) {
            for (final var location : this.locations) {
              if (location.userId.equals(userId)) {
                usersLocation.locations.add(location);
                break;
              }
            }
          }
        }
        final var response = ctx.response();
        response.setStatusCode(Status.OK.getStatusCode());
        response.end(usersLocation.toBuffer());
      }
    };
  }
protected Handler < RoutingContext > createPostLocationsHandler ( ) { return ctx -> { final var body = Model . fromJsonObject ( ctx . getBodyAsJson ( ) , Users . class ) ; if ( body == null ) { final var response = ctx . response ( ) ; response . setStatusCode ( Status . BAD_REQUEST . getStatusCode ( ) ) ; response . end ( new ErrorMessage ( "unexpected_users" , "The post does not contains the users" ) . toBuffer ( ) ) ; } else { final var usersLocation = new UsersLocations ( ) ; if ( ! this . locations . isEmpty ( ) ) { for ( final var userId : body . userids ) { for ( final var location : this . locations ) { if ( location . userId . equals ( userId ) ) { usersLocation . locations . add ( location ) ; break ; } } } } final var response = ctx . response ( ) ; response . setStatusCode ( Status . OK . getStatusCode ( ) ) ; response . end ( usersLocation . toBuffer ( ) ) ; } } ; }
Handler for post the locations of a set of users.
Handler for post the locations of a set of users .