@Test public void testStoreRepresentation() throws ResourceException, IOException, ParseException { final Representation entity = context.mock(Representation.class); final String json = buildJSONString(); context.checking(new Expectations() { { oneOf(entity).getText(); will(returnValue(json)); setupCommonRepresentExpectations(); oneOf(fr).setUrl(testUrl); oneOf(fr).setFeedTitle(testFeedTitle); oneOf(mapper).flush(); } }); sut.storeRepresentation(entity); context.assertIsSatisfied(); }
@Override public void storeRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); FeedReader toUpdate = entityMapper.findFeedByOpenSocialIdAndModuleId(feedReader.getOpenSocialId(), feedReader.getModuleId()); toUpdate.setUrl(feedReader.getUrl()); toUpdate.setFeedTitle(feedReader.getFeedTitle()); entityMapper.flush(); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } catch (ParseException e) { logger.error("Unable to Parse Json of entity", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to Parse Json of entity"); } }
FeedReaderEntityResource extends FeedReaderResource { @Override public void storeRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); FeedReader toUpdate = entityMapper.findFeedByOpenSocialIdAndModuleId(feedReader.getOpenSocialId(), feedReader.getModuleId()); toUpdate.setUrl(feedReader.getUrl()); toUpdate.setFeedTitle(feedReader.getFeedTitle()); entityMapper.flush(); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } catch (ParseException e) { logger.error("Unable to Parse Json of entity", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to Parse Json of entity"); } } }
FeedReaderEntityResource extends FeedReaderResource { @Override public void storeRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); FeedReader toUpdate = entityMapper.findFeedByOpenSocialIdAndModuleId(feedReader.getOpenSocialId(), feedReader.getModuleId()); toUpdate.setUrl(feedReader.getUrl()); toUpdate.setFeedTitle(feedReader.getFeedTitle()); entityMapper.flush(); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } catch (ParseException e) { logger.error("Unable to Parse Json of entity", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to Parse Json of entity"); } } protected  FeedReaderEntityResource(); }
FeedReaderEntityResource extends FeedReaderResource { @Override public void storeRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); FeedReader toUpdate = entityMapper.findFeedByOpenSocialIdAndModuleId(feedReader.getOpenSocialId(), feedReader.getModuleId()); toUpdate.setUrl(feedReader.getUrl()); toUpdate.setFeedTitle(feedReader.getFeedTitle()); entityMapper.flush(); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } catch (ParseException e) { logger.error("Unable to Parse Json of entity", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to Parse Json of entity"); } } protected  FeedReaderEntityResource(); @Override void removeRepresentations(); @Override Representation represent(final Variant variant); @Override void storeRepresentation(final Representation entity); @Override void acceptRepresentation(final Representation entity); }
FeedReaderEntityResource extends FeedReaderResource { @Override public void storeRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); FeedReader toUpdate = entityMapper.findFeedByOpenSocialIdAndModuleId(feedReader.getOpenSocialId(), feedReader.getModuleId()); toUpdate.setUrl(feedReader.getUrl()); toUpdate.setFeedTitle(feedReader.getFeedTitle()); entityMapper.flush(); } catch (IOException e) { logger.error("No Entity sent with request", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Entity sent with request"); } catch (ParseException e) { logger.error("Unable to Parse Json of entity", e); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to Parse Json of entity"); } } protected  FeedReaderEntityResource(); @Override void removeRepresentations(); @Override Representation represent(final Variant variant); @Override void storeRepresentation(final Representation entity); @Override void acceptRepresentation(final Representation entity);  }