@Test void computeSimilarityWhenDocumentAndTypeAreNull() { Event event1 = mock(Event.class); Event event2 = mock(Event.class); assertEquals(SimilarityCalculator.NO_SIMILARITY, this.sq.computeSimilarity(event1, event2)); }
public int computeSimilarity(Event event1, Event event2) { if (event1.getDocument() != null && event1.getDocument().equals(event2.getDocument())) { if (event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_DOCUMENT_AND_TYPE; } else if (event1.getGroupId() != null && event1.getGroupId().equals(event2.getGroupId())) { return SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES; } } else if (event1.getDocument() == null && event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_TYPE_BUT_NO_DOCUMENT; } return NO_SIMILARITY; }
SimilarityCalculator { public int computeSimilarity(Event event1, Event event2) { if (event1.getDocument() != null && event1.getDocument().equals(event2.getDocument())) { if (event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_DOCUMENT_AND_TYPE; } else if (event1.getGroupId() != null && event1.getGroupId().equals(event2.getGroupId())) { return SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES; } } else if (event1.getDocument() == null && event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_TYPE_BUT_NO_DOCUMENT; } return NO_SIMILARITY; } }
SimilarityCalculator { public int computeSimilarity(Event event1, Event event2) { if (event1.getDocument() != null && event1.getDocument().equals(event2.getDocument())) { if (event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_DOCUMENT_AND_TYPE; } else if (event1.getGroupId() != null && event1.getGroupId().equals(event2.getGroupId())) { return SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES; } } else if (event1.getDocument() == null && event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_TYPE_BUT_NO_DOCUMENT; } return NO_SIMILARITY; }  }
SimilarityCalculator { public int computeSimilarity(Event event1, Event event2) { if (event1.getDocument() != null && event1.getDocument().equals(event2.getDocument())) { if (event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_DOCUMENT_AND_TYPE; } else if (event1.getGroupId() != null && event1.getGroupId().equals(event2.getGroupId())) { return SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES; } } else if (event1.getDocument() == null && event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_TYPE_BUT_NO_DOCUMENT; } return NO_SIMILARITY; }  int computeSimilarity(Event event1, Event event2); }
SimilarityCalculator { public int computeSimilarity(Event event1, Event event2) { if (event1.getDocument() != null && event1.getDocument().equals(event2.getDocument())) { if (event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_DOCUMENT_AND_TYPE; } else if (event1.getGroupId() != null && event1.getGroupId().equals(event2.getGroupId())) { return SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES; } } else if (event1.getDocument() == null && event1.getType() != null && event1.getType().equals(event2.getType())) { return SAME_TYPE_BUT_NO_DOCUMENT; } return NO_SIMILARITY; }  int computeSimilarity(Event event1, Event event2); static final int SAME_GROUP_ID_AND_DOCUMENT_BUT_DIFFERENT_TYPES; static final int SAME_DOCUMENT_AND_TYPE; static final int SAME_TYPE_BUT_NO_DOCUMENT; static final int NO_SIMILARITY; }