ErrorSignalElement { protected static EbmsError readErrorElement(final OMElement errorElement) { final EbmsError error = new EbmsError(); error.setCategory(errorElement.getAttributeValue(new QName(CATEGORY_ATTR))); error.setErrorCode(errorElement.getAttributeValue(new QName(ERROR_CODE_ATTR))); error.setOrigin(errorElement.getAttributeValue(new QName(ORIGIN_ATTR))); error.setMessage(errorElement.getAttributeValue(new QName(SHORT_DESCR_ATTR))); error.setRefToMessageInError(errorElement.getAttributeValue(new QName(REF_TO_ATTR))); final String severity = errorElement.getAttributeValue(new QName(SEVERITY_ATTR)); if (!Utils.isNullOrEmpty(severity)) try { error.setSeverity(IEbmsError.Severity.valueOf(severity.toLowerCase())); } catch (IllegalArgumentException unknownSeverity) { } final OMElement errDetailElement = errorElement.getFirstChildWithName(Q_ERROR_DETAIL); if (errDetailElement != null) error.setErrorDetail(errDetailElement.getText()); error.setDescription(DescriptionElement.readElement( DescriptionElement.getElement(errorElement))); return error; }  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 testReadErrorElement() throws Exception { ErrorMessage errorMessage = new ErrorMessage(); ArrayList<IEbmsError> errors = new ArrayList<>(); EbmsError ebmsError = new EbmsError(); ebmsError.setSeverity(IEbmsError.Severity.failure); ebmsError.setErrorCode("some_error_code"); ebmsError.setCategory("some_category"); ebmsError.setOrigin("some_error_origin"); ebmsError.setMessage("some_message"); ebmsError.setRefToMessageInError("ref_to_some_message"); ebmsError.setErrorDetail("some_error_detail"); Description description = new Description("some_text", "en-CA"); ebmsError.setDescription(description); errors.add(ebmsError); errorMessage.setErrors(errors); OMElement esElement = ErrorSignalElement.createElement(headerBlock, errorMessage); OMElement eElement = (OMElement) esElement.getChildrenWithName(ERROR_ELEMENT_NAME).next(); ebmsError = ErrorSignalElement.readErrorElement(eElement); assertEquals(IEbmsError.Severity.failure, ebmsError.getSeverity()); assertEquals("some_error_code", ebmsError.getErrorCode()); assertEquals("some_category", ebmsError.getCategory()); assertEquals("some_error_origin", ebmsError.getOrigin()); assertEquals("some_message", ebmsError.getMessage()); assertEquals("ref_to_some_message", ebmsError.getRefToMessageInError()); assertEquals("some_error_detail", ebmsError.getErrorDetail()); assertEquals("some_text", ebmsError.getDescription().getText()); assertEquals("en-CA", ebmsError.getDescription().getLanguage()); }