LoadEncodedTermStatsTask extends CommonTask { @Override public void run() throws IOException { log.info("Loading encoded term stats map from: " + this.encodedTermStatsFile); String localFile = Utils.TEMP_FOLDER + encodedTermStatsFile; this.cloudService.downloadObjectFromCloudStorage(this.encodedTermStatsFile, localFile, this.bucket); Map<String, Long> termStats = FileUtils.jsonFileToMap(localFile); if(!termStats.isEmpty()) { List<Item> items = new ArrayList<>(); for(Entry<String, Long> item: termStats.entrySet()) { Item anItem = (new Item()).setKey(item.getKey()).setWeight(item.getValue()); items.add(anItem); } this.addOutput("termItems", items); log.info("Successfully added term stats to the job context: " + items); } }  @Override void run(); String getBucket(); void setBucket(String bucket); String getEncodedTermStatsFile(); void setEncodedTermStatsFile(String encodedTermStatsFile);  }
@Test public void testRun() throws IOException { LoadEncodedTermStatsTask task = new LoadEncodedTermStatsTask(); task.setCloudService(service); task.setBucket("swetodblp-fullrun-1"); task.setEncodedTermStatsFile("term_stats_encoded.json"); task.run(); Map<String, Object> output = task.getOutput(); assertNotNull(output); assertEquals(1, output.size()); List<Item> items = (List<Item>) output.get("termItems"); assertNotNull(items); assertEquals(28, items.size()); }