Search in sources :

Example 31 with OrgType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.

the class TestOrgStruct method test410AddJackWithOrgUnit.

/**
     * Add new user Jack with an assignments as an manager and also a member of ministry of offense.
     * (copied from test400)
     */
@Test
public void test410AddJackWithOrgUnit() throws Exception {
    final String TEST_NAME = "test400AddJackWithOrgUnit";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestOrgStruct.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    OrgType minOffense = getObject(OrgType.class, ORG_MINISTRY_OF_OFFENSE_OID).asObjectable();
    PrismObject<UserType> userJack = prismContext.parseObject(USER_JACK_FILE);
    userJack.asObjectable().getOrganizationalUnit().add(minOffense.getName());
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userJack.createAddDelta());
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    userJack = getUser(USER_JACK_OID);
    display("User jack after", userJack);
    assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID);
    assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID);
    assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
    assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
    // Postcondition
    assertMonkeyIslandOrgSanity();
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 32 with OrgType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.

the class TestMachineIntelligence method test010importActiveUserRUR.

/**
	 * 
	 * WHEN: Create account in the HR, import this acount to the midPoint
	 * THEN: User is imported to midPoint, new Organization is created,
	 * 		user is assigned to the organization, assignment is active/inactive
	 * 		according to the setting in the resource
	 */
@Test
public void test010importActiveUserRUR() throws Exception {
    final String TEST_NAME = "test010importActiveUserRUR";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    PrismObject<ShadowType> shadow = addObject(SHADOW_RUR_FILE, task, result);
    assertEquals(SHADOW_RUR_OID, shadow.getOid());
    //AND 
    modelService.importFromResource(SHADOW_RUR_OID, task, result);
    //THEN
    //assert created organization
    SearchResultList<PrismObject<OrgType>> orgs = modelService.searchObjects(OrgType.class, QueryBuilder.queryFor(OrgType.class, prismContext).item(OrgType.F_NAME).eq("Universe").matching(PolyStringNormMatchingRule.NAME).build(), null, task, result);
    assertEquals("Found unexpected number of organizations, expected 1, found " + orgs.size(), 1, orgs.size());
    //assert created owner of shadow
    PrismObject<UserType> userRur = assertShadowOwner(SHADOW_RUR_OID, "R.U.R", "Rossum", "Universal Robots", "Rossum's Universal Robots", task, result);
    //assert assignment of org
    assertAssignedOrg(userRur, orgs.iterator().next());
    //assert assignment of or in more depth
    assertAssignment(userRur.asObjectable(), ActivationStatusType.ENABLED, null);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 33 with OrgType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.

the class AbstractLdapHierarchyTest method assertGroupMembers.

protected void assertGroupMembers(PrismObject<OrgType> org, String... members) throws Exception {
    String groupOid = getLinkRefOid(org, RESOURCE_OPENDJ_OID, ShadowKindType.ENTITLEMENT, "org-group");
    PrismObject<ShadowType> groupShadow = getShadowModel(groupOid);
    assertAttribute(resourceOpenDj, groupShadow.asObjectable(), new QName(MidPointConstants.NS_RI, "uniqueMember"), members);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 34 with OrgType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.

the class TestEntertainment method test001AddParentOrg.

@Test
public void test001AddParentOrg() throws Exception {
    final String TEST_NAME = "test001AddParentOrg";
    displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    addObject(ORG_GAMES_TOP_FILE);
    // THEN
    PrismObject<OrgType> orgGames = modelService.getObject(OrgType.class, ORG_GAMES_TOP_OID, null, task, result);
    assertNotNull("No top org for games found", orgGames);
    result.computeStatus();
    assertSuccess("Error while getting top games org", result);
    OrgType orgGamesType = orgGames.asObjectable();
    assertLinks(orgGames, 2);
    List<ObjectReferenceType> linkRefs = orgGamesType.getLinkRef();
    // SHADOW 1
    ShadowType shadowType1 = getAndAssertShadowSuccess(linkRefs.get(0), task, result);
    // SHADOW 2
    ShadowType shadowType2 = getAndAssertShadowSuccess(linkRefs.get(1), task, result);
    assertIntents(shadowType1, shadowType2);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 35 with OrgType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.

the class TestEntertainment method test002AddChildOrg.

@Test
public void test002AddChildOrg() throws Exception {
    final String TEST_NAME = "test002AddChildOrg";
    displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // WHEN
    addObject(ORG_POKER_FILE);
    // THEN
    Collection<String> uniqueMembers = openDJController.getGroupUniqueMembers("cn=Games,ou=groups,dc=example,dc=com");
    assertNotNull("null unique members", uniqueMembers);
    assertEquals("Expected exactly one member", 1, uniqueMembers.size());
    openDJController.assertUniqueMember("cn=Games,ou=groups,dc=example,dc=com", "cn=Poker,ou=groups,dc=example,dc=com");
    PrismObject<OrgType> orgGames = modelService.getObject(OrgType.class, ORG_POKER_OID, null, task, result);
    assertNotNull("No top org for games found", orgGames);
    result.computeStatus();
    assertSuccess("Error while getting top games org", result);
    OrgType orgGamesType = orgGames.asObjectable();
    assertLinks(orgGames, 2);
    List<ObjectReferenceType> linkRefs = orgGamesType.getLinkRef();
    // SHADOW 1
    ShadowType shadowType1 = getAndAssertShadowSuccess(linkRefs.get(0), task, result);
    // SHADOW 2
    ShadowType shadowType2 = getAndAssertShadowSuccess(linkRefs.get(1), task, result);
    assertIntents(shadowType1, shadowType2);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)123 Test (org.testng.annotations.Test)70 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)69 Task (com.evolveum.midpoint.task.api.Task)69 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)31 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)23 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)22 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 PrismObject (com.evolveum.midpoint.prism.PrismObject)13 ArrayList (java.util.ArrayList)13 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)11 Entry (org.opends.server.types.Entry)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)8 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)8 QName (javax.xml.namespace.QName)8 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)7 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7