Search in sources :

Example 26 with RUser

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

the class ObjectDeltaUpdaterTest method test300DeletePhoto.

@Test
public void test300DeletePhoto() throws Exception {
    OperationResult result = new OperationResult("test300DeletePhoto");
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
    delta.addModificationDeleteProperty(UserType.F_JPEG_PHOTO, new byte[] { 4, 5, 6 });
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(5, TestStatementInspector.getQueryCount());
    }
    logger.info("test300DeletePhoto check");
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        Set<RFocusPhoto> p = u.getJpegPhoto();
        AssertJUnit.assertEquals(0, p.size());
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) RFocusPhoto(com.evolveum.midpoint.repo.sql.data.common.RFocusPhoto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 27 with RUser

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

the class ObjectDeltaUpdaterTest method test160AddDeleteParentRef.

@Test
public void test160AddDeleteParentRef() throws Exception {
    OperationResult result = new OperationResult("test160AddDeleteParentRef");
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
    ObjectReferenceType parentOrgRef = createRef(OrgType.COMPLEX_TYPE, "456");
    delta.addModificationDeleteReference(UserType.F_PARENT_ORG_REF, parentOrgRef.asReferenceValue());
    parentOrgRef = createRef(OrgType.COMPLEX_TYPE, "789");
    delta.addModificationAddReference(UserType.F_PARENT_ORG_REF, parentOrgRef.asReferenceValue());
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(6, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        // noinspection unchecked
        assertReferences((Collection) u.getParentOrgRef(), createRepoRef(OrgType.COMPLEX_TYPE, "123"), createRepoRef(OrgType.COMPLEX_TYPE, "789"));
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 28 with RUser

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

the class ObjectDeltaUpdaterTest method test290ReplacePhoto.

@Test
public void test290ReplacePhoto() throws Exception {
    OperationResult result = new OperationResult("test290ReplacePhoto");
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
    delta.addModificationReplaceProperty(UserType.F_JPEG_PHOTO, new byte[] { 4, 5, 6 });
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(6, TestStatementInspector.getQueryCount());
    }
    logger.info("test290ReplacePhoto check");
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        Set<RFocusPhoto> p = u.getJpegPhoto();
        AssertJUnit.assertEquals(1, p.size());
        RFocusPhoto photo = p.iterator().next();
        Assert.assertEquals(photo.getPhoto(), new byte[] { 4, 5, 6 });
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) RFocusPhoto(com.evolveum.midpoint.repo.sql.data.common.RFocusPhoto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 29 with RUser

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

the class ObjectDeltaUpdaterTest method test280AddPhoto.

// More photo-related tests should go to UserPhotoTest
@Test
public void test280AddPhoto() throws Exception {
    OperationResult result = new OperationResult("test280AddPhoto");
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
    delta.addModificationAddProperty(UserType.F_JPEG_PHOTO, new byte[] { 1, 2, 3 });
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result);
    TestStatementInspector.dump();
    if (isUsingH2()) {
        AssertJUnit.assertEquals(6, TestStatementInspector.getQueryCount());
    }
    logger.info("test280AddPhoto check");
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        Set<RFocusPhoto> p = u.getJpegPhoto();
        AssertJUnit.assertEquals(1, p.size());
        RFocusPhoto photo = p.iterator().next();
        Assert.assertEquals(photo.getPhoto(), new byte[] { 1, 2, 3 });
    }
}
Also used : RUser(com.evolveum.midpoint.repo.sql.data.common.RUser) RFocusPhoto(com.evolveum.midpoint.repo.sql.data.common.RFocusPhoto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Session(org.hibernate.Session) Test(org.testng.annotations.Test)

Example 30 with RUser

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

the class ObjectDeltaUpdaterTest method test130AddDeleteAssignment.

@Test
public void test130AddDeleteAssignment() throws Exception {
    OperationResult result = new OperationResult("test130AddDeleteAssignment");
    List<ItemDelta<?, ?>> modifications = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).delete(new AssignmentType(prismContext).id(1L)).add(new AssignmentType(prismContext).description("asdf").targetRef("444", OrgType.COMPLEX_TYPE).beginMetadata().createChannel("zzz").modifyApproverRef("555", UserType.COMPLEX_TYPE).<AssignmentType>end()).asItemDeltas();
    TestStatementInspector.start();
    repositoryService.modifyObject(UserType.class, userOid, modifications, result);
    TestStatementInspector.dump();
    // select modifyappr0_.owner_id as owner_id1_14_0_, modifyappr0_.owner_owner_oid as owner_ow2_14_0_, modifyappr0_.reference_type as referenc3_14_0_, modifyappr0_.relation as relation4_14_0_, modifyappr0_.targetOid as targetOi5_14_0_, modifyappr0_.owner_id as owner_id1_14_1_, modifyappr0_.owner_owner_oid as owner_ow2_14_1_, modifyappr0_.reference_type as referenc3_14_1_, modifyappr0_.relation as relation4_14_1_, modifyappr0_.targetOid as targetOi5_14_1_, modifyappr0_.targetType as targetTy6_14_1_ from m_assignment_reference modifyappr0_ where ( modifyappr0_.reference_type= 1) and modifyappr0_.owner_id=? and modifyappr0_.owner_owner_oid=?
    if (isUsingH2()) {
        AssertJUnit.assertEquals(10, TestStatementInspector.getQueryCount());
    }
    try (Session session = factory.openSession()) {
        RUser u = session.get(RUser.class, userOid);
        Set<RAssignment> assignments = u.getAssignments();
        AssertJUnit.assertEquals(1, assignments.size());
        RAssignment a = assignments.iterator().next();
        AssertJUnit.assertEquals("zzz", a.getCreateChannel());
        ObjectReferenceType targetRef = a.getTargetRef().toJAXB(prismContext);
        AssertJUnit.assertEquals(createRef(OrgType.COMPLEX_TYPE, "444", SchemaConstants.ORG_DEFAULT), targetRef);
        // noinspection unchecked
        assertReferences((Collection) a.getModifyApproverRef(), createRepoRef(UserType.COMPLEX_TYPE, "555"));
    }
}
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