@Test public void testGetUserCharset_CharsetIsSupported() { String supportedCharset = "UTF-8"; PropertyImpl propertyWithSupportedCharset = mock(PropertyImpl.class); when(propertyWithSupportedCharset.getStringValue()).thenReturn(supportedCharset); when(propertyManagerMock.findProperty(identityMock, null, null, null, UserServiceImpl.CHARSET)).thenReturn(propertyWithSupportedCharset); String charsetValue = userServiceImpl.getUserCharset(identityMock); assertEquals("Wrong charset when charset is supported, should return this value", charsetValue, supportedCharset); }
@Override public String getUserCharset(final Identity identity) { String charset; charset = WebappHelper.getDefaultCharset(); final PropertyImpl p = propertyManager.findProperty(identity, null, null, null, CHARSET); if (p != null) { charset = p.getStringValue(); if (!Charset.isSupported(charset)) { charset = WebappHelper.getDefaultCharset(); } } else { charset = WebappHelper.getDefaultCharset(); } return charset; }
UserServiceImpl implements UserService { @Override public String getUserCharset(final Identity identity) { String charset; charset = WebappHelper.getDefaultCharset(); final PropertyImpl p = propertyManager.findProperty(identity, null, null, null, CHARSET); if (p != null) { charset = p.getStringValue(); if (!Charset.isSupported(charset)) { charset = WebappHelper.getDefaultCharset(); } } else { charset = WebappHelper.getDefaultCharset(); } return charset; } }
UserServiceImpl implements UserService { @Override public String getUserCharset(final Identity identity) { String charset; charset = WebappHelper.getDefaultCharset(); final PropertyImpl p = propertyManager.findProperty(identity, null, null, null, CHARSET); if (p != null) { charset = p.getStringValue(); if (!Charset.isSupported(charset)) { charset = WebappHelper.getDefaultCharset(); } } else { charset = WebappHelper.getDefaultCharset(); } return charset; } UserServiceImpl(); }
UserServiceImpl implements UserService { @Override public String getUserCharset(final Identity identity) { String charset; charset = WebappHelper.getDefaultCharset(); final PropertyImpl p = propertyManager.findProperty(identity, null, null, null, CHARSET); if (p != null) { charset = p.getStringValue(); if (!Charset.isSupported(charset)) { charset = WebappHelper.getDefaultCharset(); } } else { charset = WebappHelper.getDefaultCharset(); } return charset; } UserServiceImpl(); @Override User createUser(final String firstName, final String lastName, final String eMail); @Override User createAndPersistUser(final String firstName, final String lastName, final String email); @Override Identity findIdentityByEmail(final String email); @Override User findUserByEmail(final String email); @Override boolean userExist(final String email); @Override User loadUserByKey(final Long key); @Override void updateUser(final User usr); @Override void saveUser(final User user); @Override boolean updateUserFromIdentity(final Identity identity); @Override void setUserCharset(final Identity identity, final String charset); @Override String getUserCharset(final Identity identity); @Override void deleteUserProperties(User user); @Override boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName); @Override boolean syntaxCheckOlatLogin(final String login); @Override UserPropertiesConfig getUserPropertiesConfig(); @Override List<UserPropertyHandler> getUserPropertyHandlersFor(final String usageIdentifyer, final boolean isAdministrativeUser); @Override List<UserPropertyHandler> getAllUserPropertyHandlers(); @Override boolean isMandatoryUserProperty(final String usageIdentifyer, final UserPropertyHandler propertyHandler); @Override boolean isUserViewReadOnly(final String usageIdentifyer, final UserPropertyHandler propertyHandler); @Override void setUserNameAndPasswordSyntaxChecker(final UserNameAndPasswordSyntaxChecker userNameAndPasswordSyntaxChecker); @Override void setUserPropertiesConfig(final UserPropertiesConfig userPropertiesConfig); @Override String getUserProperty(User user, String propertyName, Locale locale); @Override String getUserProperty(User user, String propertyName); @Override String getFirstAndLastname(User user); @Override String getInstitutionalIdentifier(User user); @Override void setUserProperty(final User user, final String propertyName, final String propertyValue); @Override String getPropertyOrIdentityEnvAttribute(final User user, final String propertyName, final Locale locale); }
UserServiceImpl implements UserService { @Override public String getUserCharset(final Identity identity) { String charset; charset = WebappHelper.getDefaultCharset(); final PropertyImpl p = propertyManager.findProperty(identity, null, null, null, CHARSET); if (p != null) { charset = p.getStringValue(); if (!Charset.isSupported(charset)) { charset = WebappHelper.getDefaultCharset(); } } else { charset = WebappHelper.getDefaultCharset(); } return charset; } UserServiceImpl(); @Override User createUser(final String firstName, final String lastName, final String eMail); @Override User createAndPersistUser(final String firstName, final String lastName, final String email); @Override Identity findIdentityByEmail(final String email); @Override User findUserByEmail(final String email); @Override boolean userExist(final String email); @Override User loadUserByKey(final Long key); @Override void updateUser(final User usr); @Override void saveUser(final User user); @Override boolean updateUserFromIdentity(final Identity identity); @Override void setUserCharset(final Identity identity, final String charset); @Override String getUserCharset(final Identity identity); @Override void deleteUserProperties(User user); @Override boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName); @Override boolean syntaxCheckOlatLogin(final String login); @Override UserPropertiesConfig getUserPropertiesConfig(); @Override List<UserPropertyHandler> getUserPropertyHandlersFor(final String usageIdentifyer, final boolean isAdministrativeUser); @Override List<UserPropertyHandler> getAllUserPropertyHandlers(); @Override boolean isMandatoryUserProperty(final String usageIdentifyer, final UserPropertyHandler propertyHandler); @Override boolean isUserViewReadOnly(final String usageIdentifyer, final UserPropertyHandler propertyHandler); @Override void setUserNameAndPasswordSyntaxChecker(final UserNameAndPasswordSyntaxChecker userNameAndPasswordSyntaxChecker); @Override void setUserPropertiesConfig(final UserPropertiesConfig userPropertiesConfig); @Override String getUserProperty(User user, String propertyName, Locale locale); @Override String getUserProperty(User user, String propertyName); @Override String getFirstAndLastname(User user); @Override String getInstitutionalIdentifier(User user); @Override void setUserProperty(final User user, final String propertyName, final String propertyValue); @Override String getPropertyOrIdentityEnvAttribute(final User user, final String propertyName, final Locale locale);  }