CassandraConfig { @GET @Path("/get_seeds") public Response getSeeds() { try { final List<String> seeds = priamServer.getInstanceIdentity().getSeeds(); if (!seeds.isEmpty()) { metrics.incGetSeeds(); return Response.ok(StringUtils.join(seeds, ',')).build(); } logger.error("Cannot find the Seeds"); } catch (Exception e) { logger.error("Error while executing get_seeds", e); return Response.serverError().build(); } return Response.status(500).build(); } @Inject  CassandraConfig(PriamServer server, DoubleRing doubleRing, CassMonitorMetrics metrics); @GET @Path("/get_seeds") Response getSeeds(); @GET @Path("/get_token") Response getToken(); @GET @Path("/is_replace_token") Response isReplaceToken(); @GET @Path("/get_replaced_ip") Response getReplacedIp(); @POST @Path("/set_replaced_ip") Response setReplacedIp(@QueryParam("ip") String ip); @GET @Path("/get_extra_env_params") Response getExtraEnvParams(); @GET @Path("/double_ring") Response doubleRing();  }
@Test public void getSeeds(@Mocked final InstanceIdentity identity) throws Exception { final List<String> seeds = ImmutableList.of("seed1", "seed2", "seed3"); new Expectations() { { priamServer.getInstanceIdentity(); result = identity; times = 1; identity.getSeeds(); result = seeds; times = 1; } }; Response response = resource.getSeeds(); assertEquals(200, response.getStatus()); assertEquals("seed1,seed2,seed3", response.getEntity()); }
@Test public void getSeeds_notFound(@Mocked final InstanceIdentity identity) throws Exception { final List<String> seeds = ImmutableList.of(); new Expectations() { { priamServer.getInstanceIdentity(); result = identity; times = 1; identity.getSeeds(); result = seeds; times = 1; } }; Response response = resource.getSeeds(); assertEquals(500, response.getStatus()); }
@Test public void getSeeds_handlesUnknownHostException(@Mocked final InstanceIdentity identity) throws Exception { new Expectations() { { priamServer.getInstanceIdentity(); result = identity; identity.getSeeds(); result = new UnknownHostException(); } }; Response response = resource.getSeeds(); assertEquals(500, response.getStatus()); }