@Test public void testPatchExperiment() { when(mockExperimentManager.patchExperiment(any(String.class), any(ExperimentSpec.class))). thenReturn(actualExperiment); Response patchExperimentResponse = experimentRestApi.patchExperiment(dummyId, new ExperimentSpec()); Experiment result = getResultFromResponse(patchExperimentResponse, Experiment.class); verifyResult(result, experimentUid); }
@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")}) public Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec) { try { Experiment experiment = experimentManager.patchExperiment(id, spec); return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true) .result(experiment).build(); } catch (SubmarineRuntimeException e) { return parseExperimentServiceException(e); } }
ExperimentRestApi { @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")}) public Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec) { try { Experiment experiment = experimentManager.patchExperiment(id, spec); return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true) .result(experiment).build(); } catch (SubmarineRuntimeException e) { return parseExperimentServiceException(e); } } }
ExperimentRestApi { @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")}) public Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec) { try { Experiment experiment = experimentManager.patchExperiment(id, spec); return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true) .result(experiment).build(); } catch (SubmarineRuntimeException e) { return parseExperimentServiceException(e); } }  }
ExperimentRestApi { @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")}) public Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec) { try { Experiment experiment = experimentManager.patchExperiment(id, spec); return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true) .result(experiment).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); }
ExperimentRestApi { @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")}) public Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec) { try { Experiment experiment = experimentManager.patchExperiment(id, spec); return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true) .result(experiment).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);  }