Search in sources :

Example 21 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test100ReplaceNameAndOthers.

@Test
public void test100ReplaceNameAndOthers() throws Exception {
    OperationResult result = new OperationResult("test100ReplaceNameAndOthers");
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
    delta.addModificationReplaceProperty(UserType.F_NAME, new PolyString("ášdf", "asdf"));
    delta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, new PolyString("ášdf", "asdf"));
    delta.addModificationReplaceProperty(UserType.F_LOCALE, "en-US");
    delta.addModificationReplaceProperty(ItemPath.create(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), ActivationStatusType.DISABLED);
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(5, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        AssertJUnit.assertEquals(new RPolyString("ášdf", "asdf"), u.getName());
        AssertJUnit.assertEquals(new RPolyString("ášdf", "asdf"), u.getNameCopy());
        AssertJUnit.assertEquals(new RPolyString("ášdf", "asdf"), u.getGivenName());
        AssertJUnit.assertEquals(u.getLocale(), "en-US");
        AssertJUnit.assertEquals(RActivationStatus.DISABLED, u.getActivation().getAdministrativeStatus());
    }
}
Also used : RPolyString(com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString) RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RPolyString(com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 22 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test148AddAssignmentActivation.

@Test
public void test148AddAssignmentActivation() throws Exception {
    OperationResult result = new OperationResult("test148AddAssignmentActivation");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_ACTIVATION).add(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ARCHIVED)).asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(5, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        Set<RAssignment> assignments = u.getAssignments();
        AssertJUnit.assertEquals(1, assignments.size());
        RActivation act = assignments.iterator().next().getActivation();
        AssertJUnit.assertNotNull(act);
        AssertJUnit.assertEquals(RActivationStatus.ARCHIVED, act.getAdministrativeStatus());
    }
}
Also used : RAssignment(com.evolveum.midpoint.repo.sql.data.common.container.RAssignment) RActivation(com.evolveum.midpoint.repo.sql.data.common.embedded.RActivation) RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 23 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method assertOperationExecutionSize.

private void assertOperationExecutionSize(String oid, int expectedSize) {
    try (Session session = open()) {
        RUser rUser = (RUser) session.createQuery("from RUser where oid = :o").setParameter("o", oid).getSingleResult();
        AssertJUnit.assertEquals(expectedSize, rUser.getOperationExecutions().size());
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) Session(org.hibernate.Session)

Example 24 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test170ModifySubtypeAndMetadataCreateChannel.

@Test
public void test170ModifySubtypeAndMetadataCreateChannel() throws Exception {
    OperationResult result = new OperationResult("test170ModifySubtypeAndMetadataCreateChannel");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_SUBTYPE).add("one", "two").item(UserType.F_METADATA, MetadataType.F_CREATE_CHANNEL).replace("asdf").asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(5, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        AssertJUnit.assertEquals("asdf", u.getCreateChannel());
        AssertJUnit.assertEquals(u.getSubtype(), new HashSet<>(Arrays.asList("one", "two")));
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 25 with RUser

use of com.evolveum.midpoint.repo.sql.data.common.RUser in project midpoint by Evolveum.

the class ObjectDeltaUpdaterTest method test147DeleteAssignmentActivation.

@Test
public void test147DeleteAssignmentActivation() throws Exception {
    OperationResult result = new OperationResult("test145AddActivationToAssignment");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_ACTIVATION).delete(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ENABLED)).asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(5, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        Set<RAssignment> assignments = u.getAssignments();
        AssertJUnit.assertEquals(1, assignments.size());
        AssertJUnit.assertNull(assignments.iterator().next().getActivation());
    }
}
Also used : RAssignment(com.evolveum.midpoint.repo.sql.data.common.container.RAssignment) RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Aggregations

RUser (com.evolveum.midpoint.repo.sql.data.common.RUser)56 Session (org.hibernate.Session)56 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)55 Test (org.testng.annotations.Test)55 RAssignment (com.evolveum.midpoint.repo.sql.data.common.container.RAssignment)19 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)15 RFocusPhoto (com.evolveum.midpoint.repo.sql.data.common.RFocusPhoto)3 RActivation (com.evolveum.midpoint.repo.sql.data.common.embedded.RActivation)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 RAssignmentExtension (com.evolveum.midpoint.repo.sql.data.common.any.RAssignmentExtension)1 RPolyString (com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString)1 File (java.io.File)1 QName (javax.xml.namespace.QName)1