### Question:
DiagnosisElement implements Comparable<DiagnosisElement> { @Override public int compareTo(DiagnosisElement other) { int compare = Integer.compare(this.getDiagnosedConstraintId(), other.getDiagnosedConstraintId()); if (compare == 0) { compare = Arrays.compare(this.getInvolvedParameters(), other.getInvolvedParameters()); if(compare == 0) { compare = Arrays.compare(this.getConflictingValues(), other.getConflictingValues()); } } return compare; } DiagnosisElement(int diagnosedConstraintId,
                            int[] involvedParameters,
                            int[] conflictingValues); int getDiagnosedConstraintId(); int[] getInvolvedParameters(); int[] getConflictingValues(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override int compareTo(DiagnosisElement other);  }### Answer:
@Test void testCompareToWithDifferentDiagnosedConstraintIds() { final DiagnosisElement a = new DiagnosisElement(4, new int[] {0, 1}, new int[]{0, 2}); final DiagnosisElement b = new DiagnosisElement(1, new int[] {0}, new int[]{2}); assertEquals(1, a.compareTo(b)); assertEquals(-1, b.compareTo(a)); }
@Test void testCompareToWithDifferentConflictingValues() { final DiagnosisElement a = new DiagnosisElement(4, new int[] {0, 1}, new int[]{0, 2}); final DiagnosisElement b = new DiagnosisElement(4, new int[] {0, 1}, new int[]{1, 2}); assertEquals(-1, a.compareTo(b)); assertEquals(1, b.compareTo(a)); }
@Test void testCompareToWithEqualElements() { final DiagnosisElement a = new DiagnosisElement(4, new int[] {0, 1}, new int[]{0, 2}); final DiagnosisElement b = new DiagnosisElement(4, new int[] {0, 1}, new int[]{0, 2}); assertEquals(0, a.compareTo(b)); assertEquals(0, b.compareTo(a)); }