@Test(expected = NullPointerException.class) public void testNullPointerExceptionOnInvalidCollectionCodeInGenerateTweetsIDSCSVFromAllJSON() throws UnknownHostException { boolean downloadLimited = false; persister4CollectorAPI.generateTweetsIDSCSVFromAllJSON(sampleCollectionCode , downloadLimited); }
@GET @Produces(MediaType.APPLICATION_JSON) @Path("/genTweetIds") public Response generateTweetsIDSCSVFromAllJSON(@QueryParam("collectionCode") String collectionCode, @DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited) throws UnknownHostException { logger.info("Received request for collection: " + collectionCode); JsonDeserializer jsonD = new JsonDeserializer(); Map<String, Object> result = jsonD.generateJson2TweetIdsCSV(collectionCode, downloadLimited); String fileName = PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.PERSISTER_DOWNLOAD_URL) + collectionCode+"/" + (String) result.get("fileName"); logger.info("Done processing request for collection: " + collectionCode + ", returning created file: " + fileName); JSONObject obj = new JSONObject(); obj.put("feedCount", result.get("count")); if ((Integer) result.get("count") < Integer.parseInt(PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT)) ) { obj.putAll(ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); return Response.ok(obj.toJSONString()).build(); } else { obj.putAll(ResultStatus.getUIWrapper(collectionCode,PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); return Response.ok(obj.toJSONString()).build(); } }
Persister4CollectorAPI { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genTweetIds") public Response generateTweetsIDSCSVFromAllJSON(@QueryParam("collectionCode") String collectionCode, @DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited) throws UnknownHostException { logger.info("Received request for collection: " + collectionCode); JsonDeserializer jsonD = new JsonDeserializer(); Map<String, Object> result = jsonD.generateJson2TweetIdsCSV(collectionCode, downloadLimited); String fileName = PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.PERSISTER_DOWNLOAD_URL) + collectionCode+"/" + (String) result.get("fileName"); logger.info("Done processing request for collection: " + collectionCode + ", returning created file: " + fileName); JSONObject obj = new JSONObject(); obj.put("feedCount", result.get("count")); if ((Integer) result.get("count") < Integer.parseInt(PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT)) ) { obj.putAll(ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); return Response.ok(obj.toJSONString()).build(); } else { obj.putAll(ResultStatus.getUIWrapper(collectionCode,PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); return Response.ok(obj.toJSONString()).build(); } } }
Persister4CollectorAPI { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genTweetIds") public Response generateTweetsIDSCSVFromAllJSON(@QueryParam("collectionCode") String collectionCode, @DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited) throws UnknownHostException { logger.info("Received request for collection: " + collectionCode); JsonDeserializer jsonD = new JsonDeserializer(); Map<String, Object> result = jsonD.generateJson2TweetIdsCSV(collectionCode, downloadLimited); String fileName = PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.PERSISTER_DOWNLOAD_URL) + collectionCode+"/" + (String) result.get("fileName"); logger.info("Done processing request for collection: " + collectionCode + ", returning created file: " + fileName); JSONObject obj = new JSONObject(); obj.put("feedCount", result.get("count")); if ((Integer) result.get("count") < Integer.parseInt(PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT)) ) { obj.putAll(ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); return Response.ok(obj.toJSONString()).build(); } else { obj.putAll(ResultStatus.getUIWrapper(collectionCode,PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); return Response.ok(obj.toJSONString()).build(); } } Persister4CollectorAPI(); }
Persister4CollectorAPI { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genTweetIds") public Response generateTweetsIDSCSVFromAllJSON(@QueryParam("collectionCode") String collectionCode, @DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited) throws UnknownHostException { logger.info("Received request for collection: " + collectionCode); JsonDeserializer jsonD = new JsonDeserializer(); Map<String, Object> result = jsonD.generateJson2TweetIdsCSV(collectionCode, downloadLimited); String fileName = PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.PERSISTER_DOWNLOAD_URL) + collectionCode+"/" + (String) result.get("fileName"); logger.info("Done processing request for collection: " + collectionCode + ", returning created file: " + fileName); JSONObject obj = new JSONObject(); obj.put("feedCount", result.get("count")); if ((Integer) result.get("count") < Integer.parseInt(PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT)) ) { obj.putAll(ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); return Response.ok(obj.toJSONString()).build(); } else { obj.putAll(ResultStatus.getUIWrapper(collectionCode,PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); return Response.ok(obj.toJSONString()).build(); } } Persister4CollectorAPI(); @GET @Produces("application/json") @Consumes("application/json") @Path("/start") Response startPersister(@QueryParam("file") String fileLocation, @QueryParam("collectionCode") String collectionCode); @GET @Produces("application/json") @Consumes("application/json") @Path("/stop") Response stopPersister(@QueryParam("collectionCode") String collectionCode); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genCSV") Response generateCSVFromLastestJSON(@QueryParam("collectionCode") String collectionCode,
    				@QueryParam("exportLimit") int exportLimit); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genTweetIds") Response generateTweetsIDSCSVFromAllJSON(@QueryParam("collectionCode") String collectionCode,
    		@DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited); @GET @Produces("application/json") @Path("/ping") Response ping(); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genJson") Response generateJSONFromLastestJSON(@QueryParam("collectionCode") String collectionCode,
    		@DefaultValue(DownloadType.TEXT_JSON) @QueryParam("jsonType") String jsonType); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genJsonTweetIds") Response generateTweetsIDSJSONFromAllJSON(@QueryParam("collectionCode") String collectionCode,
    			@DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited,
    			@DefaultValue(DownloadType.TEXT_JSON) @QueryParam("jsonType") String jsonType); }
