@Test public void testAcceptRepresentation() throws ResourceException, IOException, ParseException { final Representation entity = context.mock(Representation.class, "rep"); final String json = buildJSONString(); context.checking(new Expectations() { { oneOf(entity).getText(); will(returnValue(json)); oneOf(mapper).findTop10FriendFeeds(json); will(returnValue(listOfFRC)); oneOf(feedReaderCount).getFeedTitle(); will(returnValue(testFeedTitle)); oneOf(feedReaderCount).getUrl(); will(returnValue(testUrl)); oneOf(feedReaderCount).getCount(); will(returnValue(testCount)); oneOf(adaptedResponse).setEntity("[" + buildJSONString() + "]", MediaType.APPLICATION_JSON); } }); sut.acceptRepresentation(entity); context.assertIsSatisfied(); }
@Override public void acceptRepresentation(final Representation entity) throws ResourceException { try { List<FeedReaderUrlCount> feedReader; feedReader = entityMapper.findTop10FriendFeeds(entity.getText()); JSONArray jsonArray = new JSONArray(); for (FeedReaderUrlCount fr : feedReader) { jsonArray.add(convertFeedCountToJSON((FeedReaderUrlCount) fr)); } getAdaptedResponse().setEntity(jsonArray.toString(), MediaType.APPLICATION_JSON); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } }
FeedReaderCollectionResource extends FeedReaderResource { @Override public void acceptRepresentation(final Representation entity) throws ResourceException { try { List<FeedReaderUrlCount> feedReader; feedReader = entityMapper.findTop10FriendFeeds(entity.getText()); JSONArray jsonArray = new JSONArray(); for (FeedReaderUrlCount fr : feedReader) { jsonArray.add(convertFeedCountToJSON((FeedReaderUrlCount) fr)); } getAdaptedResponse().setEntity(jsonArray.toString(), MediaType.APPLICATION_JSON); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } } }
FeedReaderCollectionResource extends FeedReaderResource { @Override public void acceptRepresentation(final Representation entity) throws ResourceException { try { List<FeedReaderUrlCount> feedReader; feedReader = entityMapper.findTop10FriendFeeds(entity.getText()); JSONArray jsonArray = new JSONArray(); for (FeedReaderUrlCount fr : feedReader) { jsonArray.add(convertFeedCountToJSON((FeedReaderUrlCount) fr)); } getAdaptedResponse().setEntity(jsonArray.toString(), MediaType.APPLICATION_JSON); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } } protected  FeedReaderCollectionResource(); }
FeedReaderCollectionResource extends FeedReaderResource { @Override public void acceptRepresentation(final Representation entity) throws ResourceException { try { List<FeedReaderUrlCount> feedReader; feedReader = entityMapper.findTop10FriendFeeds(entity.getText()); JSONArray jsonArray = new JSONArray(); for (FeedReaderUrlCount fr : feedReader) { jsonArray.add(convertFeedCountToJSON((FeedReaderUrlCount) fr)); } getAdaptedResponse().setEntity(jsonArray.toString(), MediaType.APPLICATION_JSON); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } } protected  FeedReaderCollectionResource(); @Override Representation represent(final Variant variant); @Override void acceptRepresentation(final Representation entity); }
FeedReaderCollectionResource extends FeedReaderResource { @Override public void acceptRepresentation(final Representation entity) throws ResourceException { try { List<FeedReaderUrlCount> feedReader; feedReader = entityMapper.findTop10FriendFeeds(entity.getText()); JSONArray jsonArray = new JSONArray(); for (FeedReaderUrlCount fr : feedReader) { jsonArray.add(convertFeedCountToJSON((FeedReaderUrlCount) fr)); } getAdaptedResponse().setEntity(jsonArray.toString(), MediaType.APPLICATION_JSON); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } } protected  FeedReaderCollectionResource(); @Override Representation represent(final Variant variant); @Override void acceptRepresentation(final Representation entity);  }