Search in sources :

Example 51 with UserType

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

the class TestProjectorPersona method test100AssignRolePersonaAdminToJack.

@Test
public void test100AssignRolePersonaAdminToJack() throws Exception {
    final String TEST_NAME = "test100AssignRolePersonaAdminToJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestProjectorPersona.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    LensContext<UserType> context = createUserLensContext();
    fillContextWithUser(context, USER_JACK_OID, result);
    ObjectDelta<UserType> focusDelta = createAssignmentFocusDelta(UserType.class, USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, RoleType.COMPLEX_TYPE, null, null, null, true);
    addFocusDeltaToContext(context, focusDelta);
    display("Input context", context);
    assertFocusModificationSanity(context);
    rememberShadowFetchOperationCount();
    // WHEN
    projector.project(context, "test", task, result);
    // THEN
    display("Output context", context);
    assertShadowFetchOperationCountIncrement(0);
    assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY);
    assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.ENABLED);
    assertTrue("Unexpected projection changes", context.getProjectionContexts().isEmpty());
    DeltaSetTriple<EvaluatedAssignmentImpl<?>> evaluatedAssignmentTriple = context.getEvaluatedAssignmentTriple();
    assertNotNull("No evaluatedAssignmentTriple", evaluatedAssignmentTriple);
    assertTrue("Unexpected evaluatedAssignmentTriple zero set", evaluatedAssignmentTriple.getZeroSet().isEmpty());
    assertTrue("Unexpected evaluatedAssignmentTriple minus set", evaluatedAssignmentTriple.getMinusSet().isEmpty());
    assertNotNull("No evaluatedAssignmentTriple plus set", evaluatedAssignmentTriple.getPlusSet());
    assertEquals("Wrong size of evaluatedAssignmentTriple plus set", 1, evaluatedAssignmentTriple.getPlusSet().size());
    EvaluatedAssignmentImpl<UserType> evaluatedAssignment = (EvaluatedAssignmentImpl<UserType>) evaluatedAssignmentTriple.getPlusSet().iterator().next();
    display("evaluatedAssignment", evaluatedAssignment);
    assertNotNull("No evaluatedAssignment", evaluatedAssignment);
    DeltaSetTriple<PersonaConstruction<UserType>> personaConstructionTriple = evaluatedAssignment.getPersonaConstructionTriple();
    display("personaConstructionTriple", personaConstructionTriple);
    assertNotNull("No personaConstructionTriple", personaConstructionTriple);
    assertFalse("Empty personaConstructionTriple", personaConstructionTriple.isEmpty());
    assertTrue("Unexpected personaConstructionTriple plus set", personaConstructionTriple.getPlusSet().isEmpty());
    assertTrue("Unexpected personaConstructionTriple minus set", personaConstructionTriple.getMinusSet().isEmpty());
    assertNotNull("No personaConstructionTriple zero set", personaConstructionTriple.getZeroSet());
    assertEquals("Wrong size of personaConstructionTriple zero set", 1, personaConstructionTriple.getZeroSet().size());
    PersonaConstruction<UserType> personaConstruction = personaConstructionTriple.getZeroSet().iterator().next();
    assertNotNull("No personaConstruction", personaConstruction);
    PersonaConstructionType personaConstructionType = personaConstruction.getConstructionType();
    assertNotNull("No personaConstructionType", personaConstructionType);
    assertTrue("Wrong type: " + personaConstructionType.getTargetType(), QNameUtil.match(UserType.COMPLEX_TYPE, personaConstructionType.getTargetType()));
    PrismAsserts.assertEqualsCollectionUnordered("Wrong subtype", personaConstructionType.getTargetSubtype(), "admin");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PersonaConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.PersonaConstructionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 52 with UserType

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

the class TestCorrelationConfiramtionEvaluator method test005CorrelationMatchCaseInsensitive.

