@Test public void validRequest() throws Exception { String experimentID = BenchFlowData.VALID_EXPERIMENT_ID_1_TRIAL; Mockito.doReturn(true).when(minioMock).isValidExperimentID(experimentID); String[] experimentIDArray = experimentID.split(MODEL_ID_DELIMITER_REGEX); String username = experimentIDArray[0]; String testName = experimentIDArray[1]; int testNumber = Integer.parseInt(experimentIDArray[2]); int experimentNumber = Integer.parseInt(experimentIDArray[3]); experimentResource.runBenchFlowExperiment(username, testName, testNumber, experimentNumber); Mockito.verify(experimentModelDAOMock, Mockito.times(1)).addExperiment(experimentID); Mockito.verify(minioMock, Mockito.times(1)).isValidExperimentID(experimentID); }
@POST @Path("/run") public void runBenchFlowExperiment(@PathParam("username") String username, @PathParam("testName") String testName, @PathParam("testNumber") int testNumber, @PathParam("experimentNumber") int experimentNumber) { String experimentID = BenchFlowConstants.getExperimentID(username, testName, testNumber, experimentNumber); logger.info("request received: POST " + BenchFlowConstants.getPathFromExperimentID(experimentID) + RUN_ACTION_PATH); if (!minio.isValidExperimentID(experimentID)) { logger.info("invalid experimentID: " + experimentID); throw new WebApplicationException(BenchFlowConstants.INVALID_EXPERIMENT_ID_MESSAGE, Response.Status.PRECONDITION_FAILED); } experimentModelDAO.addExperiment(experimentID); new Thread(() -> experimentTaskScheduler.handleStartingExperiment(experimentID)).start(); }
BenchFlowExperimentResource { @POST @Path("/run") public void runBenchFlowExperiment(@PathParam("username") String username, @PathParam("testName") String testName, @PathParam("testNumber") int testNumber, @PathParam("experimentNumber") int experimentNumber) { String experimentID = BenchFlowConstants.getExperimentID(username, testName, testNumber, experimentNumber); logger.info("request received: POST " + BenchFlowConstants.getPathFromExperimentID(experimentID) + RUN_ACTION_PATH); if (!minio.isValidExperimentID(experimentID)) { logger.info("invalid experimentID: " + experimentID); throw new WebApplicationException(BenchFlowConstants.INVALID_EXPERIMENT_ID_MESSAGE, Response.Status.PRECONDITION_FAILED); } experimentModelDAO.addExperiment(experimentID); new Thread(() -> experimentTaskScheduler.handleStartingExperiment(experimentID)).start(); } }
BenchFlowExperimentResource { @POST @Path("/run") public void runBenchFlowExperiment(@PathParam("username") String username, @PathParam("testName") String testName, @PathParam("testNumber") int testNumber, @PathParam("experimentNumber") int experimentNumber) { String experimentID = BenchFlowConstants.getExperimentID(username, testName, testNumber, experimentNumber); logger.info("request received: POST " + BenchFlowConstants.getPathFromExperimentID(experimentID) + RUN_ACTION_PATH); if (!minio.isValidExperimentID(experimentID)) { logger.info("invalid experimentID: " + experimentID); throw new WebApplicationException(BenchFlowConstants.INVALID_EXPERIMENT_ID_MESSAGE, Response.Status.PRECONDITION_FAILED); } experimentModelDAO.addExperiment(experimentID); new Thread(() -> experimentTaskScheduler.handleStartingExperiment(experimentID)).start(); } BenchFlowExperimentResource();  BenchFlowExperimentResource(MinioService minio,
      BenchFlowExperimentModelDAO experimentModelDAO,
      ExperimentTaskScheduler experimentTaskScheduler); }
