use of org.xwiki.wiki.user.UserScope in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method getUserScopeWithError.
@Test
public void getUserScopeWithError() throws Exception {
// Mocks
Exception expectedException = new WikiUserManagerException("Error in getUserScope");
when(wikiUserManager.getUserScope("test")).thenThrow(expectedException);
// Test
UserScope result = mocker.getComponentUnderTest().getUserScope("test");
// Asserts
assertNull(result);
assertEquals(expectedException, mocker.getComponentUnderTest().getLastError());
}
use of org.xwiki.wiki.user.UserScope in project xwiki-platform by xwiki.
the class DefaultWikiUserConfigurationHelper method getConfiguration.
@Override
public WikiUserConfiguration getConfiguration(String wikiId) throws WikiUserManagerException {
// Create the configuration object to return
WikiUserConfiguration configuration = new WikiUserConfiguration();
// Get the document
XWikiDocument document = getDocument(wikiId);
// Get the XWiki object
BaseObject object = document.getXObject(WikiUserClassDocumentInitializer.CONFIGURATION_CLASS);
if (object != null) {
// Get the user scope
String scopeValue = object.getStringValue(WikiUserClassDocumentInitializer.FIELD_USERSCOPE);
UserScope userScope;
try {
userScope = UserScope.valueOf(scopeValue.toUpperCase());
} catch (Exception e) {
// Default value
userScope = UserScope.LOCAL_AND_GLOBAL;
}
configuration.setUserScope(userScope);
// Get the membershipType value
String membershipTypeValue = object.getStringValue(WikiUserClassDocumentInitializer.FIELD_MEMBERSHIPTYPE);
MembershipType membershipType;
try {
membershipType = MembershipType.valueOf(membershipTypeValue.toUpperCase());
} catch (Exception e) {
// Default value
membershipType = MembershipType.INVITE;
}
configuration.setMembershipType(membershipType);
}
return configuration;
}
use of org.xwiki.wiki.user.UserScope in project xwiki-platform by xwiki.
the class WikiUserManagerScriptServiceTest method getUserScope.
@Test
public void getUserScope() throws Exception {
when(wikiUserManager.getUserScope("subwiki")).thenReturn(UserScope.GLOBAL_ONLY);
UserScope result = mocker.getComponentUnderTest().getUserScope();
assertEquals(UserScope.GLOBAL_ONLY, result);
}
Aggregations