Author: anil.saldhana(a)jboss.com
Date: 2008-08-30 06:58:51 -0400 (Sat, 30 Aug 2008)
New Revision: 43
Modified:
trunk/identity-impl/src/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java
Log:
JBID-21: portal reqs
Modified:
trunk/identity-impl/src/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java
===================================================================
---
trunk/identity-impl/src/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java 2008-08-30
10:50:54 UTC (rev 42)
+++
trunk/identity-impl/src/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java 2008-08-30
10:58:51 UTC (rev 43)
@@ -21,20 +21,26 @@
*/
package org.jboss.test.identity.impl.test.portal;
+import junit.framework.TestCase;
+
import org.jboss.identity.api.managers.IdentityManager;
import org.jboss.identity.api.managers.RelationshipManager;
+import org.jboss.identity.api.store.IdentityStore;
+import org.jboss.identity.api.store.IdentityStoreRepository;
+import org.jboss.identity.impl.store.FileBasedIdentityStore;
import org.jboss.identity.model.Identity;
+import org.jboss.identity.model.IdentityType;
+import org.jboss.identity.model.IdentityTypeEnum;
import org.jboss.identity.model.groups.Group;
import org.jboss.identity.model.groups.GroupType;
import org.jboss.identity.model.groups.SimpleGroupType;
import org.jboss.identity.model.relation.HierarchicalRelationshipType;
import org.jboss.identity.model.relation.RelationshipType;
import org.jboss.test.identity.impl.portal.PortalIdentityManager;
+import org.jboss.test.identity.impl.portal.PortalIdentityStoreRepository;
import org.jboss.test.identity.impl.portal.PortalRealm;
import org.jboss.test.identity.impl.portal.PortalRelationshipManager;
-import junit.framework.TestCase;
-
/**
* Portal identity unit test
* @author Anil.Saldhana(a)redhat.com
@@ -42,22 +48,37 @@
*/
public class PortalIdentityUnitTestCase extends TestCase
{
+ private IdentityType IDENTITY = IdentityTypeEnum.IDENTITY;
+ private IdentityType GROUP = IdentityTypeEnum.GROUP;
+
private RelationshipType hierarchy = new HierarchicalRelationshipType();
private RelationshipManager relationshipManager = new PortalRelationshipManager();
private IdentityManager identityManager = new PortalIdentityManager();
private PortalRealm portalRealm ;
+ private PortalIdentityStoreRepository portalRepository;
+ private IdentityStore portalIdentityStore;
protected void setUp() throws Exception
{
portalRealm = (PortalRealm) identityManager.bootstrap("portal");
- portalRealm.createModelRoots();
+ portalRealm.createModelRoots();
+ portalRepository = new PortalIdentityStoreRepository();
+ identityManager.setRepository(portalRealm, portalRepository);
+ portalIdentityStore = new FileBasedIdentityStore();
+ portalRepository.register(IDENTITY, portalIdentityStore);
}
- public void testPortalIdentity() throws Exception
+ public void testPortalIdentityOrganizationType() throws Exception
{
- bootstrapOrganizationType();
+ bootstrapOrganizationType();
+ searchOrganizationType();
}
+ public void testPortalIdentityBusinessType() throws Exception
+ {
+ bootstrapBusinessType();
+ }
+
/**
* Bootstrap the organization type system
*/
@@ -116,4 +137,72 @@
relationshipManager.associate(portalRealm, julien, portalGroup);
relationshipManager.associate(portalRealm, theute, portalGroup);
}
+
+
+ /**
+ * Bootstrap the business type system
+ */
+ private void bootstrapBusinessType() throws Exception
+ {
+ //***************************************************
+ // Create the Group Model
+ //***************************************************
+ GroupType businessGroupType = new SimpleGroupType("Business");
+ Group rolesGroup = identityManager.createGroup(portalRealm, "Roles",
+ businessGroupType);
+
+ Group developersGroup = identityManager.createGroup(portalRealm,
+ "Developers",
+ businessGroupType);
+ Group managementGroup = identityManager.createGroup(portalRealm,
+ "Management",
+ businessGroupType);
+
+ relationshipManager.associate(rolesGroup, developersGroup, hierarchy);
+ relationshipManager.associate(rolesGroup, managementGroup, hierarchy);
+
+ Group portalProjectLeadGroup = identityManager.createGroup(portalRealm,
+ "Portal Project Lead",
+ businessGroupType);
+ Group portalProductLeadGroup = identityManager.createGroup(portalRealm,
+ "Portal Product Lead",
+ businessGroupType);
+
+ relationshipManager.associate(developersGroup, portalProjectLeadGroup, hierarchy);
+ relationshipManager.associate(developersGroup, portalProductLeadGroup, hierarchy);
+
+ Group commonFrameworkManagerGroup = identityManager.createGroup(portalRealm,
+ "Common Framework Manager",
+ businessGroupType);
+
+ relationshipManager.associate(managementGroup,
+ commonFrameworkManagerGroup, hierarchy);
+
+ //***************************************************
+ // Create the Identity Model
+ //***************************************************
+ //Create Identities - julien, theute and associate with portal group
+ Identity julien = identityManager.createIdentity(portalRealm, "julien");
+ Identity theute = identityManager.createIdentity(portalRealm, "theute");
+ //bgeorges for common framework manager group
+ Identity bgeorges = identityManager.createIdentity(portalRealm,
"bgeorges");
+
+ relationshipManager.associate(portalRealm, julien, portalProjectLeadGroup);
+ relationshipManager.associate(portalRealm, theute, portalProductLeadGroup);
+ relationshipManager.associate(portalRealm, bgeorges, commonFrameworkManagerGroup);
+ }
+
+ private void searchOrganizationType() throws Exception
+ {
+ IdentityStoreRepository repo = identityManager.getRepository(portalRealm);
+ assertEquals(repo, portalRepository);
+ //Get the IdentityStore for identities
+ IdentityStore identityStore = repo.getIdentityStore(IdentityTypeEnum.IDENTITY);
+ assertNotNull("IdentityStore is not null", identityStore);
+ assertEquals("Portal Identity Store",portalIdentityStore,
+ repo.getIdentityStore(IDENTITY));
+
+ Identity julien = portalIdentityStore.findIdentity("julien");
+ assertNotNull(julien);
+ }
}
\ No newline at end of file