@Test(expected = WebApplicationException.class) public void testFetchJobSpecDetailsByIdThrowsWebApplicationExceptionIfJobSpecIdIsNull() throws IOException { final JobSpecDAO jobSpecDAO = mock(JobSpecDAO.class); final JobSpecResource jobSpecResource = new JobSpecResource(jobSpecDAO, DEFAULT_PAGE_SIZE); final SecurityContext securityContext = generateSecureSecurityContext(); final Optional<APIJobSpec> response = jobSpecResource.fetchJobSpecDetailsById(securityContext, null); }
@GET @Path("{job-spec-id}") @Operation( summary = "Get a a job spec.", description = "If found, returns a job spec. A job spec describes declaratively what a " + "job needs in order to run.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job specification found and returned", content = @Content( schema = @Schema(implementation = APIJobSpec.class) )), @ApiResponse( responseCode = "404", description = "The job specification cannot be found", content = @Content( schema = @Schema(implementation = APIErrorMessage.class) )) }) @PermitAll public Optional<APIJobSpec> fetchJobSpecDetailsById( @Context SecurityContext context, @Parameter(description = "The job spec's ID") @PathParam("job-spec-id") @NotNull JobSpecId jobSpecId) throws IOException { if (jobSpecId == null) throw new WebApplicationException("Job Spec ID cannot be null", 400); return jobSpecDAO.getJobSpecById(jobSpecId).map(APIJobSpec::fromJobSpec); }
JobSpecResource { @GET @Path("{job-spec-id}") @Operation( summary = "Get a a job spec.", description = "If found, returns a job spec. A job spec describes declaratively what a " + "job needs in order to run.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job specification found and returned", content = @Content( schema = @Schema(implementation = APIJobSpec.class) )), @ApiResponse( responseCode = "404", description = "The job specification cannot be found", content = @Content( schema = @Schema(implementation = APIErrorMessage.class) )) }) @PermitAll public Optional<APIJobSpec> fetchJobSpecDetailsById( @Context SecurityContext context, @Parameter(description = "The job spec's ID") @PathParam("job-spec-id") @NotNull JobSpecId jobSpecId) throws IOException { if (jobSpecId == null) throw new WebApplicationException("Job Spec ID cannot be null", 400); return jobSpecDAO.getJobSpecById(jobSpecId).map(APIJobSpec::fromJobSpec); } }
JobSpecResource { @GET @Path("{job-spec-id}") @Operation( summary = "Get a a job spec.", description = "If found, returns a job spec. A job spec describes declaratively what a " + "job needs in order to run.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job specification found and returned", content = @Content( schema = @Schema(implementation = APIJobSpec.class) )), @ApiResponse( responseCode = "404", description = "The job specification cannot be found", content = @Content( schema = @Schema(implementation = APIErrorMessage.class) )) }) @PermitAll public Optional<APIJobSpec> fetchJobSpecDetailsById( @Context SecurityContext context, @Parameter(description = "The job spec's ID") @PathParam("job-spec-id") @NotNull JobSpecId jobSpecId) throws IOException { if (jobSpecId == null) throw new WebApplicationException("Job Spec ID cannot be null", 400); return jobSpecDAO.getJobSpecById(jobSpecId).map(APIJobSpec::fromJobSpec); } JobSpecResource(JobSpecDAO jobSpecDAO, int defaultPageSize); }
JobSpecResource { @GET @Path("{job-spec-id}") @Operation( summary = "Get a a job spec.", description = "If found, returns a job spec. A job spec describes declaratively what a " + "job needs in order to run.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job specification found and returned", content = @Content( schema = @Schema(implementation = APIJobSpec.class) )), @ApiResponse( responseCode = "404", description = "The job specification cannot be found", content = @Content( schema = @Schema(implementation = APIErrorMessage.class) )) }) @PermitAll public Optional<APIJobSpec> fetchJobSpecDetailsById( @Context SecurityContext context, @Parameter(description = "The job spec's ID") @PathParam("job-spec-id") @NotNull JobSpecId jobSpecId) throws IOException { if (jobSpecId == null) throw new WebApplicationException("Job Spec ID cannot be null", 400); return jobSpecDAO.getJobSpecById(jobSpecId).map(APIJobSpec::fromJobSpec); } JobSpecResource(JobSpecDAO jobSpecDAO, int defaultPageSize); @GET @Operation( summary = "Get summaries of the job specs exposed by the system", description = "Returns an object that contains summaries of *some* of the job specs exposed by the system. " + "The response does not necessarily contain summaries for *all* job specs exposed by the system. " + "This is because pagination and client permissions may hide job specs. If further pages of job specs are " + "available, links shall be set to contain hrefs which the client may use to fetch more specs." + "The server may reorder job spec summaries based on its configuration or knowledge about the user. " + "If a client sets a query string, the server will respond appropriately; however, the same rules apply.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job summaries returned", content = @Content( schema = @Schema(implementation = APIJobSpecSummaryCollection.class) )), }) @PermitAll APIJobSpecSummaryCollection fetchJobSpecSummaries(
            @Context
                    SecurityContext context,
            @Parameter(description = "The page number (0-indexed)")
            @QueryParam("page")
                    Optional<Integer> page,
            @Parameter(description = "The number of entries a response page should contain.")
            @QueryParam("page-size")
                    Optional<Integer> pageSize,
            @Parameter(description = "Client query string")
            @QueryParam("query")
                    Optional<String> query); @GET @Path("{job-spec-id}") @Operation( summary = "Get a a job spec.", description = "If found, returns a job spec. A job spec describes declaratively what a " + "job needs in order to run.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job specification found and returned", content = @Content( schema = @Schema(implementation = APIJobSpec.class) )), @ApiResponse( responseCode = "404", description = "The job specification cannot be found", content = @Content( schema = @Schema(implementation = APIErrorMessage.class) )) }) @PermitAll Optional<APIJobSpec> fetchJobSpecDetailsById(
            @Context
                    SecurityContext context,
            @Parameter(description = "The job spec's ID")
            @PathParam("job-spec-id")
            @NotNull
                    JobSpecId jobSpecId); }
