### Question:
IndexJSFileParser implements IndexParser<String> { @Override public Set<MongoIndex> parse(String fileName) { Map<String, Object> indexMap = null; File resourceFile = null; FileInputStream fstream = null; BufferedReader br = null; Set<MongoIndex> indexes = new HashSet<MongoIndex>(); try { URL resourceURL = Thread.currentThread().getContextClassLoader().getResource(fileName); if (resourceURL != null) { resourceFile = new File(resourceURL.toURI()); if (resourceFile != null) { fstream = new FileInputStream(resourceFile); br = new BufferedReader(new InputStreamReader(fstream)); String collectionName = null; String keyJsonString; String currentFileLine; while ((currentFileLine = br.readLine()) != null) { boolean unique = false; Matcher indexMatcher = ensureIndexStatement(currentFileLine); if (indexMatcher != null) { collectionName = indexMatcher.group(1); keyJsonString = indexMatcher.group(2); if (indexMatcher.group(3) != null) { unique = Boolean.parseBoolean(indexMatcher.group(4)); } indexMap = parseJson(keyJsonString); DBObject keyObj = new BasicDBObject(indexMap); indexes.add(new MongoIndex(collectionName, unique, keyObj)); } } } } } catch (IOException e) { LOG.error("Error reading index file:" + e.getMessage()); } catch (URISyntaxException e) { LOG.error("Index file not found: " + e.getMessage()); } finally { IOUtils.closeQuietly(br); IOUtils.closeQuietly(fstream); } return indexes; }  @Override Set<MongoIndex> parse(String fileName); static Map<String, Object> parseJson(String jsonString);  }### Answer:
@Test public void parseJSTest() { IndexJSFileParser indexJSFileParser = new IndexJSFileParser(); Set<MongoIndex> indexes = indexJSFileParser.parse(INDEX_FILE); Map<String, MongoIndex> expectedIndexes = new HashMap<String, MongoIndex>(); DBObject userSessionIndex = new BasicDBObject(); userSessionIndex.put("body.expiration", 1); userSessionIndex.put("body.hardLogout", 1); userSessionIndex.put("body.appSession.token", 1); expectedIndexes.put("usersession", new MongoIndex("userSession", false, userSessionIndex)); DBObject tenantIndex = new BasicDBObject(); tenantIndex.put("body.tenantId", 1); expectedIndexes.put("tenant", new MongoIndex("tenant", true, tenantIndex)); assertEquals(4, indexes.size()); for (MongoIndex idx : indexes) { if (idx.getCollection().equalsIgnoreCase("realm")) { fail("Invalid index was parsed"); } else if (idx.getCollection().equalsIgnoreCase("usersession")) { assertEquals(idx, expectedIndexes.get("usersession")); } else if (idx.getCollection().equalsIgnoreCase("tenant")) { assertEquals(idx, expectedIndexes.get("tenant")); assertTrue(idx.isUnique()); } } }