ReNounFact { public void save(MongoCollection<Document> collection) { collection.insertOne( new Document() .append(SUBJECT_FIELD, subject) .append(ATTRIBUTE_FIELD, attribute) .append(OBJECT_FIELD, object) .append(SCORE_FIELD, score) .append(PATTERN_FIELD, pattern) .append(SENTENCE_FIELD, sentence)); } ReNounFact(Document document);  ReNounFact(String subject, String attribute, String object);  ReNounFact(String subject, String attribute, String object, String pattern); String getAttribute(); String getSubject(); String getObject(); Double getScore(); void setScore(Double score); String getPattern(); void setPattern(String pattern); String getSentence(); void setSentence(String sentence); void save(MongoCollection<Document> collection); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final String SUBJECT_FIELD; static final String ATTRIBUTE_FIELD; static final String OBJECT_FIELD; static final String SCORE_FIELD; static final String PATTERN_FIELD; static final String SENTENCE_FIELD; }
@Test @SuppressWarnings("unchecked") public void testSave() { MongoCollection<Document> collection = mock(MongoCollection.class); ReNounFact fact1 = new ReNounFact(SUBJECT, ATTRIBUTE, OBJECT); ReNounFact fact2 = new ReNounFact(SUBJECT, ATTRIBUTE, OBJECT, PATTERN); ReNounFact fact3 = new ReNounFact(SUBJECT, ATTRIBUTE, OBJECT); fact3.setScore(1.0); fact1.save(collection); fact2.save(collection); fact3.save(collection); verify(collection, times(3)).insertOne(ArgumentMatchers.isA(Document.class)); }