Search in sources :

Example 21 with OrgType

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

the class TestRetirement method createOrg.

private PrismObject<OrgType> createOrg(String name, String parentOrgOid) throws SchemaException {
    PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
    OrgType orgType = org.asObjectable();
    orgType.setName(new PolyStringType(name));
    orgType.getOrgType().add(ORG_TYPE_FUNCTIONAL);
    AssignmentType metaRoleAssignment = new AssignmentType();
    ObjectReferenceType metaRoleAssignmentTargetRef = new ObjectReferenceType();
    metaRoleAssignmentTargetRef.setOid(ROLE_META_ORG_OID);
    metaRoleAssignmentTargetRef.setType(RoleType.COMPLEX_TYPE);
    metaRoleAssignment.setTargetRef(metaRoleAssignmentTargetRef);
    orgType.getAssignment().add(metaRoleAssignment);
    if (parentOrgOid != null) {
        AssignmentType parentAssignment = new AssignmentType();
        ObjectReferenceType parentAssignmentTargetRef = new ObjectReferenceType();
        parentAssignmentTargetRef.setOid(parentOrgOid);
        parentAssignmentTargetRef.setType(OrgType.COMPLEX_TYPE);
        parentAssignment.setTargetRef(parentAssignmentTargetRef);
        orgType.getAssignment().add(parentAssignment);
    }
    return org;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 22 with OrgType

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

the class TestRetirement method assertGroupMembers.

private 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 23 with OrgType

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

the class TestRetirement method test100AddOrgRoyulaCarpathia.

@Test
public void test100AddOrgRoyulaCarpathia() throws Exception {
    final String TEST_NAME = "test100AddOrgRoyulaCarpathia";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestRetirement.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<OrgType> orgBefore = createOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    display("Adding org", orgBefore);
    addObject(orgBefore, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    dumpOrgTree();
    dumpLdap();
    PrismObject<OrgType> orgAfter = getAndAssertFunctionalOrg(ORG_ROYULA_CARPATHIA_NAME, ORG_TOP_OID);
    orgRolyulaCarpathiaOid = orgAfter.getOid();
    assertSubOrgs(orgAfter, 0);
    assertSubOrgs(ORG_TOP_OID, 1);
}
Also used : 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) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest)

Example 24 with OrgType

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

the class TestOrgSync method test110AddHrAccountGuybrush.

/**
	 * Two-level orgpath. Both orgs should be created.
	 */
@Test
public void test110AddHrAccountGuybrush() throws Exception {
    final String TEST_NAME = "test110AddHrAccountGuybrush";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
    DummyAccount newAccount = new DummyAccount(ACCOUNT_GUYBRUSH_USERNAME);
    newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_FIRST_NAME, ACCOUNT_GUYBRUSH_FIST_NAME);
    newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_LAST_NAME, ACCOUNT_GUYBRUSH_LAST_NAME);
    newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_HR_ORGPATH, ORGPATH_FREELANCE);
    // WHEN
    dummyResourceHr.addAccount(newAccount);
    waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_HR_OID, true);
    // THEN
    PrismObject<UserType> user = findUserByUsername(ACCOUNT_GUYBRUSH_USERNAME);
    assertNotNull("No guybrush user", user);
    display("User", user);
    assertUserGuybrush(user);
    assertAccount(user, RESOURCE_DUMMY_HR_OID);
    dumpOrgTree();
    PrismObject<OrgType> orgFreelance = getAndAssertReplicatedOrg("Freelance");
    PrismObject<OrgType> orgMoR = getAndAssertReplicatedOrg("Ministry of Rum");
    orgMoROid = orgMoR.getOid();
    assertAssignedOrg(user, orgFreelance.getOid());
    assertHasOrg(user, orgFreelance.getOid());
    assertHasOrg(orgFreelance, orgMoR.getOid());
    assertHasOrg(orgMoR, ORG_TOP_OID);
    assertSubOrgs(orgFreelance, 0);
    assertSubOrgs(orgMoR, 1);
    assertSubOrgs(orgMonkeyIslandOid, 0);
    assertSubOrgs(ORG_TOP_OID, 2);
    assertBasicRoleAndResources(user);
    assertAssignments(user, 2);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 25 with OrgType

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

the class OrgStructTest method test003modifyOrgStructDeleteRef.

@SuppressWarnings("unchecked")
@Test
public void test003modifyOrgStructDeleteRef() throws Exception {
    // test modification of org ref - delete org ref
    OperationResult opResult = new OperationResult("test003modifyOrgStructDeleteRef");
    ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_DELETE_REF_FILENAME), ObjectModificationType.COMPLEX_TYPE);
    ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext);
    Session session = open();
    try {
        LOGGER.info("==>before modify - delete<==");
        List<ROrgClosure> orgClosure = getOrgClosure(ORG_F003_OID, MODIFY_ORG_DELETE_REF_OID, session);
        AssertJUnit.assertEquals(1, orgClosure.size());
        session.getTransaction().commit();
        repositoryService.modifyObject(OrgType.class, MODIFY_ORG_DELETE_REF_OID, delta.getModifications(), opResult);
        session.clear();
        session.beginTransaction();
        LOGGER.info("==>after modify - delete<==");
        orgClosure = getOrgClosure(ORG_F003_OID, MODIFY_ORG_DELETE_REF_OID, session);
        AssertJUnit.assertEquals(0, orgClosure.size());
    } finally {
        close(session);
    }
}
Also used : ObjectModificationType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType) ROrgClosure(com.evolveum.midpoint.repo.sql.data.common.ROrgClosure) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) File(java.io.File) Session(org.hibernate.Session) 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