@@ -42,10 +42,8 @@ protected Document<InvoiceSplitterV1> getInvoiceSplitterPrediction() throws
4242 protected PredictResponse <InvoiceV4 > getInvoicePrediction (LocalInputSource invoicePDF ) throws
4343 IOException , MindeeException {
4444 return client .parse (InvoiceV4 .class , invoicePDF );
45-
4645 }
4746
48-
4947 protected String prepareInvoiceReturn (String rstFilePath , Document <InvoiceV4 > invoicePrediction )
5048 throws IOException {
5149 List <String > rstRefLines = Files .readAllLines (Paths .get (rstFilePath ));
@@ -60,7 +58,7 @@ protected String prepareInvoiceReturn(String rstFilePath, Document<InvoiceV4> in
6058 }
6159
6260 @ Test
63- public void givenAPDF_shouldExtractInvoicesStrict () throws IOException , InterruptedException {
61+ public void givenAPDF_shouldExtractInvoices () throws IOException , InterruptedException {
6462 Document <InvoiceSplitterV1 > document = getInvoiceSplitterPrediction ();
6563 InvoiceSplitterV1 inference = document .getInference ();
6664
@@ -77,23 +75,30 @@ public void givenAPDF_shouldExtractInvoicesStrict() throws IOException, Interrup
7775 String testStringRSTInvoice0 = prepareInvoiceReturn (
7876 "src/test/resources/products/invoices/response_v4/summary_full_invoice_p1.rst" ,
7977 invoice0 .getDocument ());
80- Assertions .assertEquals (testStringRSTInvoice0 , String .join (String .format ("%n" ),
81- invoice0 .getDocument ().toString ().split (System .lineSeparator ())));
78+
79+ double invoice0Ratio = levenshteinRatio (
80+ testStringRSTInvoice0 ,
81+ String .join (
82+ String .format ("%n" ),
83+ invoice0 .getDocument ().toString ().split (System .lineSeparator ())
84+ )
85+ );
86+ Assertions .assertTrue (invoice0Ratio > 0.90 );
8287
8388 PredictResponse <InvoiceV4 > invoice1 =
8489 getInvoicePrediction (extractedPDFsStrict .get (1 ).asInputSource ());
8590
8691 String testStringRSTInvoice1 = prepareInvoiceReturn (
8792 "src/test/resources/products/invoices/response_v4/summary_full_invoice_p2.rst" ,
8893 invoice1 .getDocument ());
89- Assertions . assertTrue (
90- levenshteinRatio (
94+
95+ double invoice1Ratio = levenshteinRatio (
9196 testStringRSTInvoice1 ,
92- String .join (String .format ("%n" ),
93- invoice1 .getDocument ().toString ().split (System .lineSeparator ())
97+ String .join (
98+ String .format ("%n" ),
99+ invoice1 .getDocument ().toString ().split (System .lineSeparator ())
94100 )
95- ) > 0.97 );
96-
97-
101+ );
102+ Assertions .assertTrue (invoice1Ratio > 0.90 );
98103 }
99104}
0 commit comments