@Test public void testAcceptRepresentation() 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)); oneOf(mapper).insert(with(any(FeedReader.class))); } }); sut.acceptRepresentation(entity); context.assertIsSatisfied(); }
@Override public void acceptRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); entityMapper.insert(feedReader); } 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 acceptRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); entityMapper.insert(feedReader); } 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 acceptRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); entityMapper.insert(feedReader); } 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 acceptRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); entityMapper.insert(feedReader); } 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 acceptRepresentation(final Representation entity) throws ResourceException { try { JSONObject jsonObject = JSONObject.fromObject(entity.getText()); FeedReader feedReader = convertJSONObjectToFeed(jsonObject); entityMapper.insert(feedReader); } 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);  }