/** * Checks whether the hash codes are evaluated if similar warnings are part of new and fixed. */ @Test public void testHashCodes() { Set<FileAnnotation> actual = new HashSet<FileAnnotation>(); Set<FileAnnotation> previous = new HashSet<FileAnnotation>(); FileAnnotation current = createAnnotation(STRING, Priority.HIGH, STRING, STRING, STRING, 3, 4); actual.add(current); FileAnnotation old = createAnnotation(STRING, Priority.HIGH, STRING, STRING, STRING, 2, 3); previous.add(old); assertEquals(WARNINGS_COUNT_ERROR, 1, AnnotationDifferencer.getFixedAnnotations(actual, previous).size()); assertEquals(WARNINGS_COUNT_ERROR, 1, AnnotationDifferencer.getNewAnnotations(actual, previous).size()); ((AbstractAnnotation)current).setContextHashCode(0); ((AbstractAnnotation)old).setContextHashCode(0); assertEquals(WARNINGS_COUNT_ERROR, 0, AnnotationDifferencer.getFixedAnnotations(actual, previous).size()); assertEquals(WARNINGS_COUNT_ERROR, 0, AnnotationDifferencer.getNewAnnotations(actual, previous).size()); } }
/** * Checks whether the hash codes are evaluated if similar warnings are part of new and fixed. */ @Test public void testHashCodes() { Set<FileAnnotation> actual = new HashSet<FileAnnotation>(); Set<FileAnnotation> previous = new HashSet<FileAnnotation>(); FileAnnotation current = createAnnotation(STRING, Priority.HIGH, STRING, STRING, STRING, 3, 4); actual.add(current); FileAnnotation old = createAnnotation(STRING, Priority.HIGH, STRING, STRING, STRING, 2, 3); previous.add(old); assertEquals(WARNINGS_COUNT_ERROR, 1, AnnotationDifferencer.getFixedAnnotations(actual, previous).size()); assertEquals(WARNINGS_COUNT_ERROR, 1, AnnotationDifferencer.getNewAnnotations(actual, previous).size()); ((AbstractAnnotation)current).setContextHashCode(0); ((AbstractAnnotation)old).setContextHashCode(0); assertEquals(WARNINGS_COUNT_ERROR, 0, AnnotationDifferencer.getFixedAnnotations(actual, previous).size()); assertEquals(WARNINGS_COUNT_ERROR, 0, AnnotationDifferencer.getNewAnnotations(actual, previous).size()); } }