@Test
public void test005CorrelationMatchCaseInsensitive() throws Exception {
    String TEST_NAME = "test005CorrelationMatchCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE_EMPL_NUMBER), ConditionalSearchFilterType.COMPLEX_TYPE);
    //		ObjectQuery query = ObjectQuery.createObjectQuery(EqualsFilter.createEqual(null, userType.getDefinition().findItemDefinition(UserType.F_EMPLOYEE_NUMBER), "stringIgnoreCase", "ps1234"));
    //		List<QueryType> queries = new ArrayList<QueryType>();
    //		queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setEmployeeNumber("JaCk");
    ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
    try {
        boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
        System.out.println("matched users " + matchedUsers);
        AssertJUnit.assertTrue(matchedUsers);
    } catch (Exception ex) {
        LOGGER.error("exception occured: {}", ex.getMessage(), ex);
        throw ex;
    }
//		assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
//		assertEquals("Found more than one user.", 1, matchedUsers.size());
//		
//		PrismObject<UserType> jack = matchedUsers.get(0);
//		assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 53 with UserType

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

the class TestCorrelationConfiramtionEvaluator method test001CorrelationOrFilter.

@Test
public void test001CorrelationOrFilter() throws Exception {
    String TEST_NAME = "test001CorrelationOrFilter";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    importObjectFromFile(USER_JACK_FILE);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType filter = PrismTestUtil.parseAtomicValue(new File(CORRELATION_OR_FILTER), ConditionalSearchFilterType.COMPLEX_TYPE);
    List<ConditionalSearchFilterType> filters = new ArrayList<>();
    filters.add(filter);
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    IntegrationTestTools.display("Queries", filters);
    // WHEN
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, filters, resourceType, getSystemConfiguration(), task, result);
    // THEN
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 54 with UserType

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

the class TestCorrelationConfiramtionEvaluator method test003CorrelationWithCondition.

@Test
public void test003CorrelationWithCondition() throws Exception {
    String TEST_NAME = "test003CorrelationWithCondition";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    List<ConditionalSearchFilterType> queries = new ArrayList<>();
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_WITH_CONDITION), ConditionalSearchFilterType.COMPLEX_TYPE);
    queries.add(query);
    query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_WITH_CONDITION_EMPL_NUMBER), ConditionalSearchFilterType.COMPLEX_TYPE);
    queries.add(query);
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    List<PrismObject<UserType>> matchedUsers = evaluator.findFocusesByCorrelationRule(UserType.class, shadow, queries, resourceType, getSystemConfiguration(), task, result);
    assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
    assertEquals("Found more than one user.", 1, matchedUsers.size());
    PrismObject<UserType> jack = matchedUsers.get(0);
    assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 55 with UserType

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

the class TestCorrelationConfiramtionEvaluator method test004CorrelationMatchCaseInsensitive.

@Test
public void test004CorrelationMatchCaseInsensitive() throws Exception {
    String TEST_NAME = "test004CorrelationMatchCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE), ConditionalSearchFilterType.COMPLEX_TYPE);
    //		List<QueryType> queries = new ArrayList<QueryType>();
    //		queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setName(new PolyStringType("JACK"));
    ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
    try {
        boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
        System.out.println("matched users " + matchedUsers);
        AssertJUnit.assertTrue(matchedUsers);
    } catch (Exception ex) {
        LOGGER.error("exception occured: {}", ex.getMessage(), ex);
        throw ex;
    }
//		assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
//		assertEquals("Found more than one user.", 1, matchedUsers.size());
//		
//		PrismObject<UserType> jack = matchedUsers.get(0);
//		assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Aggregations

UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)903 Test (org.testng.annotations.Test)767 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)741 Task (com.evolveum.midpoint.task.api.Task)576 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)217 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)192 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)104 PrismObject (com.evolveum.midpoint.prism.PrismObject)100 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)99 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)88 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)85 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)84 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)83 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)77 ArrayList (java.util.ArrayList)74 QName (javax.xml.namespace.QName)74 File (java.io.File)72 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)58 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)55 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)55