CassandraConfig { @GET @Path("/is_replace_token") public Response isReplaceToken() { try { return Response.ok(String.valueOf(priamServer.getInstanceIdentity().isReplace())) .build(); } catch (Exception e) { logger.error("Error while executing is_replace_token", e); return Response.serverError().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 isReplaceToken(@Mocked final InstanceIdentity identity) { new Expectations() { { priamServer.getInstanceIdentity(); result = identity; identity.isReplace(); result = true; } }; Response response = resource.isReplaceToken(); assertEquals(200, response.getStatus()); assertEquals("true", response.getEntity()); }
@Test public void isReplaceToken_handlesException(@Mocked final InstanceIdentity identity) { new Expectations() { { priamServer.getInstanceIdentity(); result = identity; identity.isReplace(); result = new RuntimeException(); } }; Response response = resource.isReplaceToken(); assertEquals(500, response.getStatus()); }