### Question:
AtcParser { public List<AtcDescription> findDrugDetails(String inputLine) { Matcher matchCode = s_codePattern.matcher(inputLine); List<AtcDescription> detailsList = new ArrayList<AtcDescription>(); while(matchCode.find()) { if (!matchCode.group(3).equals("Show text from Guidelines")) { detailsList.add(new AtcDescription((matchCode.group(1)), matchCode.group(3))); } } return detailsList; }  List<AtcDescription> findDrugDetails(String inputLine); List<AtcDescription> parse(InputStream is); AtcDescription getAtcCode(String drugName); List<AtcDescription> getAtcDetails(String atcCode);  }### Answer:
@Test public void testMatchCodeFail() { String drugTest = "This will have to return null"; assertEquals(Collections.emptyList(), new AtcParser().findDrugDetails(drugTest)); }
@Test public void testMatchCodeSuccesful() { String drugTest = "<a href=\"http: assertEquals(1, new AtcParser().findDrugDetails(drugTest).size()); assertEquals("N06AB03", new AtcParser().findDrugDetails(drugTest).get(0).getCode()); assertEquals("fluoxetine", new AtcParser().findDrugDetails(drugTest).get(0).getDescription()); }
@Test public void testCodeParse() throws IOException { BufferedReader readCode = new BufferedReader(new InputStreamReader(d_drugStream)); AtcParser parser = new AtcParser(); String inputLine; List<AtcDescription> tmp = Collections.emptyList(); while ((inputLine = readCode.readLine()) != null && tmp.isEmpty()) { tmp = parser.findDrugDetails(inputLine); } assertEquals("N06AB03", tmp.get(0).getCode()); assertEquals("fluoxetine", tmp.get(0).getDescription()); }
@Test public void testDrugFirstDetailParse() throws IOException { BufferedReader readCode = new BufferedReader(new InputStreamReader(d_codeStream)); AtcParser parser = new AtcParser(); String inputLine; while ((inputLine = readCode.readLine()) != null && parser.findDrugDetails(inputLine).isEmpty()) { } List<AtcDescription> finalList = parser.findDrugDetails(inputLine); assertEquals(1, finalList.size()); assertEquals("N", finalList.get(0).getCode()); assertEquals("NERVOUS SYSTEM", finalList.get(0).getDescription()); }