BenchFlowExperimentResource { @POST @Path("/run") public void runBenchFlowExperiment(@PathParam("username") String username, @PathParam("testName") String testName, @PathParam("testNumber") int testNumber, @PathParam("experimentNumber") int experimentNumber) { String experimentID = BenchFlowConstants.getExperimentID(username, testName, testNumber, experimentNumber); logger.info("request received: POST " + BenchFlowConstants.getPathFromExperimentID(experimentID) + RUN_ACTION_PATH); if (!minio.isValidExperimentID(experimentID)) { logger.info("invalid experimentID: " + experimentID); throw new WebApplicationException(BenchFlowConstants.INVALID_EXPERIMENT_ID_MESSAGE, Response.Status.PRECONDITION_FAILED); } experimentModelDAO.addExperiment(experimentID); new Thread(() -> experimentTaskScheduler.handleStartingExperiment(experimentID)).start(); } BenchFlowExperimentResource();  BenchFlowExperimentResource(MinioService minio,
      BenchFlowExperimentModelDAO experimentModelDAO,
      ExperimentTaskScheduler experimentTaskScheduler); @POST @Path("/run") void runBenchFlowExperiment(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); @GET @Path("/state") @Produces(MediaType.APPLICATION_JSON) BenchFlowExperimentStateResponse getExperimentState(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); @GET @Path("/status") @Produces(MediaType.APPLICATION_JSON) BenchFlowExperimentModel getExperimentStatus(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); @PUT @Path("/state") @Consumes(MediaType.APPLICATION_JSON) BenchFlowExperimentStateResponse changeExperimentState(
      @PathParam("username") String username, @PathParam("testName") String testName,
      @PathParam("testNumber") int testNumber, @PathParam("experimentNumber") int experimentNumber,
      @NotNull @Valid BenchFlowExperimentStateRequest stateRequest); @POST @Path("/abort") void abortExperiment(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); }
BenchFlowExperimentResource { @POST @Path("/run") public void runBenchFlowExperiment(@PathParam("username") String username, @PathParam("testName") String testName, @PathParam("testNumber") int testNumber, @PathParam("experimentNumber") int experimentNumber) { String experimentID = BenchFlowConstants.getExperimentID(username, testName, testNumber, experimentNumber); logger.info("request received: POST " + BenchFlowConstants.getPathFromExperimentID(experimentID) + RUN_ACTION_PATH); if (!minio.isValidExperimentID(experimentID)) { logger.info("invalid experimentID: " + experimentID); throw new WebApplicationException(BenchFlowConstants.INVALID_EXPERIMENT_ID_MESSAGE, Response.Status.PRECONDITION_FAILED); } experimentModelDAO.addExperiment(experimentID); new Thread(() -> experimentTaskScheduler.handleStartingExperiment(experimentID)).start(); } BenchFlowExperimentResource();  BenchFlowExperimentResource(MinioService minio,
      BenchFlowExperimentModelDAO experimentModelDAO,
      ExperimentTaskScheduler experimentTaskScheduler); @POST @Path("/run") void runBenchFlowExperiment(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); @GET @Path("/state") @Produces(MediaType.APPLICATION_JSON) BenchFlowExperimentStateResponse getExperimentState(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); @GET @Path("/status") @Produces(MediaType.APPLICATION_JSON) BenchFlowExperimentModel getExperimentStatus(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); @PUT @Path("/state") @Consumes(MediaType.APPLICATION_JSON) BenchFlowExperimentStateResponse changeExperimentState(
      @PathParam("username") String username, @PathParam("testName") String testName,
      @PathParam("testNumber") int testNumber, @PathParam("experimentNumber") int experimentNumber,
      @NotNull @Valid BenchFlowExperimentStateRequest stateRequest); @POST @Path("/abort") void abortExperiment(@PathParam("username") String username,
      @PathParam("testName") String testName, @PathParam("testNumber") int testNumber,
      @PathParam("experimentNumber") int experimentNumber); static final String RUN_ACTION_PATH; static final String ACTION_PATH; static final String STATUS_PATH; static final String ABORT_PATH; }