com.helger.commons.error.list.IErrorList Java Examples
The following examples show how to use
com.helger.commons.error.list.IErrorList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IJAXBValidator.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Validate the passed JAXB document. * * @param aJAXBDocument * The JAXB document to be validated. May not be <code>null</code>. * @return The validation results. Never <code>null</code>. */ @Nonnull default IErrorList validate (@Nonnull final JAXBTYPE aJAXBDocument) { final ErrorList aErrorList = new ErrorList (); validate (aJAXBDocument, aErrorList); return aErrorList; }
Example #2
Source File: UBL23InvoiceHelperTest.java From ph-ubl with Apache License 2.0 | 5 votes |
@Test public void testComvertBackAndForth () { for (final String sFilename : MockUBL23TestDocuments.getUBL23TestDocuments (EUBL23DocumentType.INVOICE)) { LOGGER.info (sFilename); // Read final Document aDoc = DOMReader.readXMLDOM (new ClassPathResource (sFilename), new DOMReaderSettings ().setSchema (EUBL23DocumentType.INVOICE.getSchema ())); assertNotNull (sFilename, aDoc); final InvoiceType aUBLObject = UBL23Reader.invoice ().read (aDoc); assertNotNull (sFilename, aUBLObject); // Convert Invoice to CreditNote final CreditNoteType aCreditNote = new CreditNoteType (); UBL23InvoiceHelper.cloneInvoiceToCreditNote (aUBLObject, aCreditNote); // Validate CreditNote IErrorList aErrors = UBL23Validator.creditNote ().validate (aCreditNote); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); // Convert CreditNote back to Invoice final InvoiceType aInvoice2 = new InvoiceType (); UBL23CreditNoteHelper.cloneCreditNoteToInvoice (aCreditNote, aInvoice2); // Validate Invoice again aErrors = UBL23Validator.invoice ().validate (aInvoice2); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); } }
Example #3
Source File: UBLPEBuilderFuncTest.java From ph-ubl with Apache License 2.0 | 5 votes |
@Test public void testReadAndWriteSummaryDocuments () { final UBLPEReaderBuilder <SummaryDocumentsType> aReader = new UBLPEReaderBuilder <> (SummaryDocumentsType.class); final UBLPEValidatorBuilder <SummaryDocumentsType> aValidator = new UBLPEValidatorBuilder <> (SummaryDocumentsType.class); final UBLPEWriterBuilder <SummaryDocumentsType> aWriter = new UBLPEWriterBuilder <> (SummaryDocumentsType.class).setFormattedOutput (true); final String sFilename = MockUBLPETestDocuments.getUBLPETestDocuments (EUBLPEDocumentType.SUMMARY_DOCUMENTS) .getFirst (); assertNotNull (sFilename); // Read from resource final SummaryDocumentsType aRead1 = aReader.read (new ClassPathResource (sFilename)); assertNotNull (aRead1); // Read from byte[] final SummaryDocumentsType aRead2 = aReader.read (StreamHelper.getAllBytes (new ClassPathResource (sFilename))); assertNotNull (aRead2); assertEquals (aRead1, aRead2); // Validate final IErrorList aREG1 = aValidator.validate (aRead1); final IErrorList aREG2 = aValidator.validate (aRead2); assertEquals (aREG1, aREG2); // Write final String s = aWriter.getAsString (aRead1); System.out.println (s); }
Example #4
Source File: UBL20BuilderFuncTest.java From ph-ubl with Apache License 2.0 | 5 votes |
@Test public void testReadAndWriteInvoice () { final UBL20ReaderBuilder <InvoiceType> aReader = new UBL20ReaderBuilder<> (InvoiceType.class); final UBL20ValidatorBuilder <InvoiceType> aValidator = new UBL20ValidatorBuilder<> (InvoiceType.class); final UBL20WriterBuilder <InvoiceType> aWriter = new UBL20WriterBuilder<> (InvoiceType.class).setFormattedOutput (true); aWriter.setNamespaceContext (new MapBasedNamespaceContext ().addMapping ("bla", EUBL20DocumentType.INVOICE.getNamespaceURI ())); final String sFilename = MockUBL20TestDocuments.getUBL20TestDocuments (EUBL20DocumentType.INVOICE).get (0); // Read from resource final InvoiceType aRead1 = aReader.read (new ClassPathResource (sFilename)); assertNotNull (aRead1); // Read from byte[] final InvoiceType aRead2 = aReader.read (StreamHelper.getAllBytes (new ClassPathResource (sFilename))); assertNotNull (aRead2); assertEquals (aRead1, aRead2); // Validate final IErrorList aREG1 = aValidator.validate (aRead1); final IErrorList aREG2 = aValidator.validate (aRead2); assertEquals (aREG1, aREG2); // Write final String s = aWriter.getAsString (aRead1); System.out.println (s); }
Example #5
Source File: UBL20InvoiceHelperTest.java From ph-ubl with Apache License 2.0 | 5 votes |
@Test public void testComvertBackAndForth () { for (final String sFilename : MockUBL20TestDocuments.getUBL20TestDocuments (EUBL20DocumentType.INVOICE)) { LOGGER.info (sFilename); // Read final Document aDoc = DOMReader.readXMLDOM (new ClassPathResource (sFilename), new DOMReaderSettings ().setSchema (EUBL20DocumentType.INVOICE.getSchema ())); assertNotNull (sFilename, aDoc); final InvoiceType aUBLObject = UBL20Reader.invoice ().read (aDoc); assertNotNull (sFilename, aUBLObject); // Convert Invoice to CreditNote final CreditNoteType aCreditNote = new CreditNoteType (); UBL20InvoiceHelper.cloneInvoiceToCreditNote (aUBLObject, aCreditNote); // Validate CreditNote IErrorList aErrors = UBL20Validator.creditNote ().validate (aCreditNote); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); // Convert CreditNote back to Invoice final InvoiceType aInvoice2 = new InvoiceType (); UBL20CreditNoteHelper.cloneCreditNoteToInvoice (aCreditNote, aInvoice2); // Validate Invoice again aErrors = UBL20Validator.invoice ().validate (aInvoice2); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); } }
Example #6
Source File: UBLTRBuilderFuncTest.java From ph-ubl with Apache License 2.0 | 5 votes |
@Test public void testReadAndWriteCancelUserAccount () { final UBLTRReaderBuilder <CancelUserAccountType> aReader = new UBLTRReaderBuilder<> (CancelUserAccountType.class); final UBLTRValidatorBuilder <CancelUserAccountType> aValidator = new UBLTRValidatorBuilder<> (CancelUserAccountType.class); final UBLTRWriterBuilder <CancelUserAccountType> aWriter = new UBLTRWriterBuilder<> (CancelUserAccountType.class).setFormattedOutput (true); final String sFilename = MockUBLTRTestDocuments.getUBLTRTestDocuments (EUBLTRDocumentType.CANCEL_USER_ACCOUNT) .get (0); // Read from resource final CancelUserAccountType aRead1 = aReader.read (new ClassPathResource (sFilename)); assertNotNull (aRead1); // Read from byte[] final CancelUserAccountType aRead2 = aReader.read (StreamHelper.getAllBytes (new ClassPathResource (sFilename))); assertNotNull (aRead2); assertEquals (aRead1, aRead2); // Validate final IErrorList aREG1 = aValidator.validate (aRead1); final IErrorList aREG2 = aValidator.validate (aRead2); assertEquals (aREG1, aREG2); // Write final String s = aWriter.getAsString (aRead1); System.out.println (s); }
Example #7
Source File: UBL21InvoiceHelperTest.java From ph-ubl with Apache License 2.0 | 5 votes |
@Test public void testComvertBackAndForth () { for (final String sFilename : MockUBL21TestDocuments.getUBL21TestDocuments (EUBL21DocumentType.INVOICE)) { LOGGER.info (sFilename); // Read final Document aDoc = DOMReader.readXMLDOM (new ClassPathResource (sFilename), new DOMReaderSettings ().setSchema (EUBL21DocumentType.INVOICE.getSchema ())); assertNotNull (sFilename, aDoc); final InvoiceType aUBLObject = UBL21Reader.invoice ().read (aDoc); assertNotNull (sFilename, aUBLObject); // Convert Invoice to CreditNote final CreditNoteType aCreditNote = new CreditNoteType (); UBL21InvoiceHelper.cloneInvoiceToCreditNote (aUBLObject, aCreditNote); // Validate CreditNote IErrorList aErrors = UBL21Validator.creditNote ().validate (aCreditNote); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); // Convert CreditNote back to Invoice final InvoiceType aInvoice2 = new InvoiceType (); UBL21CreditNoteHelper.cloneCreditNoteToInvoice (aCreditNote, aInvoice2); // Validate Invoice again aErrors = UBL21Validator.invoice ().validate (aInvoice2); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); } }
Example #8
Source File: UBL22InvoiceHelperTest.java From ph-ubl with Apache License 2.0 | 5 votes |
@Test public void testComvertBackAndForth () { for (final String sFilename : MockUBL22TestDocuments.getUBL22TestDocuments (EUBL22DocumentType.INVOICE)) { LOGGER.info (sFilename); // Read final Document aDoc = DOMReader.readXMLDOM (new ClassPathResource (sFilename), new DOMReaderSettings ().setSchema (EUBL22DocumentType.INVOICE.getSchema ())); assertNotNull (sFilename, aDoc); final InvoiceType aUBLObject = UBL22Reader.invoice ().read (aDoc); assertNotNull (sFilename, aUBLObject); // Convert Invoice to CreditNote final CreditNoteType aCreditNote = new CreditNoteType (); UBL22InvoiceHelper.cloneInvoiceToCreditNote (aUBLObject, aCreditNote); // Validate CreditNote IErrorList aErrors = UBL22Validator.creditNote ().validate (aCreditNote); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); // Convert CreditNote back to Invoice final InvoiceType aInvoice2 = new InvoiceType (); UBL22CreditNoteHelper.cloneCreditNoteToInvoice (aCreditNote, aInvoice2); // Validate Invoice again aErrors = UBL22Validator.invoice ().validate (aInvoice2); assertNotNull (sFilename, aErrors); assertFalse (sFilename, aErrors.containsAtLeastOneError ()); } }
Example #9
Source File: SchematronResourceSCHCacheTest.java From ph-schematron with Apache License 2.0 | 5 votes |
@Test public void testXSLTPreprocessor () { for (final IReadableResource aRes : SchematronTestHelper.getAllValidSchematronFiles ()) // BIICORE-UBL-*.sch works but takes forever // EUGEN-UBL-*.sch has a StackOverflow // The others have errors (required parameters etc.) if (!aRes.getPath ().endsWith ("/BIICORE-UBL-T01.sch") && !aRes.getPath ().endsWith ("/BIICORE-UBL-T10.sch") && !aRes.getPath ().endsWith ("/BIICORE-UBL-T14.sch") && !aRes.getPath ().endsWith ("/BIICORE-UBL-T15.sch") && !aRes.getPath ().endsWith ("/EUGEN-UBL-T14.sch") && !aRes.getPath ().endsWith ("/EUGEN-UBL-T15.sch") && !aRes.getPath ().endsWith ("/CellarBook.sch") && !aRes.getPath ().endsWith ("/pattern-example-with-includes.sch") && !aRes.getPath ().endsWith ("/pattern-example.sch") && !aRes.getPath ().endsWith ("/schematron-svrl.sch")) { if (true) LOGGER.info (aRes.toString ()); final CollectingTransformErrorListener aCEH = new CollectingTransformErrorListener (); final ISchematronXSLTBasedProvider aPreprocessor = SchematronResourceSCHCache.createSchematronXSLTProvider (aRes, new SCHTransformerCustomizer ().setErrorListener (aCEH) .setLanguageCode ("de")); assertNotNull ("Failed to parse: " + aRes.toString (), aPreprocessor); assertTrue (aRes.getPath (), aPreprocessor.isValidSchematron ()); assertNotNull (aPreprocessor.getXSLTDocument ()); final IErrorList aErrorGroup = aCEH.getErrorList (); if (aErrorGroup.isNotEmpty ()) { for (final IError aError : aErrorGroup) if (aError.isError ()) LOGGER.info ("!!" + aError.getAsString (Locale.US)); LOGGER.info ("!!" + XMLWriter.getNodeAsString (aPreprocessor.getXSLTDocument ())); } } }
Example #10
Source File: SchematronHelper.java From ph-schematron with Apache License 2.0 | 5 votes |
/** * Convert a {@link SchematronOutputType} to an {@link IErrorList}. * * @param aSchematronOutput * The result of Schematron validation * @param sResourceName * The name of the resource that was validated (may be a file path * etc.) * @return List non-<code>null</code> error list of {@link SVRLResourceError} * objects. */ @Nonnull public static IErrorList convertToErrorList (@Nonnull final SchematronOutputType aSchematronOutput, @Nullable final String sResourceName) { ValueEnforcer.notNull (aSchematronOutput, "SchematronOutput"); final ErrorList ret = new ErrorList (); for (final SVRLFailedAssert aFailedAssert : SVRLHelper.getAllFailedAssertions (aSchematronOutput)) ret.add (aFailedAssert.getAsResourceError (sResourceName)); return ret; }
Example #11
Source File: XMLSchemaValidationHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public static IErrorList validate (@Nonnull final Schema aSchema, @Nonnull final Source aXML) { final ErrorList aErrorList = new ErrorList (); validate (aSchema, aXML, aErrorList); return aErrorList; }
Example #12
Source File: XMLSchemaValidationHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public static IErrorList validate (@Nonnull final Schema aSchema, @Nonnull final IReadableResource aXML) { ValueEnforcer.notNull (aXML, "XML"); return validate (aSchema, TransformSourceFactory.create (aXML)); }
Example #13
Source File: XMLSchemaValidationHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public static IErrorList validate (@Nonnull @Nonempty final IReadableResource [] aSchemas, @Nonnull final IReadableResource aXML) { ValueEnforcer.notNull (aXML, "XML"); return validate (aSchemas, TransformSourceFactory.create (aXML)); }
Example #14
Source File: AbstractCollectingPSErrorHandler.java From ph-schematron with Apache License 2.0 | 4 votes |
@Nonnull @ReturnsMutableCopy public IErrorList getErrorList () { return m_aErrorList.getClone (); }
Example #15
Source File: AbstractCollectingPSErrorHandler.java From ph-schematron with Apache License 2.0 | 4 votes |
@Nonnull @ReturnsMutableCopy public IErrorList getAllFailures () { return m_aErrorList.getAllFailures (); }
Example #16
Source File: AbstractCollectingPSErrorHandler.java From ph-schematron with Apache License 2.0 | 4 votes |
@Nonnull @ReturnsMutableCopy public IErrorList getAllErrors () { return m_aErrorList.getAllErrors (); }
Example #17
Source File: CollectingSAXErrorHandler.java From ph-commons with Apache License 2.0 | 4 votes |
@Nonnull @ReturnsMutableCopy public IErrorList getErrorList () { return m_aRWLock.readLockedGet (m_aErrors::getClone); }
Example #18
Source File: XMLSchemaValidationHelper.java From ph-commons with Apache License 2.0 | 4 votes |
@Nonnull public static IErrorList validate (@Nonnull @Nonempty final IReadableResource [] aSchemas, @Nonnull final Source aXML) { // Get Schema from XMLSchemaCache return validate (XMLSchemaCache.getInstance ().getSchema (aSchemas), aXML); }
Example #19
Source File: XMLSchemaValidationHelper.java From ph-commons with Apache License 2.0 | 4 votes |
@Nonnull public static IErrorList validate (@Nonnull @Nonempty final IReadableResource aSchema, @Nonnull final Source aXML) { return validate (new IReadableResource [] { aSchema }, aXML); }
Example #20
Source File: XMLSchemaValidationHelper.java From ph-commons with Apache License 2.0 | 4 votes |
@Nonnull public static IErrorList validate (@Nonnull final IReadableResource aSchema, @Nonnull final IReadableResource aXML) { return validate (new IReadableResource [] { aSchema }, aXML); }
Example #21
Source File: CollectingValidationEventHandler.java From ph-commons with Apache License 2.0 | 4 votes |
@Nonnull @ReturnsMutableCopy public IErrorList getErrorList () { return m_aRWLock.readLockedGet (m_aErrors::getClone); }
Example #22
Source File: IJAXBDocumentType.java From ph-commons with Apache License 2.0 | 3 votes |
/** * Validate the passed XML instance against the XML Schema of this document * type using the default class loader. * * @param aXML * The XML resource to be validated. May not be <code>null</code>. * @return A group of validation errors. Is empty if no error occurred. * <code>null</code> is returned if this document type has no XSDs * assigned and therefore not validation can take place. */ @Nullable default IErrorList validateXML (@Nonnull final IReadableResource aXML) { final Schema aSchema = getSchema (); return aSchema == null ? null : XMLSchemaValidationHelper.validate (aSchema, aXML); }