### Question:
DrugsByNameComparator implements Comparator<Drug>, Serializable { @Override public int compare(Drug d1, Drug d2) { return compareDrugNamesIgnoringNumericals(d1, d2); }  @Override int compare(Drug d1, Drug d2);  }### Answer:
@Test public void compareDrugNamesIgnoringNumericals_shouldReturnNegativeIfNameForDrug1ComesBeforeThatOfDrug2() { Drug drug1 = new Drug(); drug1.setName("ABCD"); Drug drug2 = new Drug(); drug2.setName("BCDE"); DrugsByNameComparator dComparator = new DrugsByNameComparator(); int actualValue = dComparator.compare(drug1, drug2); Assert.assertEquals(actualValue, -1); }
@Test public void compareDrugNamesIgnoringNumericals_shouldReturnZeroIfNameForDrug1ComesBeforeThatOfDrug2() { Drug drug1 = new Drug(); drug1.setName("ABCD"); Drug drug2 = new Drug(); drug2.setName("abcd"); DrugsByNameComparator dComparator = new DrugsByNameComparator(); int actualValue = dComparator.compare(drug1, drug2); Assert.assertEquals(actualValue, 0); }
@Test public void compareDrugNamesIgnoringNumericals_shouldReturnPositiveIfNameForDrug1ComesBeforeThatOfDrug2IgnoringDashes() { Drug drug1 = new Drug(); drug1.setName("AB-AB"); Drug drug2 = new Drug(); drug2.setName("ABAA"); DrugsByNameComparator dComparator = new DrugsByNameComparator(); int actualValue = dComparator.compare(drug1, drug2); Assert.assertEquals(actualValue, 1); }
@Test public void compareDrugNamesIgnoringNumericals_shouldReturnPositiveIfNameForDrug1ComesBeforeThatOfDrug2IgnoringNumerics() { Drug drug1 = new Drug(); drug1.setName("AB1AB"); Drug drug2 = new Drug(); drug2.setName("ABAA"); DrugsByNameComparator dComparator = new DrugsByNameComparator(); int actualValue = dComparator.compare(drug1, drug2); Assert.assertEquals(actualValue, 1); }