RepairRunResource { static Set splitStateParam(Optional<String> state) { if (state.isPresent()) { final Iterable<String> chunks = RepairRunService.COMMA_SEPARATED_LIST_SPLITTER.split(state.get()); for (final String chunk : chunks) { try { RepairRun.RunState.valueOf(chunk.toUpperCase()); } catch (IllegalArgumentException e) { LOG.warn("Listing repair runs called with erroneous states: {}", state.get(), e); return null; } } return Sets.newHashSet(chunks); } else { return Sets.newHashSet(); } } RepairRunResource(AppContext context); @POST Response addRepairRun(
      @Context UriInfo uriInfo,
      @QueryParam("clusterName") Optional<String> clusterName,
      @QueryParam("keyspace") Optional<String> keyspace,
      @QueryParam("tables") Optional<String> tableNamesParam,
      @QueryParam("owner") Optional<String> owner,
      @QueryParam("cause") Optional<String> cause,
      @QueryParam("segmentCount") Optional<Integer> segmentCountPerNode,
      @QueryParam("repairParallelism") Optional<String> repairParallelism,
      @QueryParam("intensity") Optional<String> intensityStr,
      @QueryParam("incrementalRepair") Optional<String> incrementalRepairStr,
      @QueryParam("nodes") Optional<String> nodesToRepairParam,
      @QueryParam("datacenters") Optional<String> datacentersToRepairParam,
      @QueryParam("blacklistedTables") Optional<String> blacklistedTableNamesParam,
      @QueryParam("repairThreadCount") Optional<Integer> repairThreadCountParam); @PUT @Path("/{id}/state/{state}") Response modifyRunState(
      @Context UriInfo uriInfo,
      @PathParam("id") UUID repairRunId,
      @PathParam("state") Optional<String> stateStr); @PUT @Path("/{id}/intensity/{intensity}") Response modifyRunIntensity(
      @Context UriInfo uriInfo,
      @PathParam("id") UUID repairRunId,
      @PathParam("intensity") Optional<String> intensityStr); @PUT @Path("/{id}") @Deprecated Response oldModifyRunState(
      @Context UriInfo uriInfo,
      @PathParam("id") UUID repairRunId,
      @QueryParam("state") Optional<String> stateStr); @GET @Path("/{id}") Response getRepairRun(
      @PathParam("id") UUID repairRunId); @GET @Path("/{id}/segments") Response getRepairRunSegments(@PathParam("id") UUID repairRunId); @POST @Path("/{id}/segments/abort/{segment_id}") Response abortRepairRunSegment(@PathParam("id") UUID repairRunId, @PathParam("segment_id") UUID segmentId); @GET @Path("/cluster/{cluster_name}") Response getRepairRunsForCluster(
      @PathParam("cluster_name") String clusterName,
      @QueryParam("limit") Optional<Integer> limit); @GET Response listRepairRuns(
      @QueryParam("state") Optional<String> state,
      @QueryParam("cluster_name") Optional<String> cluster,
      @QueryParam("keyspace_name") Optional<String> keyspace,
      @QueryParam("limit") Optional<Integer> limit); @DELETE @Path("/{id}") Response deleteRepairRun(
      @PathParam("id") UUID runId,
      @QueryParam("owner") Optional<String> owner); @POST @Path("/purge") Response purgeRepairRuns();  }
@Test public void testSplitStateParam() { Optional<String> stateParam = Optional.of("RUNNING"); assertEquals(Sets.newHashSet("RUNNING"), RepairRunResource.splitStateParam(stateParam)); stateParam = Optional.of("PAUSED,RUNNING"); assertEquals(Sets.newHashSet("RUNNING", "PAUSED"), RepairRunResource.splitStateParam(stateParam)); stateParam = Optional.of("NOT_EXISTING"); assertEquals(null, RepairRunResource.splitStateParam(stateParam)); stateParam = Optional.of("NOT_EXISTING,RUNNING"); assertEquals(null, RepairRunResource.splitStateParam(stateParam)); stateParam = Optional.of("RUNNING,PAUSED,"); assertEquals(Sets.newHashSet("RUNNING", "PAUSED"), RepairRunResource.splitStateParam(stateParam)); stateParam = Optional.of(",RUNNING,PAUSED,"); assertEquals(Sets.newHashSet("RUNNING", "PAUSED"), RepairRunResource.splitStateParam(stateParam)); stateParam = Optional.of("PAUSED ,RUNNING"); assertEquals(Sets.newHashSet("RUNNING", "PAUSED"), RepairRunResource.splitStateParam(stateParam)); }