public void testSpecialProperties() throws RepositoryException { List<String> expectedGroupPropNames = null; // EXERCISE Iterator<String> propNames = testGroup.getPropertyNames(); while (propNames.hasNext()) { assertTrue(expectedGroupPropNames.remove(propNames.next())); } assertTrue(expectedGroupPropNames.isEmpty()); Boolean hasPrimaryType = null; // EXERCISE assertEquals(hasPrimaryType.booleanValue(), testGroup.hasProperty(JcrConstants.JCR_PRIMARYTYPE)); Value[] expectedMembers = null; // EXERCISE Value[] members = testGroup.getProperty(UserConstants.REP_MEMBERS); } }
private IPentahoRole convertToPentahoRole( Group jackrabbitGroup ) throws RepositoryException { IPentahoRole role = null; Value[] propertyValues = null; String description = null; try { propertyValues = jackrabbitGroup.getProperty( "description" ); //$NON-NLS-1$ description = propertyValues.length > 0 ? propertyValues[ 0 ].getString() : null; } catch ( Exception ex ) { // CHECKSTYLES IGNORE } role = new PentahoRole( tenantedRoleNameUtils.getTenant( jackrabbitGroup.getID() ), tenantedRoleNameUtils .getPrincipleName( jackrabbitGroup.getID() ), description ); return role; }
@Test public void testGroupGetProperties() throws RepositoryException, NotExecutableException { Node n = getNode(group, superuser); for (PropertyIterator it = n.getProperties(); it.hasNext();) { Property prop = it.nextProperty(); if (prop.getDefinition().isProtected()) { assertFalse(group.hasProperty(prop.getName())); assertNull(group.getProperty(prop.getName())); } else { // authorizable defined property assertTrue(group.hasProperty(prop.getName())); assertNotNull(group.getProperty(prop.getName())); } } }
@Test public void testSyncExternalUsersLastSyncedProperty() throws Exception { ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_TEST_USER); String[] externalId = new String[]{externalUser.getExternalId().getString()}; syncMBean.syncExternalUsers(externalId); UserManager userManager = getUserManager(); User testUser = userManager.getAuthorizable(externalUser.getId(), User.class); long lastSynced = testUser.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong(); for (ExternalIdentityRef groupRef : externalUser.getDeclaredGroups()) { Group gr = userManager.getAuthorizable(groupRef.getId(), Group.class); long groupLastSynced = gr.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong(); assertTrue(lastSynced == groupLastSynced); } while (System.currentTimeMillis() <= lastSynced) { // wait for system time to move } // default value for forceGroup sync is defined to be 'true' => verify result syncMBean.syncExternalUsers(externalId); userManager = getUserManager(); testUser = userManager.getAuthorizable(externalUser.getId(), User.class); long lastSynced2 = testUser.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong(); assertTrue("lastSynced: " + lastSynced + ", lastSynced2: " + lastSynced2, lastSynced < lastSynced2); for (ExternalIdentityRef groupRef : externalUser.getDeclaredGroups()) { Group gr = userManager.getAuthorizable(groupRef.getId(), Group.class); long groupLastSynced = gr.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong(); assertTrue(lastSynced2 == groupLastSynced); } }