Skip to content

Commit

Permalink
improved junit tests
Browse files Browse the repository at this point in the history
Issue #215
  • Loading branch information
rsoika committed Nov 3, 2024
1 parent d8d3482 commit 2bb187c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private void readEInvoiceContent(FileData eInvoiceFileData,
ZUGFeRDInvoiceImporter zii = new ZUGFeRDInvoiceImporter(new ByteArrayInputStream(xmlData));

Invoice invoice = zii.extractInvoice();

workitem.setItemValue("invoice.number", invoice.getNumber());
workitem.setItemValue("cdtr.name", invoice.getOwnOrganisationName());
workitem.setItemValue("invoice.date", invoice.getIssueDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -78,6 +77,11 @@ void testXMLWithExtraction() throws AdapterException, PluginException, IOExcepti

assertEquals("R-00010", workitem.getItemValueString("invoice.number"));
assertEquals("Max Mustermann", workitem.getItemValueString("cdtr.name"));
LocalDate invoiceDate = workitem.getItemValueDate("invoice.date").toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
assertEquals(LocalDate.of(2021, 7, 28), invoiceDate);

}

/**
Expand All @@ -98,10 +102,11 @@ void testZugferdWithExtraction() throws AdapterException, PluginException, IOExc

assertEquals("R-00011", workitem.getItemValueString("invoice.number"));
assertEquals("Max Mustermann", workitem.getItemValueString("cdtr.name"));
ZonedDateTime expectedZdt = ZonedDateTime.of(2021, 7, 27, 0, 0, 0, 0, ZoneId.of("Europe/Berlin"));
Date expectedDate = Date.from(expectedZdt.toInstant());

assertEquals(expectedDate, workitem.getItemValueDate("invoice.date"));
LocalDate invoiceDate = workitem.getItemValueDate("invoice.date").toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
assertEquals(LocalDate.of(2021, 7, 27), invoiceDate);

// Payment data
assertEquals(892.50, workitem.getItemValueFloat("invoice.total"));
Expand Down

0 comments on commit 2bb187c

Please # to comment.