use of org.pentaho.platform.api.usersettings.pojo.IUserSetting in project pentaho-platform by pentaho.
the class UserSettingServiceTest method testGetGlobalUserSettingUnset.
@Test
public void testGetGlobalUserSettingUnset() throws Exception {
final String settingName = "settings";
final String defaultValue = "defaultValue";
final IUserSetting globalUserSetting = userSettingService.getGlobalUserSetting(settingName, defaultValue);
assertEquals(settingName, globalUserSetting.getSettingName());
assertEquals(defaultValue, globalUserSetting.getSettingValue());
}
use of org.pentaho.platform.api.usersettings.pojo.IUserSetting in project pentaho-platform by pentaho.
the class SolutionImportHandlerTest method testImportUserSettings_NoOverwrite.
@Test
public void testImportUserSettings_NoOverwrite() throws Exception {
UserExport user = new UserExport();
user.setUsername("pentaho");
user.addUserSetting(new ExportManifestUserSetting("theme", "crystal"));
user.addUserSetting(new ExportManifestUserSetting("language", "en_US"));
IAnyUserSettingService userSettingService = Mockito.mock(IAnyUserSettingService.class);
PentahoSystem.registerObject(userSettingService);
importHandler.setOverwriteFile(false);
IUserSetting existingSetting = Mockito.mock(IUserSetting.class);
Mockito.when(userSettingService.getUserSetting("pentaho", "theme", null)).thenReturn(existingSetting);
Mockito.when(userSettingService.getUserSetting("pentaho", "language", null)).thenReturn(null);
importHandler.importUserSettings(user);
Mockito.verify(userSettingService, Mockito.never()).setUserSetting("pentaho", "theme", "crystal");
Mockito.verify(userSettingService).setUserSetting("pentaho", "language", "en_US");
Mockito.verify(userSettingService).getUserSetting("pentaho", "theme", null);
Mockito.verify(userSettingService).getUserSetting("pentaho", "language", null);
}
use of org.pentaho.platform.api.usersettings.pojo.IUserSetting in project pentaho-platform by pentaho.
the class SolutionImportHandlerTest method testImportGlobalUserSetting_noOverwrite.
@Test
public void testImportGlobalUserSetting_noOverwrite() throws Exception {
importHandler.setOverwriteFile(false);
List<ExportManifestUserSetting> settings = new ArrayList<>();
settings.add(new ExportManifestUserSetting("language", "en_US"));
settings.add(new ExportManifestUserSetting("showHiddenFiles", "false"));
IUserSettingService userSettingService = Mockito.mock(IUserSettingService.class);
PentahoSystem.registerObject(userSettingService);
IUserSetting setting = Mockito.mock(IUserSetting.class);
Mockito.when(userSettingService.getGlobalUserSetting("language", null)).thenReturn(null);
Mockito.when(userSettingService.getGlobalUserSetting("showHiddenFiles", null)).thenReturn(setting);
importHandler.importGlobalUserSettings(settings);
Mockito.verify(userSettingService).setGlobalUserSetting("language", "en_US");
Mockito.verify(userSettingService, Mockito.never()).setGlobalUserSetting(Mockito.eq("showHiddenFiles"), Mockito.anyString());
Mockito.verify(userSettingService).getGlobalUserSetting("language", null);
Mockito.verify(userSettingService).getGlobalUserSetting("showHiddenFiles", null);
}
use of org.pentaho.platform.api.usersettings.pojo.IUserSetting in project pentaho-platform by pentaho.
the class UserSettingsResourceTest method testGetUserSettings.
@Test
public void testGetUserSettings() throws Exception {
IUserSetting userSetting = mock(IUserSetting.class);
when(userSetting.getSettingName()).thenReturn(USER_SETTING_NAME);
when(userSetting.getSettingValue()).thenReturn(USER_SETTING_VALUE);
List<IUserSetting> userSettings = new ArrayList<>();
userSettings.add(userSetting);
when(userSettingService.getUserSettings()).thenReturn(userSettings);
when(userSettingsResource.getUserSettings()).thenCallRealMethod();
ArrayList<Setting> response = userSettingsResource.getUserSettings();
assertNotNull(response);
assertTrue(!response.isEmpty());
assertTrue(response.get(0).getName().equals(USER_SETTING_NAME));
assertTrue(response.get(0).getValue().equals(USER_SETTING_VALUE));
}
use of org.pentaho.platform.api.usersettings.pojo.IUserSetting in project pentaho-platform by pentaho.
the class UserSettingsResource method getUserSetting.
/**
* Retrieve a particular user setting for the current user
*
* @param setting (Name of the setting)
*
* @return value of the setting for the user
*/
@GET
@Path("{setting : .+}")
@Facet(name = "Unsupported")
public Response getUserSetting(@PathParam("setting") String setting) {
IUserSettingService settingsService = getUserSettingService();
IUserSetting userSetting = settingsService.getUserSetting(setting, null);
return Response.ok(userSetting != null ? userSetting.getSettingValue() : null).build();
}
Aggregations