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());
}
}
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"));
}
}
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 });
}
}
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 });
}
}
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"));
}
}
Aggregations