@Test
 @SuppressWarnings("unchecked")
 public void getComponentSubscriptionByAnAuthenticatedUser() throws Exception {
   WebResource resource = resource();
   UserDetailWithProfiles user = new UserDetailWithProfiles();
   user.setFirstName("Bart");
   user.setLastName("Simpson");
   user.setId("10");
   user.addProfile(COMPONENT_ID, SilverpeasRole.writer);
   user.addProfile(COMPONENT_ID, SilverpeasRole.user);
   String sessionKey = authenticate(user);
   SubscriptionService mockedSubscriptionService = mock(SubscriptionService.class);
   ComponentSubscription subscription = new ComponentSubscription("10", COMPONENT_ID);
   Collection<ComponentSubscription> subscriptions = Lists.newArrayList(subscription);
   when((Collection<ComponentSubscription>)
           mockedSubscriptionService.getUserSubscriptionsByComponent("10", COMPONENT_ID))
       .thenReturn(subscriptions);
   getTestResources()
       .getMockableSubscriptionService()
       .setImplementation(mockedSubscriptionService);
   SubscriptionEntity[] entities =
       resource
           .path(SUBSCRIPTION_RESOURCE_PATH)
           .header(HTTP_SESSIONKEY, sessionKey)
           .accept(MediaType.APPLICATION_JSON)
           .get(SubscriptionEntity[].class);
   assertNotNull(entities);
   assertThat(entities.length, is(1));
   assertThat(entities[0], SubscriptionEntityMatcher.matches((Subscription) subscription));
 }
 @Test
 @SuppressWarnings("unchecked")
 public void getComponentSubscribersByAnAuthenticatedUser() throws Exception {
   WebResource resource = resource();
   UserDetailWithProfiles user = new UserDetailWithProfiles();
   user.setFirstName("Bart");
   user.setLastName("Simpson");
   user.setId("10");
   user.addProfile(COMPONENT_ID, SilverpeasRole.writer);
   user.addProfile(COMPONENT_ID, SilverpeasRole.user);
   String sessionKey = authenticate(user);
   SubscriptionService mockedSubscriptionService = mock(SubscriptionService.class);
   List<String> subscribers = Lists.newArrayList("5", "6", "7", "20");
   when(mockedSubscriptionService.getSubscribers(new ForeignPK("0", COMPONENT_ID)))
       .thenReturn(subscribers);
   getTestResources()
       .getMockableSubscriptionService()
       .setImplementation(mockedSubscriptionService);
   String[] entities =
       resource
           .path(SUBSCRIPTION_RESOURCE_PATH + "/subscribers/0")
           .header(HTTP_SESSIONKEY, sessionKey)
           .accept(MediaType.APPLICATION_JSON)
           .get(String[].class);
   assertNotNull(entities);
   assertThat(entities.length, is(4));
   assertThat(entities, is(new String[] {"5", "6", "7", "20"}));
 }