@Test public void testParse() throws IOException, XMLStreamException { InputStream soap = new ClassPathResource("sab/response_success.xml").getInputStream(); List<String> roles = subject.parse(soap); assertEquals(Arrays.asList( "Superuser", "Instellingsbevoegde", "Infraverantwoordelijke", "OperationeelBeheerder", "Mailverantwoordelijke", "Domeinnamenverantwoordelijke", "DNS-Beheerder", "AAIverantwoordelijke", "Beveiligingsverantwoordelijke"), roles); }
public List<String> parse(InputStream soap) throws XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(soap); List<String> roles = new ArrayList<>(); boolean processRoles = false; while (reader.hasNext()) { switch (reader.next()) { case XMLStreamConstants.START_ELEMENT: switch (reader.getLocalName()) { case "Attribute": if (hasAttributeValue(reader, "urn:oid:1.3.6.1.4.1.5923.1.1.1.7")) { processRoles = true; } break; case "AttributeValue": if (processRoles) { roles.add(reader.getElementText()); } break; } break; case XMLStreamConstants.END_ELEMENT: if (processRoles && reader.getLocalName().equals("Attribute")) { return roles; } } } return roles; }
SabResponseParser { public List<String> parse(InputStream soap) throws XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(soap); List<String> roles = new ArrayList<>(); boolean processRoles = false; while (reader.hasNext()) { switch (reader.next()) { case XMLStreamConstants.START_ELEMENT: switch (reader.getLocalName()) { case "Attribute": if (hasAttributeValue(reader, "urn:oid:1.3.6.1.4.1.5923.1.1.1.7")) { processRoles = true; } break; case "AttributeValue": if (processRoles) { roles.add(reader.getElementText()); } break; } break; case XMLStreamConstants.END_ELEMENT: if (processRoles && reader.getLocalName().equals("Attribute")) { return roles; } } } return roles; } }
SabResponseParser { public List<String> parse(InputStream soap) throws XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(soap); List<String> roles = new ArrayList<>(); boolean processRoles = false; while (reader.hasNext()) { switch (reader.next()) { case XMLStreamConstants.START_ELEMENT: switch (reader.getLocalName()) { case "Attribute": if (hasAttributeValue(reader, "urn:oid:1.3.6.1.4.1.5923.1.1.1.7")) { processRoles = true; } break; case "AttributeValue": if (processRoles) { roles.add(reader.getElementText()); } break; } break; case XMLStreamConstants.END_ELEMENT: if (processRoles && reader.getLocalName().equals("Attribute")) { return roles; } } } return roles; }  }
SabResponseParser { public List<String> parse(InputStream soap) throws XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(soap); List<String> roles = new ArrayList<>(); boolean processRoles = false; while (reader.hasNext()) { switch (reader.next()) { case XMLStreamConstants.START_ELEMENT: switch (reader.getLocalName()) { case "Attribute": if (hasAttributeValue(reader, "urn:oid:1.3.6.1.4.1.5923.1.1.1.7")) { processRoles = true; } break; case "AttributeValue": if (processRoles) { roles.add(reader.getElementText()); } break; } break; case XMLStreamConstants.END_ELEMENT: if (processRoles && reader.getLocalName().equals("Attribute")) { return roles; } } } return roles; }  List<String> parse(InputStream soap); }
SabResponseParser { public List<String> parse(InputStream soap) throws XMLStreamException { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(soap); List<String> roles = new ArrayList<>(); boolean processRoles = false; while (reader.hasNext()) { switch (reader.next()) { case XMLStreamConstants.START_ELEMENT: switch (reader.getLocalName()) { case "Attribute": if (hasAttributeValue(reader, "urn:oid:1.3.6.1.4.1.5923.1.1.1.7")) { processRoles = true; } break; case "AttributeValue": if (processRoles) { roles.add(reader.getElementText()); } break; } break; case XMLStreamConstants.END_ELEMENT: if (processRoles && reader.getLocalName().equals("Attribute")) { return roles; } } } return roles; }  List<String> parse(InputStream soap);  }