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