ProjectAssignmentComparator implements Comparator<ProjectAssignment>, Serializable { public int compare(ProjectAssignment o1, ProjectAssignment o2) { int cmp; switch (compareType) { case ASSIGNMENT_COMPARE_NAME: cmp = compareNames(o1, o2); break; case ASSIGNMENT_COMPARE_START: cmp = compareDateStart(o1, o2); break; case ASSIGNMENT_COMPARE_CUSTDATEPRJ: cmp = compareCustomerStartDateProject(o1, o2); break; default: cmp = 0; break; } return cmp; } ProjectAssignmentComparator();  ProjectAssignmentComparator(int compareType); int compare(ProjectAssignment o1, ProjectAssignment o2); static final int ASSIGNMENT_COMPARE_NAME; static final int ASSIGNMENT_COMPARE_START; static final int ASSIGNMENT_COMPARE_CUSTDATEPRJ; }
@Test public void testCompareCustDatePrj() { int x = new ProjectAssignmentComparator(ProjectAssignmentComparator.ASSIGNMENT_COMPARE_CUSTDATEPRJ) .compare(ProjectAssignmentObjectMother.createProjectAssignment(2), ProjectAssignmentObjectMother.createProjectAssignment(1)); assertTrue(x > 0); }
@Test public void testCompareName() { int x = new ProjectAssignmentComparator(ProjectAssignmentComparator.ASSIGNMENT_COMPARE_NAME) .compare(ProjectAssignmentObjectMother.createProjectAssignment(2), ProjectAssignmentObjectMother.createProjectAssignment(1)); assertTrue(x > 0); }
@Test public void testCompareStart() { int x = new ProjectAssignmentComparator(ProjectAssignmentComparator.ASSIGNMENT_COMPARE_START) .compare(ProjectAssignmentObjectMother.createProjectAssignment(1), ProjectAssignmentObjectMother.createProjectAssignment(1)); assertTrue(x == 0); }