ProvinceInfoHandler extends DefaultHandler { public List<ProvinceModel> getProvinceList() { return mList; } ProvinceInfoHandler(List<ProvinceModel> list); List<ProvinceModel> getProvinceList(); @Override void startDocument(); @Override void startElement(String uri, String localName, String qName, Attributes attributes); @Override void characters(char[] ch, int start, int length); @Override void endElement(String uri, String localName, String qName);  }
@Test public void testDocumentParsingWithInitialNullProvincesList() throws ParserConfigurationException, SAXException, IOException { provinceInfoHandler = new ProvinceInfoHandler(null); parseDocument("valid-data.xml"); assertProvinceList(provinces, provinceInfoHandler.getProvinceList()); }
@Test public void testEmptyDocumentParsing() throws ParserConfigurationException, SAXException, IOException { parseDocument("empty-data.xml"); assertTrue(provinceInfoHandler.getProvinceList() == null || provinceInfoHandler.getProvinceList().isEmpty()); }
@Test public void testUnknownTagsDocumentParsing() throws ParserConfigurationException, SAXException, IOException { provinceInfoHandler = new ProvinceInfoHandler(null); parseDocument("unknown-data.xml"); assertProvinceList(provinces, provinceInfoHandler.getProvinceList()); }
@Test public void testConstructor() { assertTrue(provinceInfoHandler.getProvinceList().isEmpty()); }
@Test public void testConstructorWithNullArgument() { provinceInfoHandler = new ProvinceInfoHandler(null); assertNull(provinceInfoHandler.getProvinceList()); }
@Test public void testDocumentParsing() throws ParserConfigurationException, SAXException, IOException { parseDocument("valid-data.xml"); assertProvinceList(provinces, provinceInfoHandler.getProvinceList()); }