### Question:
ContainerEndpoint { @GET @Path("/unhealthy/{state}") public Response getUnhealthyContainers( @PathParam("state") String state, @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT) int limit, @DefaultValue(DEFAULT_BATCH_NUMBER) @QueryParam(RECON_QUERY_BATCH_PARAM) int batchNum) { int offset = Math.max(((batchNum - 1) * limit), 0); List<UnhealthyContainerMetadata> unhealthyMeta = new ArrayList<>(); List<UnhealthyContainersSummary> summary; try { UnHealthyContainerStates internalState = null; if (state != null) { internalState = UnHealthyContainerStates.valueOf(state); } summary = containerSchemaManager.getUnhealthyContainersSummary(); List<UnhealthyContainers> containers = containerSchemaManager .getUnhealthyContainers(internalState, offset, limit); for (UnhealthyContainers c : containers) { long containerID = c.getContainerId(); ContainerInfo containerInfo = containerManager.getContainer(new ContainerID(containerID)); long keyCount = containerInfo.getNumberOfKeys(); UUID pipelineID = containerInfo.getPipelineID().getId(); List<ContainerHistory> datanodes = containerSchemaManager.getLatestContainerHistory( containerID, containerInfo.getReplicationFactor().getNumber()); unhealthyMeta.add(new UnhealthyContainerMetadata( c, datanodes, pipelineID, keyCount)); } } catch (IOException ex) { throw new WebApplicationException(ex, Response.Status.INTERNAL_SERVER_ERROR); } catch (IllegalArgumentException e) { throw new WebApplicationException(e, Response.Status.BAD_REQUEST); } UnhealthyContainersResponse response = new UnhealthyContainersResponse(unhealthyMeta); for (UnhealthyContainersSummary s : summary) { response.setSummaryCount(s.getContainerState(), s.getCount()); } return Response.ok(response).build(); } @Inject  ContainerEndpoint(OzoneStorageContainerManager reconSCM,
                           ContainerSchemaManager containerSchemaManager); @GET Response getContainers(
      @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT)
          int limit,
      @DefaultValue(PREV_CONTAINER_ID_DEFAULT_VALUE)
      @QueryParam(RECON_QUERY_PREVKEY) long prevKey); @GET @Path("/{id}/keys") Response getKeysForContainer(
      @PathParam("id") Long containerID,
      @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT)
          int limit,
      @DefaultValue(StringUtils.EMPTY) @QueryParam(RECON_QUERY_PREVKEY)
          String prevKeyPrefix); @GET @Path("/{id}/replicaHistory") Response getReplicaHistoryForContainer(
      @PathParam("id") Long containerID); @GET @Path("/missing") Response getMissingContainers(); @GET @Path("/unhealthy/{state}") Response getUnhealthyContainers(
      @PathParam("state") String state,
      @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT)
          int limit,
      @DefaultValue(DEFAULT_BATCH_NUMBER)
      @QueryParam(RECON_QUERY_BATCH_PARAM) int batchNum); @GET @Path("/unhealthy") Response getUnhealthyContainers(
      @DefaultValue(DEFAULT_FETCH_COUNT) @QueryParam(RECON_QUERY_LIMIT)
          int limit,
      @DefaultValue(DEFAULT_BATCH_NUMBER)
      @QueryParam(RECON_QUERY_BATCH_PARAM) int batchNum);  }### Answer:
@Test public void testUnhealthyContainersInvalidState() { try { containerEndpoint.getUnhealthyContainers("invalid", 1000, 1); fail("Expected exception to be raised"); } catch (WebApplicationException e) { assertEquals("HTTP 400 Bad Request", e.getMessage()); } }