use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class OrgStructTest method test002modifyOrgStructAddRefIncorrect.
@Test
public void test002modifyOrgStructAddRefIncorrect() throws Exception {
OperationResult opResult = new OperationResult("test002modifyOrgStructAddRefIncorrect");
// test modification of org ref in another org type..
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_INCORRECT_ADD_REF_FILENAME), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext);
repositoryService.modifyObject(OrgType.class, MODIFY_ORG_INCORRECT_ADD_REF_OID, delta.getModifications(), opResult);
Session session = open();
try {
List<ROrgClosure> orgClosure = getOrgClosureByDescendant(MODIFY_ORG_INCORRECT_ADD_REF_OID, session);
LOGGER.info("after modify incorrect - closure");
for (ROrgClosure c : orgClosure) {
LOGGER.info("{}\t{}", new Object[] { c.getAncestor().getOid(), c.getDescendant().getOid() });
}
AssertJUnit.assertEquals(5, orgClosure.size());
List<String> ancestors = new ArrayList<String>();
ancestors.add(MODIFY_ORG_INCORRECT_ADD_REF_OID);
ancestors.add(ORG_F001_OID);
ancestors.add(ORG_F002_OID);
for (String ancestorOid : ancestors) {
orgClosure = getOrgClosure(ancestorOid, MODIFY_ORG_INCORRECT_ADD_REF_OID, session);
AssertJUnit.assertEquals(1, orgClosure.size());
AssertJUnit.assertEquals(ancestorOid, orgClosure.get(0).getAncestor().getOid());
AssertJUnit.assertEquals(MODIFY_ORG_INCORRECT_ADD_REF_OID, orgClosure.get(0).getDescendant().getOid());
}
} finally {
close(session);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class OrgStructTest method test002modifyOrgStructAddRef.
@Test
public void test002modifyOrgStructAddRef() throws Exception {
OperationResult opResult = new OperationResult("test002modifyOrgStructAddRef");
// test modification of org ref in another org type..
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_ADD_REF_FILENAME), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext);
Query query;
List<ROrgClosure> orgClosure;
Session session = open();
try {
orgClosure = getOrgClosureByDescendant(MODIFY_ORG_ADD_REF_OID, session);
LOGGER.info("before modify");
for (ROrgClosure c : orgClosure) {
LOGGER.info("{}\t{}", new Object[] { c.getAncestor().getOid(), c.getDescendant().getOid() });
}
AssertJUnit.assertEquals(3, orgClosure.size());
} finally {
close(session);
}
repositoryService.modifyObject(OrgType.class, MODIFY_ORG_ADD_REF_OID, delta.getModifications(), opResult);
session = open();
try {
orgClosure = getOrgClosureByDescendant(MODIFY_ORG_ADD_REF_OID, session);
LOGGER.info("after modify");
for (ROrgClosure c : orgClosure) {
LOGGER.info("{}\t{}", new Object[] { c.getAncestor().getOid(), c.getDescendant().getOid() });
}
AssertJUnit.assertEquals(4, orgClosure.size());
List<String> ancestors = new ArrayList<String>();
ancestors.add(MODIFY_ORG_ADD_REF_OID);
ancestors.add(ORG_F003_OID);
ancestors.add(ORG_F001_OID);
ancestors.add(ORG_F002_OID);
for (String ancestorOid : ancestors) {
orgClosure = getOrgClosure(ancestorOid, MODIFY_ORG_ADD_REF_OID, session);
LOGGER.info("=> A: {}, D: {}", orgClosure.get(0).getAncestor(), orgClosure.get(0).getDescendant());
AssertJUnit.assertEquals(1, orgClosure.size());
AssertJUnit.assertEquals(ancestorOid, orgClosure.get(0).getAncestor().getOid());
AssertJUnit.assertEquals(MODIFY_ORG_ADD_REF_OID, orgClosure.get(0).getDescendant().getOid());
}
} finally {
close(session);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class TestOrgStructCaribbean method test104RecomputeGovernor.
/**
* MID-3448
*/
@Test
public void test104RecomputeGovernor() throws Exception {
final String TEST_NAME = "test104RecomputeGovernor";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.recompute(OrgType.class, ORG_GOVERNOR_OFFICE_OID, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<OrgType> orgJamaica = getObject(OrgType.class, ORG_CARIBBEAN_JAMAICA_OID);
display("Jamaica", orgJamaica);
assertAssignedOrgs(orgJamaica, ORG_CARIBBEAN_THE_CROWN_OID);
assertHasOrgs(orgJamaica, ORG_CARIBBEAN_THE_CROWN_OID);
assertHasNoOrg(orgJamaica, ORG_GOVERNOR_OFFICE_OID);
PrismObject<OrgType> orgMonkeyGovernor = getObject(OrgType.class, ORG_GOVERNOR_OFFICE_OID);
display("Monkey Governor", orgMonkeyGovernor);
assertHasNoOrg(orgMonkeyGovernor, ORG_CARIBBEAN_JAMAICA_OID);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class TestOrgStructCaribbean method test102RecomputeJamaica.
/**
* MID-3448
*/
@Test
public void test102RecomputeJamaica() throws Exception {
final String TEST_NAME = "test102RecomputeJamaica";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TestOrgStructCaribbean.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.recompute(OrgType.class, ORG_CARIBBEAN_JAMAICA_OID, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<OrgType> orgJamaica = getObject(OrgType.class, ORG_CARIBBEAN_JAMAICA_OID);
display("Jamaica", orgJamaica);
assertAssignedOrgs(orgJamaica, ORG_CARIBBEAN_THE_CROWN_OID);
assertHasOrgs(orgJamaica, ORG_CARIBBEAN_THE_CROWN_OID);
assertHasNoOrg(orgJamaica, ORG_GOVERNOR_OFFICE_OID);
PrismObject<OrgType> orgMonkeyGovernor = getObject(OrgType.class, ORG_GOVERNOR_OFFICE_OID);
display("Monkey Governor", orgMonkeyGovernor);
assertHasNoOrg(orgMonkeyGovernor, ORG_CARIBBEAN_JAMAICA_OID);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class TestOrgStruct method assertManager.
private void assertManager(String userOid, String managerOid, String orgType, boolean allowSelf, OperationResult result) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
PrismObject<UserType> user = getUser(userOid);
ModelExpressionThreadLocalHolder.pushExpressionEnvironment(new ExpressionEnvironment<>(null, result));
Collection<UserType> managers = libraryMidpointFunctions.getManagers(user.asObjectable(), orgType, allowSelf);
ModelExpressionThreadLocalHolder.popExpressionEnvironment();
if (managerOid == null) {
if (managers == null || managers.isEmpty()) {
return;
} else {
AssertJUnit.fail("Expected no manager for " + user + ", but got " + managers);
}
} else {
if (managers == null) {
AssertJUnit.fail("Expected manager for " + user + ", but got no manager");
}
if (managers.size() != 1) {
AssertJUnit.fail("Expected one manager for " + user + ", but got: " + managers);
} else {
UserType manager = managers.iterator().next();
if (manager.getOid().equals(managerOid)) {
return;
} else {
AssertJUnit.fail("Expected manager with OID " + managerOid + " for " + user + ", but got " + manager);
}
}
}
}
Aggregations