@Test public void ubl_can_be_converted_to_invoice() throws IOException { byte[] xml = IOUtils.getResourceAsByteArray(RESOURCES_PATH + "/" + TEST_UBL_FILE_NAME); assertNotNull(xml); Invoice invoice = documentService.convertToInvoice(xml); assertNotNull(invoice); assertNotNull(invoice.getContent()); }
@Test public void invoice_can_be_validated() throws IOException { byte[] xml = IOUtils.getResourceAsByteArray(RESOURCES_PATH + "/" + TEST_UBL_FILE_NAME); Invoice invoice = documentService.convertToInvoice(xml); assertNotNull(invoice); assertNotNull(invoice.getContent()); assertNotNull(invoice.getContent().getID()); assertEquals("HSD5", invoice.getContent().getID().getValue()); assertNotNull(invoice.getContent().getAccountingCustomerParty()); assertNotNull(invoice.getContent().getAccountingCustomerParty().getParty()); assertNotNull(invoice.getContent().getAccountingCustomerParty().getParty().getPartyName()); assertTrue( invoice.getContent().getAccountingCustomerParty().getParty().getPartyName().size() > 0); assertNotNull( invoice .getContent() .getAccountingCustomerParty() .getParty() .getPartyName() .get(0) .getName()); assertEquals( "Lemberg", invoice .getContent() .getAccountingCustomerParty() .getParty() .getPartyName() .get(0) .getName() .getValue()); assertNotNull(invoice.getContent().getAccountingCustomerParty().getParty().getPostalAddress()); assertNotNull( invoice .getContent() .getAccountingCustomerParty() .getParty() .getPostalAddress() .getCountry()); assertNotNull( invoice .getContent() .getAccountingCustomerParty() .getParty() .getPostalAddress() .getCountry() .getIdentificationCode()); assertEquals( "UA", invoice .getContent() .getAccountingCustomerParty() .getParty() .getPostalAddress() .getCountry() .getIdentificationCode() .getValue()); assertNotNull(invoice.getContent().getLegalMonetaryTotal()); assertNotNull(invoice.getContent().getLegalMonetaryTotal().getPayableAmount()); assertEquals( new BigDecimal("760.00"), invoice.getContent().getLegalMonetaryTotal().getPayableAmount().getValue()); assertNotNull(invoice.getContent().getDocumentCurrencyCode()); assertEquals("DKK", invoice.getContent().getDocumentCurrencyCode().getValue()); }