22
33import edu .harvard .iq .dataverse .*;
44import edu .harvard .iq .dataverse .authorization .users .AuthenticatedUser ;
5+ import edu .harvard .iq .dataverse .branding .BrandingUtil ;
56import edu .harvard .iq .dataverse .pidproviders .doi .AbstractDOIProvider ;
6- import edu .harvard .iq .dataverse .settings .SettingsServiceBean ;
77import edu .harvard .iq .dataverse .util .SystemConfig ;
88import jakarta .json .JsonArrayBuilder ;
99import org .junit .jupiter .api .BeforeEach ;
1010import org .junit .jupiter .api .Test ;
1111import org .junit .jupiter .api .extension .ExtendWith ;
1212import org .mockito .InjectMocks ;
1313import org .mockito .Mock ;
14+ import org .mockito .MockedStatic ;
1415import org .mockito .junit .jupiter .MockitoExtension ;
1516
1617import java .util .Collections ;
@@ -34,8 +35,6 @@ public class InAppNotificationsJsonPrinterTest {
3435 @ Mock
3536 private PermissionServiceBean permissionService ;
3637 @ Mock
37- private SettingsServiceBean settingsService ;
38- @ Mock
3938 private SystemConfig systemConfig ;
4039
4140 @ InjectMocks
@@ -401,22 +400,19 @@ public void testAddFieldsByType_statusUpdated_objectDeleted() {
401400 @ Test
402401 public void testAddFieldsByType_createAcc () {
403402 userNotification .setType (UserNotification .Type .CREATEACC );
403+ try (MockedStatic <BrandingUtil > mockedBrandingUtil = mockStatic (BrandingUtil .class )) {
404+ mockedBrandingUtil .when (BrandingUtil ::getInstallationBrandName ).thenReturn ("My Test Brand Name" );
404405
405- Dataverse rootDataverse = mock (Dataverse .class );
406- when (rootDataverse .getName ()).thenReturn ("Root" );
407- when (dataverseService .findRootDataverse ()).thenReturn (rootDataverse );
408- when (settingsService .getValueForKey (SettingsServiceBean .Key .InstallationName )).thenReturn ("InstallationName" );
406+ when (systemConfig .getGuidesBaseUrl (false )).thenReturn ("http://guides.dataverse.org" );
407+ when (systemConfig .getGuidesVersion ()).thenReturn ("v1.0" );
409408
410- when (systemConfig .getGuidesBaseUrl (false )).thenReturn ("http://guides.dataverse.org" );
411- when (systemConfig .getGuidesVersion ()).thenReturn ("v1.0" );
409+ sut .addFieldsByType (notificationJson , authenticatedUser , userNotification );
412410
413- sut .addFieldsByType (notificationJson , authenticatedUser , userNotification );
414-
415- verify (notificationJson ).add (KEY_ROOT_DATAVERSE_NAME , "Root" );
416- verify (notificationJson ).add (KEY_INSTALLATION_NAME , "InstallationName" );
417- verify (notificationJson ).add (KEY_GUIDES_BASE_URL , "http://guides.dataverse.org" );
418- verify (notificationJson ).add (KEY_GUIDES_VERSION , "1.0" );
419- verify (notificationJson ).add (KEY_GUIDES_SECTION_PATH , GUIDES_SECTION_PATH_USER_HTML );
411+ verify (notificationJson ).add (KEY_INSTALLATION_BRAND_NAME , "My Test Brand Name" );
412+ verify (notificationJson ).add (KEY_GUIDES_BASE_URL , "http://guides.dataverse.org" );
413+ verify (notificationJson ).add (KEY_GUIDES_VERSION , "1.0" );
414+ verify (notificationJson ).add (KEY_GUIDES_SECTION_PATH , GUIDES_SECTION_PATH_USER_HTML );
415+ }
420416 }
421417
422418 @ Test
0 commit comments