5555import java .nio .file .Files ;
5656import java .security .NoSuchAlgorithmException ;
5757import java .util .ArrayList ;
58+ import java .util .HashMap ;
5859import java .util .List ;
5960
6061import static org .junit .Assert .assertEquals ;
@@ -70,6 +71,8 @@ public class TargetFileServiceBundleIT extends BasePaxIT {
7071
7172 private static final String LOCAL_OBD_DIR = "imi.local_obd_dir" ;
7273 private static final String REMOTE_OBD_DIR = "imi.remote_obd_dir" ;
74+ private static final String Jh = "JH" ;
75+ private static final String non_Jh = "NON-JH" ;
7376
7477
7578 private String localObdDirBackup ;
@@ -175,9 +178,9 @@ public void createLargeFile() {
175178 ));
176179 }
177180
178- TargetFileNotification tfn = targetFileService .generateTargetFile ();
179- assertNotNull (tfn );
180- getLogger ().debug ("Generated {}" , tfn .getFileName ());
181+ HashMap < String , TargetFileNotification > tfn = targetFileService .generateTargetFile (false );
182+ assertNotNull (tfn . get ( non_Jh ) );
183+ getLogger ().debug ("Generated {}" , tfn .values (). toString ());
181184 }
182185
183186 // To check that target file should contain correct weekID according to LMP of the subscriber.
@@ -198,10 +201,10 @@ public void verifyFT151() throws NoSuchAlgorithmException, IOException {
198201 List <String > contents = new ArrayList <>();
199202 String line ;
200203
201- TargetFileNotification tfn = targetFileService .generateTargetFile ();
204+ HashMap < String , TargetFileNotification > tfn = targetFileService .generateTargetFile (false );
202205
203206 File targetDir = new File (settingsService .getSettingsFacade ().getProperty ("imi.local_obd_dir" ));
204- File targetFile = new File (targetDir , tfn .getFileName ());
207+ File targetFile = new File (targetDir , tfn .get ( non_Jh ). getFileName ());
205208 int recordCount = 0 ;
206209 boolean header = true ;
207210 try (InputStream is = Files .newInputStream (targetFile .toPath ());
@@ -218,8 +221,8 @@ public void verifyFT151() throws NoSuchAlgorithmException, IOException {
218221
219222 String checksum = ChecksumHelper .checksum (targetFile );
220223
221- assertEquals ((int )tfn .getRecordsCount (), recordCount );
222- assertEquals (tfn .getChecksum (), checksum );
224+ assertEquals ((int )tfn .get ( non_Jh ). getRecordsCount (), recordCount );
225+ assertEquals (tfn .get ( non_Jh ). getChecksum (), checksum );
223226 assertTrue ("w6_1" .equals (contents .get (0 )));
224227 assertEquals (1 , recordCount );
225228 }
@@ -242,10 +245,10 @@ public void verifyFT152() throws NoSuchAlgorithmException, IOException {
242245 List <String > contents = new ArrayList <>();
243246 String line ;
244247
245- TargetFileNotification tfn = targetFileService .generateTargetFile ();
248+ HashMap < String , TargetFileNotification > tfn = targetFileService .generateTargetFile (false );
246249
247250 File targetDir = new File (settingsService .getSettingsFacade ().getProperty ("imi.local_obd_dir" ));
248- File targetFile = new File (targetDir , tfn .getFileName ());
251+ File targetFile = new File (targetDir , tfn .get ( non_Jh ). getFileName ());
249252 int recordCount = 0 ;
250253 boolean header = true ;
251254 try (InputStream is = Files .newInputStream (targetFile .toPath ());
@@ -261,8 +264,8 @@ public void verifyFT152() throws NoSuchAlgorithmException, IOException {
261264 }
262265
263266 String checksum = ChecksumHelper .checksum (targetFile );
264- assertEquals ((int )tfn .getRecordsCount (), recordCount );
265- assertEquals (tfn .getChecksum (), checksum );
267+ assertEquals ((int )tfn .get ( non_Jh ). getRecordsCount (), recordCount );
268+ assertEquals (tfn .get ( non_Jh ). getChecksum (), checksum );
266269 assertTrue ("w5_1" .equals (contents .get (0 )));
267270
268271 //update the date of birth of the subscriber
@@ -272,9 +275,9 @@ public void verifyFT152() throws NoSuchAlgorithmException, IOException {
272275 subscriberService .updateStartDate (subscriber2 );
273276
274277 // again generate the target file to check correct weekId is picked after DOB is changed.
275- tfn = targetFileService .generateTargetFile ();
278+ tfn = targetFileService .generateTargetFile (false );
276279 contents .clear ();
277- targetFile = new File (targetDir , tfn .getFileName ());
280+ targetFile = new File (targetDir , tfn .get ( non_Jh ). getFileName ());
278281 recordCount = 0 ;
279282 header = true ;
280283 try (InputStream is = Files .newInputStream (targetFile .toPath ());
@@ -289,8 +292,8 @@ public void verifyFT152() throws NoSuchAlgorithmException, IOException {
289292 }
290293 }
291294 checksum = ChecksumHelper .checksum (targetFile );
292- assertEquals ((int )tfn .getRecordsCount (), recordCount );
293- assertEquals (tfn .getChecksum (), checksum );
295+ assertEquals ((int )tfn .get ( non_Jh ). getRecordsCount (), recordCount );
296+ assertEquals (tfn .get ( non_Jh ). getChecksum (), checksum );
294297 assertTrue ("w4_1" .equals (contents .get (0 )));
295298 assertEquals (1 , recordCount );
296299 }
@@ -313,10 +316,10 @@ public void verifyFT190() throws NoSuchAlgorithmException, IOException {
313316 List <String > contents = new ArrayList <>();
314317 String line ;
315318
316- TargetFileNotification tfn = targetFileService .generateTargetFile ();
319+ HashMap < String , TargetFileNotification > tfn = targetFileService .generateTargetFile (false );
317320
318321 File targetDir = new File (settingsService .getSettingsFacade ().getProperty ("imi.local_obd_dir" ));
319- File targetFile = new File (targetDir , tfn .getFileName ());
322+ File targetFile = new File (targetDir , tfn .get ( non_Jh ). getFileName ());
320323 int recordCount = 0 ;
321324 boolean header = true ;
322325 try (InputStream is = Files .newInputStream (targetFile .toPath ());
@@ -332,8 +335,8 @@ public void verifyFT190() throws NoSuchAlgorithmException, IOException {
332335 }
333336
334337 String checksum = ChecksumHelper .checksum (targetFile );
335- assertEquals ((int )tfn .getRecordsCount (), recordCount );
336- assertEquals (tfn .getChecksum (), checksum );
338+ assertEquals ((int )tfn .get ( non_Jh ). getRecordsCount (), recordCount );
339+ assertEquals (tfn .get ( non_Jh ). getChecksum (), checksum );
337340 assertTrue ("w1_1.wav" .equals (contents .get (0 )));
338341 }
339342
@@ -355,10 +358,10 @@ public void verifyFT191() throws NoSuchAlgorithmException, IOException {
355358 List <String > contents = new ArrayList <>();
356359 String line ;
357360
358- TargetFileNotification tfn = targetFileService .generateTargetFile ();
361+ HashMap < String , TargetFileNotification > tfn = targetFileService .generateTargetFile (false );
359362
360363 File targetDir = new File (settingsService .getSettingsFacade ().getProperty ("imi.local_obd_dir" ));
361- File targetFile = new File (targetDir , tfn .getFileName ());
364+ File targetFile = new File (targetDir , tfn .get ( non_Jh ). getFileName ());
362365 int recordCount = 0 ;
363366 boolean header = true ;
364367 try (InputStream is = Files .newInputStream (targetFile .toPath ());
@@ -374,8 +377,8 @@ public void verifyFT191() throws NoSuchAlgorithmException, IOException {
374377 }
375378
376379 String checksum = ChecksumHelper .checksum (targetFile );
377- assertEquals ((int )tfn .getRecordsCount (), recordCount );
378- assertEquals (tfn .getChecksum (), checksum );
380+ assertEquals ((int )tfn .get ( non_Jh ). getRecordsCount (), recordCount );
381+ assertEquals (tfn .get ( non_Jh ). getChecksum (), checksum );
379382 assertTrue ("w1_1.wav" .equals (contents .get (0 )));
380383
381384 }
@@ -395,9 +398,9 @@ public void testChecksumsVaryWithFileContent() throws NoSuchAlgorithmException,
395398
396399 transactionManager .commit (status );
397400
398- TargetFileNotification tfn1 = targetFileService .generateTargetFile ();
399- assertNotNull (tfn1 );
400- getLogger ().debug (tfn1 .toString ());
401+ HashMap < String , TargetFileNotification > tfn1 = targetFileService .generateTargetFile (false );
402+ assertNotNull (tfn1 . get ( non_Jh ) );
403+ getLogger ().debug (tfn1 .get ( non_Jh ). toString ());
401404
402405 // Sleep two seconds so the file names are different
403406 Thread .sleep (2000L );
@@ -413,11 +416,11 @@ public void testChecksumsVaryWithFileContent() throws NoSuchAlgorithmException,
413416
414417 transactionManager .commit (status );
415418
416- TargetFileNotification tfn2 = targetFileService .generateTargetFile ();
417- assertNotNull (tfn2 );
419+ HashMap < String , TargetFileNotification > tfn2 = targetFileService .generateTargetFile (false );
420+ assertNotNull (tfn2 . get ( non_Jh ) );
418421 getLogger ().debug (tfn2 .toString ());
419422
420- assertFalse (tfn1 .getChecksum ().equals (tfn2 .getChecksum ()));
423+ assertFalse (tfn1 .get ( non_Jh ). getChecksum ().equals (tfn2 . get ( non_Jh ) .getChecksum ()));
421424 }
422425
423426}
0 commit comments