ExperimentRestApi { @GET @Operation(summary = "List experiments", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class)))}) public Response listExperiments(@QueryParam("status") String status) { try { List<Experiment> experimentList = experimentManager.listExperimentsByStatus(status); return new JsonResponse.Builder<List<Experiment>>(Response.Status.OK).success(true) .result(experimentList).build(); } catch (SubmarineRuntimeException e) { return parseExperimentServiceException(e); } }  @VisibleForTesting void setExperimentManager(ExperimentManager experimentManager); @GET @Path(RestConstants.PING) @Consumes(MediaType.APPLICATION_JSON) @Operation(summary = "Ping submarine server", tags = {"experiment"}, description = "Return the Pong message for test the connectivity", responses = { @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class)))}) Response ping(); @POST @Consumes({RestConstants.MEDIA_TYPE_YAML, MediaType.APPLICATION_JSON}) @Operation(summary = "Create an experiment", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class)))}) Response createExperiment(ExperimentSpec spec); @POST @Path("/{name}") @Consumes({RestConstants.MEDIA_TYPE_YAML, MediaType.APPLICATION_JSON}) @Operation(summary = "use experiment template to create an experiment", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class)))}) Response SubmitExperimentTemplate(@PathParam("name") String name, 
        ExperimentTemplateSubmit spec); @GET @Operation(summary = "List experiments", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class)))}) Response listExperiments(@QueryParam("status") String status); @GET @Path("/{id}") @Operation(summary = "Get the experiment's detailed info by id", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class))), @ApiResponse(responseCode = "404", description = "Experiment not found")}) Response getExperiment(@PathParam(RestConstants.ID) String id); @PATCH @Path("/{id}") @Consumes({RestConstants.MEDIA_TYPE_YAML, MediaType.APPLICATION_JSON}) @Operation(summary = "Update the experiment in the submarine server with spec", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class))), @ApiResponse(responseCode = "404", description = "Experiment not found")}) Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec); @DELETE @Path("/{id}") @Operation(summary = "Delete the experiment", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class))), @ApiResponse(responseCode = "404", description = "Experiment not found")}) Response deleteExperiment(@PathParam(RestConstants.ID) String id); @GET @Path("/logs") @Operation(summary = "List experiment's log", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class)))}) Response listLog(@QueryParam("status") String status); @GET @Path("/logs/{id}") @Operation(summary = "Log experiment by id", tags = {"experiment"}, responses = { @ApiResponse(description = "successful operation", content = @Content( schema = @Schema(implementation = JsonResponse.class))), @ApiResponse(responseCode = "404", description = "Experiment not found")}) Response getLog(@PathParam(RestConstants.ID) String id);  }
@Test public void testListExperiment() { Experiment experiment2 = new Experiment(); experiment2.rebuild(actualExperiment); String experiment2Uid = "0b617cea-81fa-40b6-bbff-da3e400d2be5"; experiment2.setUid(experiment2Uid); experiment2.setExperimentId(experimentId); List<Experiment> experimentList = new ArrayList<>(); experimentList.add(actualExperiment); experimentList.add(experiment2); when(mockExperimentManager.listExperimentsByStatus(any(String.class))).thenReturn(experimentList); Response listExperimentResponse = experimentRestApi.listExperiments(Response.Status.OK.toString()); List<Experiment> result = getResultListFromResponse(listExperimentResponse, Experiment.class); verifyResult(result.get(0), experimentUid); verifyResult(result.get(1), experiment2Uid); }