Source:
<code>public void shouldWriteAllFieldsIntoMongoDb() throws Exception { String databaseName = mongoRule.getRandomTemporaryDatabaseName(); mongoOperations = getMongoOperations(databaseName, jobOptions.getMongoConnection()); DBCollection fileCollection = mongoRule.getCollection(databaseName, jobOptions.getDbCollectionsFilesName()); VariantSourceEntityMongoWriter filesWriter = new VariantSourceEntityMongoWriter( mongoOperations, jobOptions.getDbCollectionsFilesName()); VariantSourceEntity variantSourceEntity = getVariantSourceEntity(); filesWriter.write(Collections.singletonList(variantSourceEntity)); DBCursor cursor = fileCollection.find(); int count = 0; while (cursor.hasNext()) { count++; DBObject next = cursor.next(); assertNotNull(next.get("fname")); assertNotNull(next.get("fid")); assertNotNull(next.get("sid")); assertNotNull(next.get("sname")); assertNotNull(next.get("samp")); assertNotNull(next.get("stype")); assertNotNull(next.get("date")); assertNotNull(next.get("aggregation")); DBObject meta = (DBObject) next.get("meta"); assertNotNull(meta); assertNotNull(meta.get("fileformat")); <START> assertNotNull(meta.get("header")); <END> assertNotNull(meta.get("ALT")); assertNotNull(meta.get("FILTER")); assertNotNull(meta.get("INFO")); assertNotNull(meta.get("FORMAT")); } assertEquals(1, count); }</code><technical_language>constants here? easily this one. tests coupled, I show do strings from. A disadvantage of current way, is suggest handle this object hardcoded strings. a side note, I field names in VariantSourceEntity "fname" retrieved reflection</technical_language>

Target:
public void shouldWriteAllFieldsIntoMongoDb() throws Exception { String databaseName = mongoRule.getRandomTemporaryDatabaseName(); mongoOperations = getMongoOperations(databaseName, jobOptions.getMongoConnection()); DBCollection fileCollection = mongoRule.getCollection(databaseName, jobOptions.getDbCollectionsFilesName()); VariantSourceEntityMongoWriter filesWriter = new VariantSourceEntityMongoWriter( mongoOperations, jobOptions.getDbCollectionsFilesName()); VariantSourceEntity variantSourceEntity = getVariantSourceEntity(); filesWriter.write(Collections.singletonList(variantSourceEntity)); DBCursor cursor = fileCollection.find(); int count = 0; while (cursor.hasNext()) { count++; DBObject next = cursor.next(); assertNotNull(next.get(VariantSourceEntity.FILEID_FIELD)); assertNotNull(next.get(VariantSourceEntity.FILENAME_FIELD)); assertNotNull(next.get(VariantSourceEntity.STUDYID_FIELD)); assertNotNull(next.get(VariantSourceEntity.STUDYNAME_FIELD)); assertNotNull(next.get(VariantSourceEntity.STUDYTYPE_FIELD)); assertNotNull(next.get(VariantSourceEntity.AGGREGATION_FIELD)); assertNotNull(next.get(VariantSourceEntity.SAMPLES_FIELD)); assertNotNull(next.get(VariantSourceEntity.DATE_FIELD)); DBObject meta = (DBObject) next.get(VariantSourceEntity.METADATA_FIELD); assertNotNull(meta); assertNotNull(meta.get(VariantSourceEntity.METADATA_FILEFORMAT_FIELD)); assertNotNull(meta.get(VariantSourceEntity.METADATA_HEADER_FIELD)); assertNotNull(meta.get("ALT")); assertNotNull(meta.get("FILTER")); assertNotNull(meta.get("INFO")); assertNotNull(meta.get("FORMAT")); } assertEquals(1, count); }