Search in sources :

Example 36 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class TestActivitiQuery method test300SearchByAssignee.

@Test
public void test300SearchByAssignee() throws Exception {
    final String TEST_NAME = "test210SearchByAssignee";
    TestUtil.displayTestTile(this, TEST_NAME);
    login(userAdministrator);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    List<PrismReferenceValue> assigneeRefs = new ArrayList<>();
    assigneeRefs.add(prv("oid-number-1"));
    assigneeRefs.add(prv(userLead1Oid));
    assigneeRefs.add(prv("oid-number-3"));
    assigneeRefs.add(prv("oid-number-4"));
    assigneeRefs.add(prv("oid-number-5"));
    assigneeRefs.add(prv("oid-number-6"));
    ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, prismContext).item(WorkItemType.F_ASSIGNEE_REF).ref(assigneeRefs).build();
    SearchResultList<WorkItemType> items = modelService.searchContainers(WorkItemType.class, query, null, task, result);
    assertEquals("Wrong # of work items found using multi-assignee/multi-delegate query", 1, items.size());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType) Test(org.testng.annotations.Test)

Example 37 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class OrgStructTest method test101ParentOrgRefFilterManagerRelation.

@Test
public void test101ParentOrgRefFilterManagerRelation() throws Exception {
    final String TEST_NAME = "test101ParentOrgRefFilterManagerRelation";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult opResult = new OperationResult(TEST_NAME);
    PrismReferenceValue refVal = new PrismReferenceValue(ORG_F001_OID);
    refVal.setRelation(SchemaConstants.ORG_MANAGER);
    ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, prismContext).item(ObjectType.F_PARENT_ORG_REF).ref(refVal).build();
    // WHEN
    List<PrismObject<ObjectType>> orgs = repositoryService.searchObjects(ObjectType.class, query, null, opResult);
    // THEN
    PrismAsserts.assertOids(orgs, ELAINE_OID);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 38 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class OrgStructTest method test102ParentOrgRefFilterAnyRelation.

@Test
public void test102ParentOrgRefFilterAnyRelation() throws Exception {
    final String TEST_NAME = "test102ParentOrgRefFilterAnyRelation";
    TestUtil.displayTestTile(TEST_NAME);
    OperationResult opResult = new OperationResult(TEST_NAME);
    PrismReferenceValue refVal = new PrismReferenceValue(ORG_F001_OID);
    refVal.setRelation(PrismConstants.Q_ANY);
    ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, prismContext).item(ObjectType.F_PARENT_ORG_REF).ref(refVal).build();
    // WHEN
    List<PrismObject<ObjectType>> orgs = repositoryService.searchObjects(ObjectType.class, query, null, opResult);
    // THEN
    PrismAsserts.assertOids(orgs, ORG_F002_OID, ORG_F003_OID, ORG_F004_OID, ELAINE_OID, ELAINE_OID);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 39 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class AbstractPasswordTest method test300TwoParentOrgRefs.

// TODO: add user with password that violates the policy
/**
	 * Create an org, and create two parentOrgRefs for jack (MID-3099).
	 * Change to password that violates the password policy.
	 */
@Test
public void test300TwoParentOrgRefs() throws Exception {
    final String TEST_NAME = "test300TwoParentOrgRefs";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    assignOrg(USER_JACK_OID, ORG_GOVERNOR_OFFICE_OID, null);
    assignOrg(USER_JACK_OID, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER);
    UserType jack = getUser(USER_JACK_OID).asObjectable();
    display("jack", jack);
    assertEquals("Wrong # of parentOrgRefs", 2, jack.getParentOrgRef().size());
    ObjectDelta<OrgType> orgDelta = (ObjectDelta<OrgType>) DeltaBuilder.deltaFor(OrgType.class, prismContext).item(OrgType.F_PASSWORD_POLICY_REF).replace(new PrismReferenceValue(PASSWORD_POLICY_GLOBAL_OID)).asObjectDelta(ORG_GOVERNOR_OFFICE_OID);
    executeChanges(orgDelta, null, task, result);
    OrgType govOffice = getObject(OrgType.class, ORG_GOVERNOR_OFFICE_OID).asObjectable();
    display("governor's office", govOffice);
    assertEquals("Wrong OID of password policy ref", PASSWORD_POLICY_GLOBAL_OID, govOffice.getPasswordPolicyRef().getOid());
    try {
        // WHEN
        modifyUserChangePassword(USER_JACK_OID, USER_PASSWORD_1_CLEAR, task, result);
        AssertJUnit.fail("Unexpected success");
    } catch (PolicyViolationException e) {
        // This is expected
        display("Exected exception", e);
    }
    // THEN
    result.computeStatus();
    TestUtil.assertFailure(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertLinks(userJack, 3);
    // Make sure that the password is unchanged
    assertUserPassword(userJack, USER_PASSWORD_VALID_1);
    assertPasswordMetadata(userJack, false, lastPasswordChangeStart, lastPasswordChangeEnd);
    assertDummyPassword(ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_VALID_1);
    assertDummyAccount(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, ACCOUNT_JACK_DUMMY_FULLNAME, true);
    assertDummyPassword(RESOURCE_DUMMY_YELLOW_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_PASSWORD_VALID_1);
    assertDummyPassword(RESOURCE_DUMMY_UGLY_NAME, ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_EMPLOYEE_NUMBER_NEW_GOOD);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 40 with PrismReferenceValue

use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.

the class AbstractPasswordTest method test200ApplyPasswordPolicy.

@Test
public void test200ApplyPasswordPolicy() throws Exception {
    final String TEST_NAME = "test200ApplyPasswordPolicy";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    PrismReferenceValue passPolicyRef = new PrismReferenceValue(PASSWORD_POLICY_GLOBAL_OID, ValuePolicyType.COMPLEX_TYPE);
    // WHEN
    modifyObjectReplaceReference(SecurityPolicyType.class, getSecurityPolicyOid(), new ItemPath(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_PASSWORD_POLICY_REF), task, result, passPolicyRef);
    modifyObjectReplaceProperty(SecurityPolicyType.class, getSecurityPolicyOid(), new ItemPath(SecurityPolicyType.F_CREDENTIALS, CredentialsPolicyType.F_PASSWORD, PasswordCredentialsPolicyType.F_HISTORY_LENGTH), task, result, 3);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Aggregations

PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)126 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)64 Test (org.testng.annotations.Test)47 Task (com.evolveum.midpoint.task.api.Task)45 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)27 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)26 PrismObject (com.evolveum.midpoint.prism.PrismObject)25 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)25 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)24 ArrayList (java.util.ArrayList)22 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)20 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)16 PrismReference (com.evolveum.midpoint.prism.PrismReference)15 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)12 Collection (java.util.Collection)12 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)11