RegimenOrder { public boolean hasSameDrugs(RegimenOrder order) { if (order == null) { return false; } return CollectionUtils.isEqualCollection(getDrugReferences(), order.getDrugReferences()); } RegimenOrder(Set<DrugOrder> drugOrders); Set<DrugOrder> getDrugOrders(); List<DrugOrder> getDrugOrders(DrugReference drugRef); List<DrugReference> getDrugReferences(); boolean hasSameDrugs(RegimenOrder order); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void hasSameDrugs_shouldCompareDrugsOnly() { Assert.assertTrue(regimen1.hasSameDrugs(regimen2)); Assert.assertTrue(regimen2.hasSameDrugs(regimen1)); Assert.assertFalse(regimen1.hasSameDrugs(regimen3)); Assert.assertFalse(regimen3.hasSameDrugs(regimen1)); Assert.assertTrue(regimen1.hasSameDrugs(regimen4)); Assert.assertTrue(regimen4.hasSameDrugs(regimen1)); Assert.assertFalse(regimen1.hasSameDrugs(null)); }