@@ -34,7 +34,8 @@ public class CompareComplyV1IntegrationTests
3434 private string versionDate = "2019-02-13" ;
3535 private string contractAFilepath ;
3636 private string contractBFilepath ;
37- private string tableFilepath ;
37+ private string tablePdfFilepath ;
38+ private string tablePngFilepath ;
3839 private string createdFeedbackId ;
3940 private string objectStorageCredentialsInputFilepath ;
4041 private string objectStorageCredentialsOutputFilepath ;
@@ -47,7 +48,8 @@ public void OneTimeSetup()
4748
4849 contractAFilepath = Application . dataPath + "/Watson/Tests/TestData/CompareComplyV1/contract_A.pdf" ;
4950 contractBFilepath = Application . dataPath + "/Watson/Tests/TestData/CompareComplyV1/contract_B.pdf" ;
50- tableFilepath = Application . dataPath + "/Watson/Tests/TestData/CompareComplyV1/TestTable.pdf" ;
51+ tablePdfFilepath = Application . dataPath + "/Watson/Tests/TestData/CompareComplyV1/TestTable.pdf" ;
52+ tablePngFilepath = Application . dataPath + "/Watson/Tests/TestData/CompareComplyV1/TableTestV3.png" ;
5153
5254 objectStorageCredentialsInputFilepath = "../sdk-credentials/cloud-object-storage-credentials-input.json" ;
5355 objectStorageCredentialsOutputFilepath = "../sdk-credentials/cloud-object-storage-credentials-output.json" ;
@@ -137,13 +139,13 @@ public IEnumerator TestClassifyElements()
137139 }
138140 #endregion
139141
140- #region ExtractTables
142+ #region ExtractTablesPdf
141143 [ UnityTest , Order ( 2 ) ]
142- public IEnumerator TestExtractTables ( )
144+ public IEnumerator TestExtractPdfTables ( )
143145 {
144146 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to ExtractTables..." ) ;
145147 TableReturn extractTablesResponse = null ;
146- using ( FileStream fs = File . OpenRead ( tableFilepath ) )
148+ using ( FileStream fs = File . OpenRead ( tablePdfFilepath ) )
147149 {
148150 using ( MemoryStream ms = new MemoryStream ( ) )
149151 {
@@ -161,19 +163,12 @@ public IEnumerator TestExtractTables()
161163 Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . ColumnHeaderIds ) ;
162164 Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . ColumnHeaderTexts ) ;
163165 Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . ColumnHeaderTextsNormalized ) ;
164- //Assert.IsTrue(extractTablesResponse.Tables[0].BodyCells[0].RowHeaderIds.Count > 0);
165- //Assert.IsTrue(extractTablesResponse.Tables[0].BodyCells[0].RowHeaderTexts.Count > 0);
166- //Assert.IsTrue(extractTablesResponse.Tables[0].BodyCells[0].RowHeaderTextsNormalized.Count > 0);
167- //Assert.IsTrue(extractTablesResponse.Tables[0].BodyCells[0].ColumnHeaderIds.Count > 0);
168- //Assert.IsTrue(extractTablesResponse.Tables[0].BodyCells[0].ColumnHeaderTexts.Count > 0);
169- //Assert.IsTrue(extractTablesResponse.Tables[0].BodyCells[0].ColumnHeaderTextsNormalized.Count > 0);
170166 Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . KeyValuePairs ) ;
171- //Assert.IsTrue(extractTablesResponse.Tables[0].KeyValuePairs.Count > 0);
172167 Assert . IsNull ( error ) ;
173168 } ,
174169 file : ms ,
175170 model : "tables" ,
176- fileContentType : Utility . GetMimeType ( Path . GetExtension ( tableFilepath ) )
171+ fileContentType : Utility . GetMimeType ( Path . GetExtension ( tablePdfFilepath ) )
177172 ) ;
178173
179174 while ( extractTablesResponse == null )
@@ -183,8 +178,47 @@ public IEnumerator TestExtractTables()
183178 }
184179 #endregion
185180
186- #region CompareDocuments
181+ #region ExtractTablesPng
187182 [ UnityTest , Order ( 3 ) ]
183+ public IEnumerator TestExtractPngTables ( )
184+ {
185+ Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to ExtractTables..." ) ;
186+ TableReturn extractTablesResponse = null ;
187+ using ( FileStream fs = File . OpenRead ( tablePngFilepath ) )
188+ {
189+ using ( MemoryStream ms = new MemoryStream ( ) )
190+ {
191+ fs . CopyTo ( ms ) ;
192+ service . ExtractTables (
193+ callback : ( DetailedResponse < TableReturn > response , IBMError error ) =>
194+ {
195+ Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "ExtractTables from png file result: {0}" , response . Response ) ;
196+ extractTablesResponse = response . Result ;
197+ Assert . IsNotNull ( extractTablesResponse ) ;
198+ Assert . IsNotNull ( extractTablesResponse . Tables ) ;
199+ Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . RowHeaderIds ) ;
200+ Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . RowHeaderTexts ) ;
201+ Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . RowHeaderTextsNormalized ) ;
202+ Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . ColumnHeaderIds ) ;
203+ Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . ColumnHeaderTexts ) ;
204+ Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . BodyCells [ 0 ] . ColumnHeaderTextsNormalized ) ;
205+ Assert . IsNotNull ( extractTablesResponse . Tables [ 0 ] . KeyValuePairs ) ;
206+ Assert . IsNull ( error ) ;
207+ } ,
208+ file : ms ,
209+ model : "tables" ,
210+ fileContentType : Utility . GetMimeType ( Path . GetExtension ( tablePngFilepath ) )
211+ ) ;
212+
213+ while ( extractTablesResponse == null )
214+ yield return null ;
215+ }
216+ }
217+ }
218+ #endregion
219+
220+ #region CompareDocuments
221+ [ UnityTest , Order ( 4 ) ]
188222 public IEnumerator TestCompareDocuments ( )
189223 {
190224 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to CompareDocuments..." ) ;
@@ -227,7 +261,7 @@ public IEnumerator TestCompareDocuments()
227261 #endregion
228262
229263 #region AddFeedback
230- [ UnityTest , Order ( 4 ) ]
264+ [ UnityTest , Order ( 5 ) ]
231265 public IEnumerator TestAddFeedback ( )
232266 {
233267 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to AddFeedback..." ) ;
@@ -352,7 +386,7 @@ public IEnumerator TestAddFeedback()
352386 #endregion
353387
354388 #region GetFeedback
355- [ UnityTest , Order ( 5 ) ]
389+ [ UnityTest , Order ( 6 ) ]
356390 public IEnumerator TestGetFeedback ( )
357391 {
358392 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to GetFeedback..." ) ;
@@ -376,7 +410,7 @@ public IEnumerator TestGetFeedback()
376410 #endregion
377411
378412 #region ListFeedback
379- [ UnityTest , Order ( 6 ) ]
413+ [ UnityTest , Order ( 7 ) ]
380414 public IEnumerator TestListFeedback ( )
381415 {
382416 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to ListFeedback..." ) ;
@@ -401,7 +435,7 @@ public IEnumerator TestListFeedback()
401435 #endregion
402436
403437 #region CreateBatch
404- [ UnityTest , Order ( 7 ) ]
438+ [ UnityTest , Order ( 8 ) ]
405439 public IEnumerator TestCreateBatch ( )
406440 {
407441 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to CreateBatch..." ) ;
@@ -447,7 +481,7 @@ public IEnumerator TestCreateBatch()
447481 #endregion
448482
449483 #region GetBatch
450- [ UnityTest , Order ( 8 ) ]
484+ [ UnityTest , Order ( 9 ) ]
451485 public IEnumerator TestGetBatch ( )
452486 {
453487 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to GetBatch..." ) ;
@@ -470,7 +504,7 @@ public IEnumerator TestGetBatch()
470504 #endregion
471505
472506 #region ListBatches
473- [ UnityTest , Order ( 9 ) ]
507+ [ UnityTest , Order ( 10 ) ]
474508 public IEnumerator TestListBatches ( )
475509 {
476510 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to ListBatches..." ) ;
@@ -493,7 +527,7 @@ public IEnumerator TestListBatches()
493527 #endregion
494528
495529 #region UpdateBatch
496- [ UnityTest , Order ( 10 ) ]
530+ [ UnityTest , Order ( 11 ) ]
497531 public IEnumerator TestUpdateBatch ( )
498532 {
499533 Log . Debug ( "CompareComplyServiceV1IntegrationTests" , "Attempting to UpdateBatch..." ) ;
0 commit comments