@@ -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
@@ -71,29 +69,37 @@ public void givenAPDF_shouldExtractInvoicesStrict() throws IOException, Interrup
7169 Assertions .assertEquals (2 , extractedPDFsStrict .size ());
7270 Assertions .assertEquals ("default_sample_001-001.pdf" , extractedPDFsStrict .get (0 ).getFilename ());
7371 Assertions .assertEquals ("default_sample_002-002.pdf" , extractedPDFsStrict .get (1 ).getFilename ());
74- PredictResponse <InvoiceV4 > invoice0 =
75- getInvoicePrediction (extractedPDFsStrict .get (0 ).asInputSource ());
7672
73+ PredictResponse <InvoiceV4 > invoice0 = getInvoicePrediction (
74+ extractedPDFsStrict .get (0 ).asInputSource ()
75+ );
7776 String testStringRSTInvoice0 = prepareInvoiceReturn (
7877 "src/test/resources/products/invoices/response_v4/summary_full_invoice_p1.rst" ,
79- invoice0 .getDocument ());
80- Assertions .assertEquals (testStringRSTInvoice0 , String .join (String .format ("%n" ),
81- invoice0 .getDocument ().toString ().split (System .lineSeparator ())));
82-
83- PredictResponse <InvoiceV4 > invoice1 =
84- getInvoicePrediction (extractedPDFsStrict .get (1 ).asInputSource ());
78+ invoice0 .getDocument ()
79+ );
80+ double invoice0Ratio = levenshteinRatio (
81+ testStringRSTInvoice0 ,
82+ String .join (
83+ String .format ("%n" ),
84+ invoice0 .getDocument ().toString ().split (System .lineSeparator ())
85+ )
86+ );
87+ Assertions .assertTrue (invoice0Ratio > 0.90 );
8588
89+ PredictResponse <InvoiceV4 > invoice1 = getInvoicePrediction (
90+ extractedPDFsStrict .get (1 ).asInputSource ()
91+ );
8692 String testStringRSTInvoice1 = prepareInvoiceReturn (
8793 "src/test/resources/products/invoices/response_v4/summary_full_invoice_p2.rst" ,
88- invoice1 .getDocument ());
89- Assertions . assertTrue (
90- levenshteinRatio (
94+ invoice1 .getDocument ()
95+ );
96+ double invoice1Ratio = levenshteinRatio (
9197 testStringRSTInvoice1 ,
92- String .join (String .format ("%n" ),
93- invoice1 .getDocument ().toString ().split (System .lineSeparator ())
98+ String .join (
99+ String .format ("%n" ),
100+ invoice1 .getDocument ().toString ().split (System .lineSeparator ())
94101 )
95- ) > 0.97 );
96-
97-
102+ );
103+ Assertions .assertTrue (invoice1Ratio > 0.90 );
98104 }
99105}
0 commit comments