JobSpecResource { @GET @Path("{job-spec-id}") @Operation( summary = "Get a a job spec.", description = "If found, returns a job spec. A job spec describes declaratively what a " + "job needs in order to run.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job specification found and returned", content = @Content( schema = @Schema(implementation = APIJobSpec.class) )), @ApiResponse( responseCode = "404", description = "The job specification cannot be found", content = @Content( schema = @Schema(implementation = APIErrorMessage.class) )) }) @PermitAll public Optional<APIJobSpec> fetchJobSpecDetailsById( @Context SecurityContext context, @Parameter(description = "The job spec's ID") @PathParam("job-spec-id") @NotNull JobSpecId jobSpecId) throws IOException { if (jobSpecId == null) throw new WebApplicationException("Job Spec ID cannot be null", 400); return jobSpecDAO.getJobSpecById(jobSpecId).map(APIJobSpec::fromJobSpec); } JobSpecResource(JobSpecDAO jobSpecDAO, int defaultPageSize); @GET @Operation( summary = "Get summaries of the job specs exposed by the system", description = "Returns an object that contains summaries of *some* of the job specs exposed by the system. " + "The response does not necessarily contain summaries for *all* job specs exposed by the system. " + "This is because pagination and client permissions may hide job specs. If further pages of job specs are " + "available, links shall be set to contain hrefs which the client may use to fetch more specs." + "The server may reorder job spec summaries based on its configuration or knowledge about the user. " + "If a client sets a query string, the server will respond appropriately; however, the same rules apply.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job summaries returned", content = @Content( schema = @Schema(implementation = APIJobSpecSummaryCollection.class) )), }) @PermitAll APIJobSpecSummaryCollection fetchJobSpecSummaries(
            @Context
                    SecurityContext context,
            @Parameter(description = "The page number (0-indexed)")
            @QueryParam("page")
                    Optional<Integer> page,
            @Parameter(description = "The number of entries a response page should contain.")
            @QueryParam("page-size")
                    Optional<Integer> pageSize,
            @Parameter(description = "Client query string")
            @QueryParam("query")
                    Optional<String> query); @GET @Path("{job-spec-id}") @Operation( summary = "Get a a job spec.", description = "If found, returns a job spec. A job spec describes declaratively what a " + "job needs in order to run.") @ApiResponses(value = { @ApiResponse( responseCode = "200", description = "Job specification found and returned", content = @Content( schema = @Schema(implementation = APIJobSpec.class) )), @ApiResponse( responseCode = "404", description = "The job specification cannot be found", content = @Content( schema = @Schema(implementation = APIErrorMessage.class) )) }) @PermitAll Optional<APIJobSpec> fetchJobSpecDetailsById(
            @Context
                    SecurityContext context,
            @Parameter(description = "The job spec's ID")
            @PathParam("job-spec-id")
            @NotNull
                    JobSpecId jobSpecId);  }