@@ -622,28 +622,12 @@ public void mapReportImagesToTemplateShouldReturnMatchingImages()
622622
623623 @ Test
624624 public void getLocaleBundleShouldReturnEmptyMapForInvalidResourceBundleNames () throws Exception {
625- assertTrue (jasperTemplateService .getLocaleBundleParameters (null , "en" ).isEmpty ());
626-
627- JasperReport parentReport = mock (JasperReport .class );
628-
629- when (parentReport .getResourceBundle ()).thenReturn (null );
630- assertTrue (jasperTemplateService .getLocaleBundleParameters (parentReport , "en" ).isEmpty ());
631-
632- // 3. Covers: resourceBundleName.isEmpty()
633- when (parentReport .getResourceBundle ()).thenReturn ("" );
634- assertTrue (jasperTemplateService .getLocaleBundleParameters (parentReport , "en" ).isEmpty ());
635-
636- // 4. Covers: resourceBundleName.trim().isEmpty()
637- when (parentReport .getResourceBundle ()).thenReturn (" " );
638- assertTrue (jasperTemplateService .getLocaleBundleParameters (parentReport , "en" ).isEmpty ());
625+ assertTrue (jasperTemplateService .getLocaleBundleParameters (null ).isEmpty ());
639626 }
640627
641628 @ Test
642629 public void getLocaleBundleShouldReturnEmptyMapIfResourceBundleDirectoryDoesNotExist ()
643630 throws Exception {
644- JasperReport parentReport = mock (JasperReport .class );
645- when (parentReport .getResourceBundle ()).thenReturn (RESOURCE_BUNDLE_NAME );
646-
647631 File mockDir = mock (File .class );
648632 whenNew (File .class ).withArguments (RESOURCE_BUNDLE_PATH ).thenReturn (mockDir );
649633
@@ -653,19 +637,16 @@ public void getLocaleBundleShouldReturnEmptyMapIfResourceBundleDirectoryDoesNotE
653637 when (ResourceBundle .getBundle (eq (RESOURCE_BUNDLE_NAME ), any (Locale .class )))
654638 .thenThrow (new MissingResourceException ("Test" , RESOURCE_BUNDLE_NAME , "key" ));
655639
656- assertTrue (jasperTemplateService .getLocaleBundleParameters (parentReport , "en" ).isEmpty ());
640+ assertTrue (jasperTemplateService .getLocaleBundleParameters ("en" ).isEmpty ());
657641
658642 when (mockDir .exists ()).thenReturn (true );
659643 when (mockDir .isDirectory ()).thenReturn (false );
660- assertTrue (jasperTemplateService .getLocaleBundleParameters (parentReport , "en" ).isEmpty ());
644+ assertTrue (jasperTemplateService .getLocaleBundleParameters ("en" ).isEmpty ());
661645 }
662646
663647 @ Test
664648 public void getLocaleBundleShouldFallbackToInternalBundleWhenConfigDirectoryNotFound ()
665649 throws Exception {
666- JasperReport parentReport = mock (JasperReport .class );
667- when (parentReport .getResourceBundle ()).thenReturn (RESOURCE_BUNDLE_NAME );
668-
669650 File mockDir = mock (File .class );
670651 whenNew (File .class ).withArguments (RESOURCE_BUNDLE_PATH ).thenReturn (mockDir );
671652 when (mockDir .exists ()).thenReturn (false );
@@ -677,7 +658,7 @@ public void getLocaleBundleShouldFallbackToInternalBundleWhenConfigDirectoryNotF
677658 .thenReturn (fallbackBundle );
678659
679660 Map <String , Object > result = jasperTemplateService
680- .getLocaleBundleParameters (parentReport , "en" );
661+ .getLocaleBundleParameters ("en" );
681662
682663 assertEquals (2 , result .size ());
683664 assertEquals (fallbackBundle , result .get (JRParameter .REPORT_RESOURCE_BUNDLE ));
@@ -687,9 +668,6 @@ public void getLocaleBundleShouldFallbackToInternalBundleWhenConfigDirectoryNotF
687668 @ Test
688669 public void getLocaleBundleShouldFallbackToInternalBundleWhenConfigBundleNotFound ()
689670 throws Exception {
690- JasperReport parentReport = mock (JasperReport .class );
691- when (parentReport .getResourceBundle ()).thenReturn (RESOURCE_BUNDLE_NAME );
692-
693671 File mockDir = mock (File .class );
694672 whenNew (File .class ).withArguments (RESOURCE_BUNDLE_PATH ).thenReturn (mockDir );
695673 when (mockDir .exists ()).thenReturn (true );
@@ -709,7 +687,7 @@ public void getLocaleBundleShouldFallbackToInternalBundleWhenConfigBundleNotFoun
709687 .thenReturn (fallbackBundle );
710688
711689 Map <String , Object > result = jasperTemplateService
712- .getLocaleBundleParameters (parentReport , "fr" );
690+ .getLocaleBundleParameters ("fr" );
713691
714692 assertEquals (2 , result .size ());
715693 assertEquals (fallbackBundle , result .get (JRParameter .REPORT_RESOURCE_BUNDLE ));
@@ -720,9 +698,6 @@ public void getLocaleBundleShouldFallbackToInternalBundleWhenConfigBundleNotFoun
720698 @ Test
721699 public void getLocaleBundleShouldReturnEmptyMapIfTranslationBundleIsMissingFromDisk ()
722700 throws Exception {
723- JasperReport parentReport = mock (JasperReport .class );
724- when (parentReport .getResourceBundle ()).thenReturn (RESOURCE_BUNDLE_NAME );
725-
726701 File mockDir = mock (File .class );
727702 whenNew (File .class ).withArguments (RESOURCE_BUNDLE_PATH ).thenReturn (mockDir );
728703 when (mockDir .exists ()).thenReturn (true );
@@ -734,14 +709,11 @@ public void getLocaleBundleShouldReturnEmptyMapIfTranslationBundleIsMissingFromD
734709 when (ResourceBundle .getBundle (anyString (), any (Locale .class ), any (URLClassLoader .class )))
735710 .thenThrow (new MissingResourceException ("Missing resource exception occurred" ,
736711 "ResourceBundle" , "key" ));
737- assertTrue (jasperTemplateService .getLocaleBundleParameters (parentReport , "en" ).isEmpty ());
712+ assertTrue (jasperTemplateService .getLocaleBundleParameters ("en" ).isEmpty ());
738713 }
739714
740715 @ Test
741716 public void getLocaleBundleShouldReturnMapWithBundleAndLocale () throws Exception {
742- JasperReport parentReport = mock (JasperReport .class );
743- when (parentReport .getResourceBundle ()).thenReturn (RESOURCE_BUNDLE_NAME );
744-
745717 // Mock the Config Directory
746718 File mockDir = mock (File .class );
747719 whenNew (File .class ).withArguments (RESOURCE_BUNDLE_PATH ).thenReturn (mockDir );
@@ -755,7 +727,7 @@ public void getLocaleBundleShouldReturnMapWithBundleAndLocale() throws Exception
755727 any (URLClassLoader .class ))).thenReturn (mockBundle );
756728
757729 Map <String , Object > result = jasperTemplateService
758- .getLocaleBundleParameters (parentReport , "fr" );
730+ .getLocaleBundleParameters ("fr" );
759731
760732 assertEquals (2 , result .size ());
761733 assertEquals (mockBundle , result .get (JRParameter .REPORT_RESOURCE_BUNDLE ));
@@ -765,9 +737,6 @@ public void getLocaleBundleShouldReturnMapWithBundleAndLocale() throws Exception
765737
766738 @ Test
767739 public void getLocaleBundleShouldFallbackToEnglishForInvalidLocale () throws Exception {
768- JasperReport parentReport = mock (JasperReport .class );
769- when (parentReport .getResourceBundle ()).thenReturn (RESOURCE_BUNDLE_NAME );
770-
771740 File mockDir = mock (File .class );
772741 whenNew (File .class ).withArguments (RESOURCE_BUNDLE_PATH ).thenReturn (mockDir );
773742 when (mockDir .exists ()).thenReturn (true );
@@ -780,7 +749,7 @@ public void getLocaleBundleShouldFallbackToEnglishForInvalidLocale() throws Exce
780749 any (URLClassLoader .class ))).thenReturn (mockBundle );
781750
782751 Map <String , Object > result = jasperTemplateService
783- .getLocaleBundleParameters (parentReport , "invalid_locale" );
752+ .getLocaleBundleParameters ("invalid_locale" );
784753
785754 assertEquals (Locale .ENGLISH , result .get (JRParameter .REPORT_LOCALE ));
786755 }
0 commit comments