33import org .junit .jupiter .api .Test ;
44
55import java .io .File ;
6- import java .util .HashMap ;
76import java .util .List ;
87import java .util .Map ;
98import java .util .Set ;
@@ -72,9 +71,8 @@ public void CreateAndOpenSimpleCase() throws Exception {
7271 @ Test
7372 public void LoadDataIntoSimpleCase () throws Exception {
7473 File caseDirectory = new File (testOutputDirectory , "LoadDataIntoSimpleCase_Case" );
75- File dataDirectory = new File (testOutputDirectory , "LoadDataIntoSimpleCase_Natives" );
76-
77- List <TermCount > termCounts = createSearchableTestData (dataDirectory , 1000 );
74+ File textFilesDirectory = TestData .getTestDataTextFilesDirectory ();
75+ Map <String , Long > termCounts = TestData .getTestDataTextFileTermCounts ();
7876
7977 NuixEngine nuixEngine = constructNuixEngine ();
8078 nuixEngine .run ((utilities -> {
@@ -90,17 +88,19 @@ public void LoadDataIntoSimpleCase() throws Exception {
9088 log .info ("Queuing data for processing..." );
9189 Processor processor = nuixCase .createProcessor ();
9290 EvidenceContainer evidenceContainer = processor .newEvidenceContainer ("SearchTestData" );
93- evidenceContainer .addFile (dataDirectory );
91+ evidenceContainer .addFile (textFilesDirectory );
9492 evidenceContainer .save ();
9593 log .info ("Processing starting..." );
9694 processor .process ();
9795 log .info ("Processing completed" );
9896
9997 log .info ("Validating search counts..." );
100- for (TermCount termCount : termCounts ) {
101- long hitCount = nuixCase .count (termCount .term );
102- assertEquals (termCount .count , hitCount , String .format ("For term %s, expect %s but got %s" ,
103- termCount .term , termCount .count , hitCount ));
98+ for (Map .Entry <String , Long > termCount : termCounts .entrySet ()) {
99+ String term = termCount .getKey ();
100+ Long count = termCount .getValue () + 1 ; // Add 1 for hit on term counts JSON
101+ long hitCount = nuixCase .count (term );
102+ assertEquals (count , hitCount , String .format ("For term %s, expect %s but got %s" ,
103+ term , count , hitCount ));
104104 }
105105
106106 log .info ("Closing case" );
@@ -111,9 +111,8 @@ public void LoadDataIntoSimpleCase() throws Exception {
111111 @ Test
112112 public void SearchAndTag () throws Exception {
113113 File caseDirectory = new File (testOutputDirectory , "SearchAndTag_Case" );
114- File dataDirectory = new File (testOutputDirectory , "SearchAndTag_Natives" );
115-
116- List <TermCount > termCounts = createSearchableTestData (dataDirectory , 5000 );
114+ File textFilesDirectory = TestData .getTestDataTextFilesDirectory ();
115+ Map <String , Long > termCounts = TestData .getTestDataTextFileTermCounts ();
117116
118117 NuixEngine nuixEngine = constructNuixEngine ();
119118 nuixEngine .run ((utilities -> {
@@ -129,7 +128,7 @@ public void SearchAndTag() throws Exception {
129128 log .info ("Queuing data for processing..." );
130129 Processor processor = nuixCase .createProcessor ();
131130 EvidenceContainer evidenceContainer = processor .newEvidenceContainer ("SearchTestData" );
132- evidenceContainer .addFile (dataDirectory );
131+ evidenceContainer .addFile (textFilesDirectory );
133132 evidenceContainer .save ();
134133
135134 // Periodically log progress
@@ -149,21 +148,24 @@ public void SearchAndTag() throws Exception {
149148 log .info ("Processing completed" );
150149
151150 log .info ("Applying Tags..." );
152- for (TermCount termCount : termCounts ) {
153- String tag = "Terms|" + termCount .term ;
154- Set <Item > responsiveItems = nuixCase .searchUnsorted (termCount .term );
151+ for (Map .Entry <String , Long > termCount : termCounts .entrySet ()) {
152+ String term = termCount .getKey ();
153+ String tag = "Terms|" + term ;
154+ Set <Item > responsiveItems = nuixCase .searchUnsorted (term );
155155 log .info (String .format ("Tagging %s items with tag '%s'" ,
156156 responsiveItems .size (), tag ));
157157 utilities .getBulkAnnotater ().addTag (tag , responsiveItems );
158158 }
159159
160160 log .info ("Validating tag counts..." );
161- for (TermCount termCount : termCounts ) {
162- String tag = "Terms|" + termCount .term ;
161+ for (Map .Entry <String , Long > termCount : termCounts .entrySet ()) {
162+ String term = termCount .getKey ();
163+ Long count = termCount .getValue () + 1 ; // Add 1 for hit on term counts JSON
164+ String tag = "Terms|" + term ;
163165 String query = "tag:\" " + tag + "\" " ;
164166 long hitCount = nuixCase .count (query );
165- assertEquals (termCount . count , hitCount , String .format ("For term %s, expect %s tagged items, but got %s" ,
166- termCount . term , termCount . count , hitCount ));
167+ assertEquals (count , hitCount , String .format ("For term %s, expect %s tagged items, but got %s" ,
168+ term , count , hitCount ));
167169 }
168170
169171 log .info ("Closing case" );
@@ -174,9 +176,8 @@ public void SearchAndTag() throws Exception {
174176 @ Test
175177 public void CreateProductionSet () throws Exception {
176178 File caseDirectory = new File (testOutputDirectory , "CreateProductionSet_Case" );
177- File dataDirectory = new File (testOutputDirectory , "CreateProductionSet_Natives" );
178-
179- List <TermCount > termCounts = createSearchableTestData (dataDirectory , 5000 );
179+ File textFilesDirectory = TestData .getTestDataTextFilesDirectory ();
180+ Map <String , Long > termCounts = TestData .getTestDataTextFileTermCounts ();
180181
181182 NuixEngine nuixEngine = constructNuixEngine ();
182183 nuixEngine .run ((utilities -> {
@@ -192,7 +193,7 @@ public void CreateProductionSet() throws Exception {
192193 log .info ("Queuing data for processing..." );
193194 Processor processor = nuixCase .createProcessor ();
194195 EvidenceContainer evidenceContainer = processor .newEvidenceContainer ("SearchTestData" );
195- evidenceContainer .addFile (dataDirectory );
196+ evidenceContainer .addFile (textFilesDirectory );
196197 evidenceContainer .save ();
197198
198199 // Periodically log progress
@@ -242,11 +243,10 @@ public void CreateProductionSet() throws Exception {
242243 @ Test
243244 public void Export () throws Exception {
244245 File caseDirectory = new File (testOutputDirectory , "ExportTest_Case" );
245- File dataDirectory = new File (testOutputDirectory , "ExportTest_Natives" );
246+ File textFilesDirectory = TestData .getTestDataTextFilesDirectory ();
247+ Map <String , Long > termCounts = TestData .getTestDataTextFileTermCounts ();
246248 File exportDirectory = new File (testOutputDirectory , "ExportTest_Export" );
247249
248- List <TermCount > termCounts = createSearchableTestData (dataDirectory , 5000 );
249-
250250 NuixEngine nuixEngine = constructNuixEngine ();
251251 nuixEngine .run ((utilities -> {
252252 // Create a new case
@@ -261,7 +261,7 @@ public void Export() throws Exception {
261261 log .info ("Queuing data for processing..." );
262262 Processor processor = nuixCase .createProcessor ();
263263 EvidenceContainer evidenceContainer = processor .newEvidenceContainer ("SearchTestData" );
264- evidenceContainer .addFile (dataDirectory );
264+ evidenceContainer .addFile (textFilesDirectory );
265265 evidenceContainer .save ();
266266
267267 // Periodically log progress
@@ -339,7 +339,7 @@ public void Export() throws Exception {
339339 // ParallelProcessingConfigurable.setParallelProcessingSettings for list of settings and what they do.
340340 exporter .setParallelProcessingSettings (Map .of (
341341 "workerCount" , utilities .getLicence ().getWorkers (),
342- "workerTemp" , new File (testOutputDirectory ,"WorkerTemp" ).getAbsolutePath ()
342+ "workerTemp" , new File (testOutputDirectory , "WorkerTemp" ).getAbsolutePath ()
343343 ));
344344
345345 // Track error count
@@ -348,6 +348,7 @@ public void Export() throws Exception {
348348 exporter .whenItemEventOccurs (new ItemEventCallback () {
349349 // Use this to track when we reported progress last
350350 long lastProgressMillis = System .currentTimeMillis ();
351+
351352 @ Override
352353 public void itemProcessed (ItemEventInfo info ) {
353354 // Report progress if it has been at least 5 seconds (5000 milliseconds) since
0 commit comments