PUMAConfig extends Config { public Map<String, String> getUserMapping(XWikiContext context) { return getMapParam("userMapping", ',', null, context); } PUMAConfig(); String getUserUidField(XWikiContext context); Map<String, String> getUserMapping(XWikiContext context); Map<String, Collection<String>> getGroupMapping(XWikiContext context); XWikiAuthService getFallbackAuthenticator(XWikiContext context);  }
@Test public void testGetUserMappingsWithoutProperty() throws Exception { this.mockery.checking(new Expectations() {{ allowing(xwikiMock).getXWikiPreference("puma_userMapping", getContext()); will(returnValue(null)); allowing(xwikiMock).Param("xwiki.authentication.puma.userMapping"); will(returnValue(null)); }}); Map<String, String> userMapping = this.config.getUserMapping(getContext()); Assert.assertNull(userMapping); }
@Test public void testGetUserMappingsWithEmptyProperty() throws Exception { this.mockery.checking(new Expectations() {{ allowing(xwikiMock).getXWikiPreference("puma_userMapping", getContext()); will(returnValue("")); allowing(xwikiMock).Param("xwiki.authentication.puma.userMapping"); will(returnValue("")); }}); Map<String, String> userMapping = this.config.getUserMapping(getContext()); Assert.assertTrue(userMapping.isEmpty()); }
@Test public void testGetUserMappingsWithOneCouple() throws Exception { this.mockery.checking(new Expectations() {{ allowing(xwikiMock).getXWikiPreference("puma_userMapping", getContext()); will(returnValue("xwikifield=pumagfield")); }}); Map<String, String> userMapping = this.config.getUserMapping(getContext()); Assert.assertEquals("pumagfield", userMapping.get("xwikifield")); }
@Test public void testGetUserMappingsWithTwoCouples() throws Exception { this.mockery.checking(new Expectations() {{ allowing(xwikiMock).getXWikiPreference("puma_userMapping", getContext()); will(returnValue("xwikifield=pumagfield,xwikifield2=pumagfield2")); }}); Map<String, String> userMapping = this.config.getUserMapping(getContext()); Assert.assertEquals("pumagfield", userMapping.get("xwikifield")); Assert.assertEquals("pumagfield2", userMapping.get("xwikifield2")); }