use of com.evolveum.midpoint.repo.sql.data.common.ROrgClosure in project midpoint by Evolveum.
the class AbstractOrgClosureTest method getActualChildrenOf.
protected Set<String> getActualChildrenOf(String ancestor) {
List<ROrgClosure> descendantRecords = getOrgClosureByAncestor(ancestor);
Set<String> rv = new HashSet<String>();
for (ROrgClosure c : descendantRecords) {
rv.add(c.getDescendantOid());
}
return rv;
}
use of com.evolveum.midpoint.repo.sql.data.common.ROrgClosure in project midpoint by Evolveum.
the class OrgStructTest method test001addOrgStructObjectsIncorrect.
@Test
public void test001addOrgStructObjectsIncorrect() throws Exception {
OperationResult opResult = new OperationResult("test001addOrgStructObjectsIncorrect");
List<PrismObject<? extends Objectable>> orgStructIncorrect = prismContext.parserFor(new File(ORG_STRUCT_OBJECTS_INCORRECT)).parseObjects();
for (PrismObject<? extends Objectable> o : orgStructIncorrect) {
repositoryService.addObject((PrismObject<ObjectType>) o, null, opResult);
}
opResult.computeStatusIfUnknown();
AssertJUnit.assertTrue(opResult.isSuccess());
Session session = open();
try {
LOGGER.info("==============CLOSURE TABLE==========");
// descendants of F007 - F007<0>, F009<1>, F008<2>, F0010<2>
Criteria criteria = session.createCriteria(ROrgClosure.class).createCriteria("ancestor", "anc").setFetchMode("ancestor", FetchMode.JOIN).add(Restrictions.eq("anc.oid", ORG_F007_OID));
List<ROrgClosure> orgClosure = criteria.list();
for (ROrgClosure c : orgClosure) {
LOGGER.info("{}", c.getDescendant());
}
AssertJUnit.assertEquals(4, orgClosure.size());
criteria = session.createCriteria(ROrgClosure.class).createCriteria("ancestor", "anc").setFetchMode("ancestor", FetchMode.JOIN).add(Restrictions.eq("anc.oid", ORG_F009_OID));
orgClosure = criteria.list();
AssertJUnit.assertEquals(3, orgClosure.size());
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_NAME).eq(ELAINE_NAME1).build();
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, opResult);
AssertJUnit.assertNotNull(users);
AssertJUnit.assertEquals(1, users.size());
UserType elaine1 = users.get(0).asObjectable();
LOGGER.info("--->elaine1<----");
AssertJUnit.assertEquals("Expected name elaine1, but got " + elaine1.getName().getOrig(), "elaine1", elaine1.getName().getOrig());
AssertJUnit.assertEquals("Expected elaine has one org ref, but got " + elaine1.getParentOrgRef().size(), 2, elaine1.getParentOrgRef().size());
AssertJUnit.assertEquals("Parent org ref oid not equal.", "00000000-8888-6666-0000-100000000011", elaine1.getParentOrgRef().get(0).getOid());
} finally {
close(session);
}
}
use of com.evolveum.midpoint.repo.sql.data.common.ROrgClosure in project midpoint by Evolveum.
the class OrgStructTest method test004modifyOrgStructAddUser.
// users are not in the closure any more
@Test(enabled = false)
public void test004modifyOrgStructAddUser() throws Exception {
Session session = open();
try {
OperationResult opResult = new OperationResult("test004modifyOrgStructAddUser");
//test modification of org ref in another org type..
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_ADD_USER_FILENAME), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<UserType> delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext);
repositoryService.modifyObject(UserType.class, ELAINE_OID, delta.getModifications(), opResult);
LOGGER.info("==>after modify - add user to org<==");
List<ROrgClosure> orgClosure = getOrgClosureByDescendant(ELAINE_OID, session);
AssertJUnit.assertEquals(7, orgClosure.size());
LOGGER.info("==============CLOSURE TABLE==========");
for (ROrgClosure o : orgClosure) {
LOGGER.info("=> A: {}, D: {}", o.getAncestor(), o.getDescendant());
}
} finally {
close(session);
}
}
use of com.evolveum.midpoint.repo.sql.data.common.ROrgClosure in project midpoint by Evolveum.
the class OrgStructTest method test003modifyOrgStructDeleteRefIncorrect.
@Test
public void test003modifyOrgStructDeleteRefIncorrect() throws Exception {
// test modification of org ref - delete org ref
OperationResult opResult = new OperationResult("test003modifyOrgStructDeleteRefIncorrect");
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_INCORRECT_DELETE_REF_FILENAME), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext);
Session session = open();
try {
LOGGER.info("==>before modify - delete<==");
List<ROrgClosure> orgClosure = getOrgClosure(ORG_F012_OID, MODIFY_ORG_INCORRECT_DELETE_REF_OID, session);
AssertJUnit.assertEquals(0, orgClosure.size());
session.getTransaction().commit();
repositoryService.modifyObject(OrgType.class, MODIFY_ORG_INCORRECT_DELETE_REF_OID, delta.getModifications(), opResult);
session.clear();
session.beginTransaction();
LOGGER.info("==>after modify - delete<==");
orgClosure = getOrgClosure(ORG_F012_OID, MODIFY_ORG_INCORRECT_DELETE_REF_OID, session);
AssertJUnit.assertEquals(0, orgClosure.size());
} finally {
close(session);
}
}
Aggregations