@Test public void givenHeader_WhenParse_ThenCompareExpectedAndActualTagElements() { String inputString = "<? xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"; TagElement expectedElement = new TagElement(); expectedElement.setName("xml"); Map<String, String> params = new HashMap<>(); params.put("version", "1.0"); params.put("encoding", "UTF-8"); params.put("standalone", "no"); expectedElement.setParams(params); expectedElement.setType(TagElementType.HEADER); handler = new Handler() { @Override public void handle(Element element) { myElement = element; } }; builder.onStart(handler); parser = builder.build(); parser.parse(inputString); Element actualElement = myElement; assertEquals(expectedElement, actualElement); }
@Test public void givenHeader_WhenParse_ThenTypeOfTheTagEqualsHEADER() { String inputString = "<? xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"; handler = new Handler() { @Override public void handle(Element element) { myElement = element; } }; builder.onStart(handler); parser = builder.build(); parser.parse(inputString); TagElementType actual = myElement.getType(); TagElementType expected = TagElementType.HEADER; assertEquals(expected, actual); }