KeysResource { @Path("/{key:" + KEY_PATTERN + "}") public KeyResource forKey(@PathParam("key") String key) { LOGGER.trace("locate sub-resource:{}", key); return new KeyResource(key, members, distributedStore); } KeysResource(Set<ClusterMember> members, DistributedStore distributedStore); @Path("/{key:" + KEY_PATTERN + "}") KeyResource forKey(@PathParam("key") String key); @GET @Produces(MediaType.APPLICATION_JSON) Collection<KeyValue> getAll();  }
@Test public void shouldReturnNewKeyResourceWhenForKeyIsCalled() { KeyResource keyResource = keysResource.forKey("key"); assertThat(keyResource.getKey(), equalTo("key")); }