### Question:
CassandraRingResource { @GET @Path("{name}") public CassandraRing findByName(@PathParam("name") String name) { return getByNameIfFound(name); } @Inject  CassandraRingResource(CassandraRingService service,
      CassandraInstanceResourceFactory instanceResourceFactory,
      SeedResourceFactory seedResourceFactory); @GET Set<CassandraRing> findAll(); @POST Response createRing(@Valid CassandraRing ring); @GET @Path("{name}") CassandraRing findByName(@PathParam("name") String name); @DELETE @Path("{name}") Response deleteRing(@PathParam("name") String name); @Path("{name}/instances") CassandraInstanceResource getCassandraInstanceResource(@PathParam("name") String name); @Path("{name}/seeds") SeedResource getSeedResource(@PathParam("name") String name);  }### Answer:
@Test public void findByName() throws Exception { CassandraRing ring = createMock(CassandraRing.class); expect(service.findByName(RING_NAME)).andReturn(ring); replayAll(); assertEquals(ring, resource.findByName(RING_NAME)); }
@Test public void findByName_notFound() throws Exception { expect(service.findByName(RING_NAME)).andReturn(null); replayAll(); try { resource.findByName(RING_NAME); fail("Expected NotFoundException"); } catch (NotFoundException e) { assertEquals(Status.NOT_FOUND.getStatusCode(), e.getResponse().getStatus()); assertEquals("No ring found with name: " + RING_NAME, e.getResponse().getEntity()); } }