Persister4CollectorAPI { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genTweetIds") public Response generateTweetsIDSCSVFromAllJSON(@QueryParam("collectionCode") String collectionCode, @DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited) throws UnknownHostException { logger.info("Received request for collection: " + collectionCode); JsonDeserializer jsonD = new JsonDeserializer(); Map<String, Object> result = jsonD.generateJson2TweetIdsCSV(collectionCode, downloadLimited); String fileName = PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.PERSISTER_DOWNLOAD_URL) + collectionCode+"/" + (String) result.get("fileName"); logger.info("Done processing request for collection: " + collectionCode + ", returning created file: " + fileName); JSONObject obj = new JSONObject(); obj.put("feedCount", result.get("count")); if ((Integer) result.get("count") < Integer.parseInt(PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT)) ) { obj.putAll(ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, null, fileName, true)); return Response.ok(obj.toJSONString()).build(); } else { obj.putAll(ResultStatus.getUIWrapper(collectionCode,PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); logger.info("Returning JSON object: " + ResultStatus.getUIWrapper(collectionCode, PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_PREFIX) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.DEFAULT_TWEETID_VOLUME_LIMIT) + PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.TWEET_DOWNLOAD_LIMIT_MSG_SUFFIX), fileName, true)); return Response.ok(obj.toJSONString()).build(); } } Persister4CollectorAPI(); @GET @Produces("application/json") @Consumes("application/json") @Path("/start") Response startPersister(@QueryParam("file") String fileLocation, @QueryParam("collectionCode") String collectionCode); @GET @Produces("application/json") @Consumes("application/json") @Path("/stop") Response stopPersister(@QueryParam("collectionCode") String collectionCode); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genCSV") Response generateCSVFromLastestJSON(@QueryParam("collectionCode") String collectionCode,
    				@QueryParam("exportLimit") int exportLimit); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genTweetIds") Response generateTweetsIDSCSVFromAllJSON(@QueryParam("collectionCode") String collectionCode,
    		@DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited); @GET @Produces("application/json") @Path("/ping") Response ping(); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genJson") Response generateJSONFromLastestJSON(@QueryParam("collectionCode") String collectionCode,
    		@DefaultValue(DownloadType.TEXT_JSON) @QueryParam("jsonType") String jsonType); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genJsonTweetIds") Response generateTweetsIDSJSONFromAllJSON(@QueryParam("collectionCode") String collectionCode,
    			@DefaultValue("true") @QueryParam("downloadLimited") Boolean downloadLimited,
    			@DefaultValue(DownloadType.TEXT_JSON) @QueryParam("jsonType") String jsonType);  }