@Test public void shouldCompareTwoOrderBasedOnCreationDateIfSupplyingFacilityNameAndProgramNameIsSame() throws Exception { Rnr rnrForHIV = make(a(RequisitionBuilder.defaultRequisition, with(id, 2L), with(program, make(a(defaultProgram, with(ProgramBuilder.programName, "HIV")))))); Order order1 = new Order(rnrForHIV); order1.setSupplyLine(make(a(defaultSupplyLine, with(SupplyLineBuilder.facility, make(a(FacilityBuilder.defaultFacility, with(name, "F10"))))))); order1.setCreatedDate(DateTime.now().toDate()); Order order2 = new Order(rnrForHIV); order2.setSupplyLine(make(a(defaultSupplyLine, with(SupplyLineBuilder.facility, make(a(FacilityBuilder.defaultFacility, with(name, "F10"))))))); order2.setCreatedDate(DateTime.now().minusDays(1).toDate()); assertThat(order1.compareTo(order2), is(greaterThan(0))); }
@Override public int compareTo(Object o) { Order order2 = (Order) o; int comparisonResult; if ((comparisonResult = this.getSupplyingFacility().getName().compareToIgnoreCase(order2.getSupplyingFacility().getName())) != 0) { return comparisonResult; } if ((comparisonResult = this.getRnr().getProgram().getName().compareToIgnoreCase(order2.getRnr().getProgram().getName())) != 0) { return comparisonResult; } return this.getCreatedDate().compareTo(order2.getCreatedDate()); }
Order extends BaseModel implements Comparable { @Override public int compareTo(Object o) { Order order2 = (Order) o; int comparisonResult; if ((comparisonResult = this.getSupplyingFacility().getName().compareToIgnoreCase(order2.getSupplyingFacility().getName())) != 0) { return comparisonResult; } if ((comparisonResult = this.getRnr().getProgram().getName().compareToIgnoreCase(order2.getRnr().getProgram().getName())) != 0) { return comparisonResult; } return this.getCreatedDate().compareTo(order2.getCreatedDate()); } }
Order extends BaseModel implements Comparable { @Override public int compareTo(Object o) { Order order2 = (Order) o; int comparisonResult; if ((comparisonResult = this.getSupplyingFacility().getName().compareToIgnoreCase(order2.getSupplyingFacility().getName())) != 0) { return comparisonResult; } if ((comparisonResult = this.getRnr().getProgram().getName().compareToIgnoreCase(order2.getRnr().getProgram().getName())) != 0) { return comparisonResult; } return this.getCreatedDate().compareTo(order2.getCreatedDate()); } Order(Rnr rnr);  Order(Long id);  Order(Rnr rnr, SupplyLine supplyLine);  Order(Long id, OrderStatus status); }
Order extends BaseModel implements Comparable { @Override public int compareTo(Object o) { Order order2 = (Order) o; int comparisonResult; if ((comparisonResult = this.getSupplyingFacility().getName().compareToIgnoreCase(order2.getSupplyingFacility().getName())) != 0) { return comparisonResult; } if ((comparisonResult = this.getRnr().getProgram().getName().compareToIgnoreCase(order2.getRnr().getProgram().getName())) != 0) { return comparisonResult; } return this.getCreatedDate().compareTo(order2.getCreatedDate()); } Order(Rnr rnr);  Order(Long id);  Order(Rnr rnr, SupplyLine supplyLine);  Order(Long id, OrderStatus status); Facility getSupplyingFacility(); @Override int compareTo(Object o); }
Order extends BaseModel implements Comparable { @Override public int compareTo(Object o) { Order order2 = (Order) o; int comparisonResult; if ((comparisonResult = this.getSupplyingFacility().getName().compareToIgnoreCase(order2.getSupplyingFacility().getName())) != 0) { return comparisonResult; } if ((comparisonResult = this.getRnr().getProgram().getName().compareToIgnoreCase(order2.getRnr().getProgram().getName())) != 0) { return comparisonResult; } return this.getCreatedDate().compareTo(order2.getCreatedDate()); } Order(Rnr rnr);  Order(Long id);  Order(Rnr rnr, SupplyLine supplyLine);  Order(Long id, OrderStatus status); Facility getSupplyingFacility(); @Override int compareTo(Object o);  }