Testing the invoice database

Tags: ZUGFeRDpublish databaseiText 5

In the examples stored under ZUGFeRD: POJOs for our simple invoice database, we create the infrastructure to query an invoice database.

This example will use this infrastructure to test if the database can be accessed and if the POJOs give us access to all the data we need.

The output of this test example looks like this:

Invoice id: 4 Date: 2015-04-01 Total cost: 1507.0€
Customer: 30
    First Name: Bill
    Last Name: Sommer
    Street: 362 - 20th Ave.
    City: BE 9000 Ghent
  #0  (28)   Running jersey      8.0€   vat 21.0%  Quantity: 9  Cost: 72.0€
  #1  (35)   Golf polo           8.0€   vat 21.0%  Quantity: 1  Cost: 8.0€
  #2  (41)   Threadmill          600.0€ vat 21.0%  Quantity: 2  Cost: 1200.0€
  #3  (23)   Pro steel dartboard 25.0€  vat 21.0%  Quantity: 2  Cost: 50.0€
  #4  (9)    My First Cookbook   17.0€  vat 6.0%   Quantity: 1  Cost: 17.0€
  #5  (37)   Golf kit            80.0€  vat 21.0%  Quantity: 2  Cost: 160.0€
Files: 
/*
 * This example was written by Bruno Lowagie
 */
package zugferd;
 
import java.sql.SQLException;
import java.util.List;
 
import zugferd.pojo.Invoice;
import zugferd.pojo.PojoFactory;
 
/**
 * A simple example to test the database
 */
public class DatabaseTest {
    public static void main(String[] args) throws SQLException {
        PojoFactory factory = PojoFactory.getInstance();
        List<Invoice> invoices = factory.getInvoices();
        for (Invoice invoice : invoices)
            System.out.println(invoice.toString());
        factory.close();
    }
}
File nameRaw URLUpdated
DatabaseTest.javaDatabaseTest.java2015-08-30 11:20 am
Resources: 
File nameRaw URLUpdated
invoices.scriptinvoices.script2015-08-30 10:37 am