### Question:
Persister4CollectorAPI { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/genCSV") public Response generateCSVFromLastestJSON(@QueryParam("collectionCode") String collectionCode, @QueryParam("exportLimit") int exportLimit) throws UnknownHostException { logger.info("Received request for collection: " + collectionCode); JsonDeserializer jsonD = new JsonDeserializer(); String fileName = jsonD.generateJSON2CSV_100K_BasedOnTweetCount(collectionCode, exportLimit); fileName = PersisterConfigurator.getInstance().getProperty(PersisterConfigurationProperty.PERSISTER_DOWNLOAD_URL) + collectionCode+"/"+fileName; logger.info("Done processing request for collection: " + collectionCode + ", returning created file: " + fileName); JSONObject obj = new JSONObject(); 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(); } 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);  }### Answer:
@Test public void testGenerateCSVFromLastestJSON() throws UnknownHostException { int exportLimit= 50; Response response = persister4CollectorAPI.generateCSVFromLastestJSON(existedCollectionCode, exportLimit); assertEquals(200, response.getStatus()); assertEquals(true, response.hasEntity()); assertEquals(false, response.bufferEntity()); response = persister4CollectorAPI.generateCSVFromLastestJSON(existedCollectionCode, 0); assertEquals(200, response.getStatus()); assertEquals(true, response.hasEntity()); assertEquals(false, response.bufferEntity()); }
@Test(expected = NullPointerException.class) public void testNullPointerExceptionOnInvalidCollectionCodeInGenerateCSVFromLastestJSON() throws UnknownHostException { int exportLimit= 50; persister4CollectorAPI.generateCSVFromLastestJSON(sampleCollectionCode, exportLimit); }