@@ -509,12 +509,16 @@ public void testfilePathGenerator(){
509
509
throw new RuntimeException (e );
510
510
}
511
511
512
- assertEquals (task .filePathGenerator ("mm22" , publishDate , "v123" ), "ts-datasets/mm22/v123" );
513
- assertEquals (task .filePathGenerator ("a01jul2025" , null , "v123" ), "ts-datasets/other/" + today );
514
- assertEquals (task .filePathGenerator ("x09jul2025" , publishDate , "v123" ), "ts-datasets/other/2024-07-18" );
515
- assertEquals (task .filePathGenerator ("dataset1" , publishDate , "v123" ), "ts-datasets/other/2024-07-18" );
516
- assertEquals (task .filePathGenerator ("rtisa" , publishDate , "v123" ), "ts-datasets/other/2024-07-18" );
517
- assertEquals (task .filePathGenerator ("cla01" , publishDate , "v123" ), "ts-datasets/other/2024-07-18" );
512
+ assertEquals (task .filePathGenerator ("mm22" , publishDate , "v123" , "" ), "ts-datasets/mm22/v123" );
513
+ assertEquals (task .filePathGenerator ("a01jul2025" , null , "v123" , "" ), "ts-datasets/other/" + today );
514
+ assertEquals (task .filePathGenerator ("x09jul2025" , publishDate , "v123" , "" ), "ts-datasets/other/2024-07-18" );
515
+ assertEquals (task .filePathGenerator ("dataset1" , publishDate , "v123" , "" ), "ts-datasets/other/2024-07-18" );
516
+ assertEquals (task .filePathGenerator ("rtisa" , publishDate , "v123" , "" ), "ts-datasets/other/2024-07-18" );
517
+ assertEquals (task .filePathGenerator ("cla01" , publishDate , "v123" , "" ), "ts-datasets/other/2024-07-18" );
518
+
519
+ assertEquals (task .filePathGenerator ("mm22" , publishDate , "v123" , "v321" ), "ts-datasets/mm22/v322" );
520
+ assertEquals (task .filePathGenerator ("drsi" , publishDate , "v456" , "v654" ), "ts-datasets/drsi/v655" );
521
+ assertEquals (task .filePathGenerator ("pn2" , publishDate , "current" , "" ), "ts-datasets/pn2/current" );
518
522
}
519
523
520
524
@ Test
@@ -567,4 +571,57 @@ public void testIncrementDatasetVersionByOne_HappyPath() {
567
571
assertEquals (expected , actual );
568
572
}
569
573
574
+ @ Test
575
+ public void testfindCorrectDatasetVersion_nullInput () {
576
+ IllegalArgumentException ex = assertThrows (IllegalArgumentException .class , () -> task .findCorrectDatasetVersion (null ));
577
+ assertThat (ex .getMessage (), equalTo ("input array can't be null" ));
578
+ }
579
+
580
+ @ Test
581
+ public void testfindCorrectDatasetVersion_correctInput () {
582
+ List <String > listOfUris = new ArrayList <>();
583
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/augusttoseptember2024/diop.csv" );
584
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/augusttoseptember2024/diop.xlsx" );
585
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/augusttoseptember2024/previous/v1/data.json" );
586
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/augusttoseptember2024/previous/v1/diop.csv" );
587
+
588
+ String expected = "v1" ;
589
+ String actual = task .findCorrectDatasetVersion (listOfUris );
590
+ assertEquals (expected , actual );
591
+ }
592
+
593
+ @ Test
594
+ public void testfindCorrectDatasetVersion_anotherCorrectInput_previousVersionExist () {
595
+ List <String > listOfUris = new ArrayList <>();
596
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/current/diop.csv" );
597
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/current/diop.xlsx" );
598
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/current/previous/v123/data.json" );
599
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/current/previous/v123/diop.csv" );
600
+
601
+ String expected = "v123" ;
602
+ String actual = task .findCorrectDatasetVersion (listOfUris );
603
+ assertEquals (expected , actual );
604
+ }
605
+
606
+ @ Test
607
+ public void testfindCorrectDatasetVersion_anotherCorrectInput_previousVersionDoesNotExist () {
608
+ List <String > listOfUris = new ArrayList <>();
609
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/current/diop.csv" );
610
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/current/diop.xlsx" );
611
+ listOfUris .add ("/economy/grossdomesticproductgdp/datasets/mycollectionpagedltest1/september2024/diop.xlsx" );
612
+
613
+ String expected = "" ;
614
+ String actual = task .findCorrectDatasetVersion (listOfUris );
615
+ assertEquals (expected , actual );
616
+ }
617
+
618
+ @ Test
619
+ public void testfindCorrectDatasetVersion_emptyList () {
620
+ List <String > listOfUris = new ArrayList <>();
621
+
622
+ String expected = "" ;
623
+ String actual = task .findCorrectDatasetVersion (listOfUris );
624
+ assertEquals (expected , actual );
625
+ }
626
+
570
627
}
0 commit comments