List of usage examples for java.util Locale CANADA_FRENCH
Locale CANADA_FRENCH
To view the source code for java.util Locale CANADA_FRENCH.
Click Source Link
From source file:fr.paris.lutece.portal.web.user.AdminUserJspBeanTest.java
public void testDoModifyDefaultUserParameterValuesInvalidToken() throws AccessDeniedException, UserNotSignedException { String origDefaultStatus = DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_STATUS); String origDefaultLevel = DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LEVEL); String origDefaultNotification = DefaultUserParameterHome .findByKey(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION); String origDefaultLanguage = DefaultUserParameterHome .findByKey(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE); AdminUserJspBean bean = new AdminUserJspBean(); MockHttpServletRequest request = new MockHttpServletRequest(); AdminUser user = getUserToModify();/*from w w w. j a v a2 s . c om*/ AdminAuthenticationService.getInstance().registerUser(request, user); bean.init(request, "CORE_USERS_MANAGEMENT"); request.setParameter("status", Integer.toString(AdminUser.ANONYMIZED_CODE)); request.setParameter("user_level", "10"); request.setParameter("notify_user", "false"); request.setParameter("language", Locale.CANADA_FRENCH.toString()); request.addParameter(SecurityTokenService.PARAMETER_TOKEN, SecurityTokenService.getInstance().getToken(request, "ManageAdvancedParameters.jsp") + "b"); try { bean.doModifyDefaultUserParameterValues(request); fail("Should have thrown"); } catch (AccessDeniedException e) { assertEquals(origDefaultStatus, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_STATUS)); assertEquals(origDefaultLevel, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LEVEL)); assertEquals(origDefaultNotification, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION)); assertEquals(origDefaultLanguage, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE)); } finally { DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_STATUS, origDefaultStatus); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_LEVEL, origDefaultLevel); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION, origDefaultNotification); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE, origDefaultLanguage); disposeOfUser(user); } }
From source file:fr.paris.lutece.portal.web.user.AdminUserJspBeanTest.java
public void testDoModifyDefaultUserParameterValuesNoToken() throws AccessDeniedException, UserNotSignedException { String origDefaultStatus = DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_STATUS); String origDefaultLevel = DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LEVEL); String origDefaultNotification = DefaultUserParameterHome .findByKey(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION); String origDefaultLanguage = DefaultUserParameterHome .findByKey(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE); AdminUserJspBean bean = new AdminUserJspBean(); MockHttpServletRequest request = new MockHttpServletRequest(); AdminUser user = getUserToModify();// w ww. ja v a 2s.c o m AdminAuthenticationService.getInstance().registerUser(request, user); bean.init(request, "CORE_USERS_MANAGEMENT"); request.setParameter("status", Integer.toString(AdminUser.ANONYMIZED_CODE)); request.setParameter("user_level", "10"); request.setParameter("notify_user", "false"); request.setParameter("language", Locale.CANADA_FRENCH.toString()); try { bean.doModifyDefaultUserParameterValues(request); fail("Should have thrown"); } catch (AccessDeniedException e) { assertEquals(origDefaultStatus, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_STATUS)); assertEquals(origDefaultLevel, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LEVEL)); assertEquals(origDefaultNotification, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION)); assertEquals(origDefaultLanguage, DefaultUserParameterHome.findByKey(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE)); } finally { DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_STATUS, origDefaultStatus); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_LEVEL, origDefaultLevel); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_NOTIFICATION, origDefaultNotification); DefaultUserParameterHome.update(AdminUserService.DSKEY_DEFAULT_USER_LANGUAGE, origDefaultLanguage); disposeOfUser(user); } }
From source file:org.openmrs.api.ConceptServiceTest.java
/** * @verifies get drugs linked to concepts with names that match the phrase and locale * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) *//* w w w. j a v a 2 s . c o m*/ @Test public void getDrugs_shouldGetDrugsLinkedToConceptsWithNamesThatMatchThePhraseAndLocale() throws Exception { executeDataSet("org/openmrs/api/include/ConceptServiceTest-drugSearch.xml"); final String searchPhrase = "some"; List<Drug> drugs = conceptService.getDrugs(searchPhrase, Locale.FRENCH, true, false); assertEquals(0, drugs.size()); drugs = conceptService.getDrugs(searchPhrase, Locale.CANADA_FRENCH, true, false); assertEquals(1, drugs.size()); assertEquals(3, drugs.get(0).getDrugId().intValue()); }
From source file:org.openmrs.api.ConceptServiceTest.java
/** * @verifies get drugs linked to concepts with names that match the phrase and related locales * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */// w w w .j a v a2s. c o m @Test public void getDrugs_shouldGetDrugsLinkedToConceptsWithNamesThatMatchThePhraseAndRelatedLocales() throws Exception { executeDataSet("org/openmrs/api/include/ConceptServiceTest-drugSearch.xml"); final String searchPhrase = "another"; //Should look only in the exact locale if exactLocale is set to true List<Drug> drugs = conceptService.getDrugs(searchPhrase, Locale.CANADA_FRENCH, true, false); assertThat(drugs, is(empty())); //Should look in broader locale if exactLocale is set to false drugs = conceptService.getDrugs(searchPhrase, Locale.CANADA_FRENCH, false, false); assertThat(drugs, contains(hasId(3))); }