LandscapeResource { @GET @Path("{id}") @Produces(MEDIA_TYPE) @Operation(summary = "Find a landscape by its id") @ApiResponse(responseCode = "200", description = "Response contains the requested landscape.", content = @Content(schema = @Schema(implementation = Landscape.class))) @ApiResponse(responseCode = "404", description = "No landscape with such id.") public String getLandscapeById(@Parameter(description = "Id of the landscape", required = true) @PathParam("id") final String id) { return Stream.of(this.landscapeStringRepo.getById(id), this.replayStringRepo.getById(id)) .filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow(() -> new NotFoundException("Landscape with id " + id + " not found.")); } @Inject  LandscapeResource(final LandscapeRepository<String> landscapeStringRepo,
      final ReplayRepository<String> replayStringRepo,
      final LandscapeSerializationHelper serializationHelper); @GET @Path("{id}") @Produces(MEDIA_TYPE) @Operation(summary = "Find a landscape by its id") @ApiResponse(responseCode = "200", description = "Response contains the requested landscape.", content = @Content(schema = @Schema(implementation = Landscape.class))) @ApiResponse(responseCode = "404", description = "No landscape with such id.") String getLandscapeById(@Parameter(description = "Id of the landscape",
      required = true) @PathParam("id") final String id); @GET @Produces(MEDIA_TYPE) @Operation(summary = "Find a landscape by its timestamp") @ApiResponse(responseCode = "200", description = "Response contains the first landscape with the given timestamp.", content = @Content(schema = @Schema(implementation = Landscape.class))) @ApiResponse(responseCode = "404", description = "No landscape with the given timestamp.") String getLandscape(@Parameter(description = "The timestamp to filter by.",
      required = true) @QueryParam("timestamp") final long timestamp); @GET @Path("/download") @Produces("application/json") @Operation(summary = "Download a landscape by its timestamp") @ApiResponse(responseCode = "200", description = "Response contains the first landscape with the given timestamp.", content = @Content(schema = @Schema(implementation = Landscape.class))) @ApiResponse(responseCode = "404", description = "No landscape with the given timestamp.") String downloadLandscape(@Parameter(description = "The timestamp to filter by.",
      required = true) @QueryParam("timestamp") final long timestamp); @POST @Path("/replay/upload") @Consumes("multipart/form-data") @Produces(MEDIA_TYPE) @Operation(summary = "Upload a landscape file from the frontend") @ApiResponse(responseCode = "200", description = "Response contains the uploaded landscape file.", content = @Content(schema = @Schema(implementation = Landscape.class))) @ApiResponse(responseCode = "404", description = "Landscape file could not be uploaded.") String uploadLandscape(
      @Parameter(description = "The name of the file.",
          required = true) @QueryParam("filename") final String fileName,
      @Parameter(description = "The uploaded landscape file.",
          required = true) @FormDataParam("file") final InputStream uploadedInputStream,
      @Parameter(description = "The file information of the uploaded landscape.",
          required = true) @FormDataParam("file") final FormDataContentDisposition fileInfo);  }
@Test @DisplayName("Return landscape by id.") public void giveAllServiceGenerated() { assertEquals(this.currentLandscape, this.landscapeResouce.getLandscapeById(this.currentLandscapeId), "Wrong landscape was returned."); }
@Test @DisplayName("Unknown landscape id throws NotFoundException.") public void checkUnknownLandscapeException() { assertThrows(NotFoundException.class, () -> { this.landscapeResouce.getLandscapeById("not-a-valid-id"); }); }