ErrorSignalElement { public static Iterator<OMElement> getElements(final SOAPHeaderBlock messaging) { final Iterator<OMElement> signals = SignalMessageElement.getElements(messaging); final ArrayList<OMElement> errors = new ArrayList<>(); while(signals.hasNext()) { final OMElement signal = signals.next(); if (signal.getFirstChildWithName(Q_ELEMENT_NAME) != null) errors.add(signal); } return errors.iterator(); }  static OMElement createElement(final OMElement messaging, final IErrorMessage errorMU); static ErrorMessage readElement(final OMElement sigElement); static Iterator<OMElement> getElements(final SOAPHeaderBlock messaging); static final QName Q_ELEMENT_NAME; }
@Test public void testGetElements() throws Exception { ErrorMessage errorMessage = new ErrorMessage(); ArrayList<IEbmsError> errors = new ArrayList<>(); EbmsError ebmsError = new EbmsError(); ebmsError.setCategory(""); ebmsError.setSeverity(IEbmsError.Severity.failure); ebmsError.setErrorCode("some_error_code"); errors.add(ebmsError); errorMessage.setErrors(errors); ErrorSignalElement.createElement(headerBlock, errorMessage); Iterator<OMElement> it = ErrorSignalElement.getElements(headerBlock); assertTrue(it.hasNext()); OMElement esElement = it.next(); assertEquals(SIGNAL_MESSAGE_ELEMENT_NAME, esElement.getQName()); OMElement eElement = (OMElement)esElement.getChildrenWithName(ERROR_ELEMENT_NAME).next(); assertEquals(ERROR_ELEMENT_NAME, eElement.getQName()); assertEquals(IEbmsError.Severity.failure.toString(), eElement.getAttributeValue(SEVERITY_ATTR_NAME)); assertEquals("some_error_code", eElement.getAttributeValue(ERROR_CODE_ATTR_NAME)); }