use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class CertificationManagerImpl method openNextStage.
@Override
public void openNextStage(String campaignOid, int requestedStageNumber, Task task, OperationResult parentResult) throws SchemaException, SecurityViolationException, ObjectNotFoundException, ObjectAlreadyExistsException {
Validate.notNull(campaignOid, "campaignOid");
Validate.notNull(task, "task");
Validate.notNull(parentResult, "parentResult");
OperationResult result = parentResult.createSubresult(OPERATION_OPEN_NEXT_STAGE);
result.addParam("campaignOid", campaignOid);
result.addParam("requestedStageNumber", requestedStageNumber);
try {
AccessCertificationCampaignType campaign = generalHelper.getCampaign(campaignOid, null, task, result);
result.addParam("campaign", ObjectTypeUtil.toShortString(campaign));
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("openNextStage starting for {}", ObjectTypeUtil.toShortString(campaign));
}
securityEnforcer.authorize(ModelAuthorizationAction.OPEN_CERTIFICATION_CAMPAIGN_REVIEW_STAGE.getUrl(), null, campaign.asPrismObject(), null, null, null, result);
final int currentStageNumber = campaign.getStageNumber();
final int stages = CertCampaignTypeUtil.getNumberOfStages(campaign);
final AccessCertificationCampaignStateType state = campaign.getState();
LOGGER.trace("openNextStage: currentStageNumber={}, stages={}, requestedStageNumber={}, state={}", currentStageNumber, stages, requestedStageNumber, state);
if (IN_REVIEW_STAGE.equals(state)) {
result.recordFatalError("Couldn't advance to review stage " + requestedStageNumber + " as the stage " + currentStageNumber + " is currently open.");
} else if (IN_REMEDIATION.equals(state)) {
result.recordFatalError("Couldn't advance to review stage " + requestedStageNumber + " as the campaign is currently in the remediation phase.");
} else if (CLOSED.equals(state)) {
result.recordFatalError("Couldn't advance to review stage " + requestedStageNumber + " as the campaign is already closed.");
} else if (!REVIEW_STAGE_DONE.equals(state) && !CREATED.equals(state)) {
throw new IllegalStateException("Unexpected campaign state: " + state);
} else if (REVIEW_STAGE_DONE.equals(state) && requestedStageNumber != currentStageNumber + 1) {
result.recordFatalError("Couldn't advance to review stage " + requestedStageNumber + " as the campaign is currently in stage " + currentStageNumber);
} else if (CREATED.equals(state) && requestedStageNumber != 1) {
result.recordFatalError("Couldn't advance to review stage " + requestedStageNumber + " as the campaign was just created");
} else if (requestedStageNumber > stages) {
result.recordFatalError("Couldn't advance to review stage " + requestedStageNumber + " as the campaign has only " + stages + " stages");
} else {
final CertificationHandler handler = findCertificationHandler(campaign);
final AccessCertificationStageType stage = updateHelper.createStage(campaign, currentStageNumber + 1);
final List<ItemDelta<?, ?>> deltas = updateHelper.getDeltasForStageOpen(campaign, stage, handler, task, result);
updateHelper.modifyObjectViaModel(AccessCertificationCampaignType.class, campaignOid, deltas, task, result);
updateHelper.afterStageOpen(campaignOid, stage, task, result);
}
} catch (RuntimeException e) {
result.recordFatalError("Couldn't move to certification campaign stage " + requestedStageNumber + ": unexpected exception: " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class TestCriticalRolesCertification method test150CloseFirstStage.
@Test
public void test150CloseFirstStage() throws Exception {
final String TEST_NAME = "test150CloseFirstStage";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
certificationManager.closeCurrentStage(campaignOid, 1, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid);
display("campaign in stage 1", campaign);
assertAfterStageClose(campaign, certificationDefinition, 1);
List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaignOid, null, null, result);
assertEquals("unexpected # of cases", 6, caseList.size());
assertCaseOutcome(caseList, USER_ELAINE_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1);
assertCaseOutcome(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID, ACCEPT, ACCEPT, 1);
assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, ACCEPT, ACCEPT, 1);
assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1);
assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, 1);
assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CTO_OID, ACCEPT, ACCEPT, 1);
assertPercentComplete(campaignOid, 100, 100, 100);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class TestCriticalRolesCertification method test330RecordDecisionsThirdStage.
@Test
public void test330RecordDecisionsThirdStage() throws Exception {
final String TEST_NAME = "test330RecordDecisionsThirdStage";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaignOid, null, null, result);
// WHEN
TestUtil.displayWhen(TEST_NAME);
/*
Case Stage1 Stage2 Stage3
==================================================================================================================================
elaine->CEO none (A) -> A elaine A -> A | A elaine:null,administrator:ND -> ND [STOP] | ND
guybrush->COO cheese: A -> A admin: RV -> RV [STOP] | RV
administrator->COO none (A) -> A admin: A -> A | A elaine:A,administrator:null -> A | A
administrator->CEO none (A) -> A elaine: A -> A | A elaine:NR,administrator:NR -> NR | NR
jack->CEO none (A) -> A elaine: null -> NR [STOP] | NR
jack->CTO none (A) -> A none (A) -> A | A elaine:null,administrator:null -> NR | NR
*/
AccessCertificationCaseType elaineCeoCase = findCase(caseList, USER_ELAINE_OID, ROLE_CEO_OID);
AccessCertificationCaseType guybrushCooCase;
AccessCertificationCaseType administratorCooCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID);
AccessCertificationCaseType administratorCeoCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID);
AccessCertificationCaseType jackCeoCase;
AccessCertificationCaseType jackCtoCase;
recordDecision(campaignOid, elaineCeoCase, NOT_DECIDED, null, USER_ADMINISTRATOR_OID, task, result);
recordDecision(campaignOid, administratorCooCase, ACCEPT, null, USER_ELAINE_OID, task, result);
recordDecision(campaignOid, administratorCeoCase, NO_RESPONSE, null, USER_ELAINE_OID, task, result);
recordDecision(campaignOid, administratorCeoCase, NO_RESPONSE, null, USER_ADMINISTRATOR_OID, task, result);
// no response for jackCto
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid);
display("campaign in stage 3", campaign);
caseList = queryHelper.searchCases(campaignOid, null, null, result);
display("caseList", caseList);
elaineCeoCase = findCase(caseList, USER_ELAINE_OID, ROLE_CEO_OID);
guybrushCooCase = findCase(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID);
administratorCooCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID);
administratorCeoCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID);
jackCeoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID);
jackCtoCase = findCase(caseList, USER_JACK_OID, ROLE_CTO_OID);
assertWorkItems(elaineCeoCase, 3);
assertWorkItems(guybrushCooCase, 2);
assertWorkItems(administratorCooCase, 3);
assertWorkItems(administratorCeoCase, 3);
assertWorkItems(jackCeoCase, 1);
assertWorkItems(jackCtoCase, 2);
assertReviewerDecision(elaineCeoCase, NOT_DECIDED, null, 3, USER_ADMINISTRATOR_OID, NOT_DECIDED, false);
assertNoDecision(guybrushCooCase, 3, REVOKE, false);
assertReviewerDecision(administratorCooCase, ACCEPT, null, 3, USER_ELAINE_OID, ACCEPT, false);
assertReviewerDecision(administratorCooCase, null, null, 3, USER_ADMINISTRATOR_OID, ACCEPT, false);
assertReviewerDecision(administratorCeoCase, null, null, 3, USER_ELAINE_OID, NO_RESPONSE, false);
assertReviewerDecision(administratorCeoCase, null, null, 3, USER_ADMINISTRATOR_OID, NO_RESPONSE, false);
assertNoDecision(jackCeoCase, 3, NO_RESPONSE, false);
assertReviewerDecision(jackCtoCase, null, null, 3, USER_ELAINE_OID, NO_RESPONSE, false);
assertReviewerDecision(jackCtoCase, null, null, 3, USER_ADMINISTRATOR_OID, NO_RESPONSE, false);
/*
Case Stage1 Stage2 Stage3
==================================================================================================================================
elaine->CEO none (A) -> A elaine A -> A | A elaine:null,administrator:ND -> ND [STOP] | ND
guybrush->COO cheese: A -> A admin: RV -> RV [STOP] | RV
administrator->COO none (A) -> A admin: A -> A | A elaine:A,administrator:null -> A | A
administrator->CEO none (A) -> A elaine: A -> A | A elaine:NR,administrator:NR -> NR | NR
jack->CEO none (A) -> A elaine: null -> NR [STOP] | NR
jack->CTO none (A) -> A none (A) -> A | A elaine:null,administrator:null -> NR | NR
*/
assertCaseOutcome(caseList, USER_ELAINE_OID, ROLE_CEO_OID, NOT_DECIDED, NOT_DECIDED, null);
assertCaseOutcome(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID, REVOKE, REVOKE, null);
assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, ACCEPT, ACCEPT, null);
assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, NO_RESPONSE, NO_RESPONSE, null);
assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CEO_OID, NO_RESPONSE, NO_RESPONSE, null);
assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CTO_OID, NO_RESPONSE, NO_RESPONSE, null);
assertPercentComplete(campaignOid, 33, 33, 25);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class TestCriticalRolesCertification method test250RecordDecisionsSecondStage.
@Test
public void test250RecordDecisionsSecondStage() throws Exception {
final String TEST_NAME = "test250RecordDecisionsSecondStage";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaignOid, null, null, result);
// WHEN
TestUtil.displayWhen(TEST_NAME);
/*
Stage2: allMustAccept, default: accept, advance on: accept (target owner)
Overall: allMustAccept
owners: CEO: elaine, COO: administrator, CTO: none
Case Stage1 Stage2
=================================================================================
elaine->CEO none (A) -> A elaine A -> A | A
guybrush->COO cheese: A -> A admin: RV -> RV [STOP] | RV
administrator->COO none (A) -> A admin: A -> A | A
administrator->CEO none (A) -> A elaine: A -> A | A
jack->CEO none (A) -> A elaine: null -> NR [STOP] | NR
jack->CTO none (A) -> A none (A) -> A
*/
AccessCertificationCaseType elaineCeoCase = findCase(caseList, USER_ELAINE_OID, ROLE_CEO_OID);
AccessCertificationCaseType guybrushCooCase = findCase(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID);
AccessCertificationCaseType administratorCooCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID);
AccessCertificationCaseType administratorCeoCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID);
recordDecision(campaignOid, elaineCeoCase, ACCEPT, null, USER_ELAINE_OID, task, result);
recordDecision(campaignOid, guybrushCooCase, REVOKE, "no", USER_ADMINISTRATOR_OID, task, result);
recordDecision(campaignOid, administratorCooCase, ACCEPT, "ok", USER_ADMINISTRATOR_OID, task, result);
recordDecision(campaignOid, administratorCeoCase, ACCEPT, null, USER_ELAINE_OID, task, result);
// jackCeo: no response
// jackCto: no reviewers
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid);
display("campaign in stage 2", campaign);
caseList = queryHelper.searchCases(campaignOid, null, null, result);
display("caseList", caseList);
elaineCeoCase = findCase(caseList, USER_ELAINE_OID, ROLE_CEO_OID);
guybrushCooCase = findCase(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID);
administratorCooCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID);
administratorCeoCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID);
AccessCertificationCaseType jackCeoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID);
AccessCertificationCaseType jackCtoCase = findCase(caseList, USER_JACK_OID, ROLE_CTO_OID);
assertWorkItems(elaineCeoCase, 1);
assertWorkItems(guybrushCooCase, 2);
assertWorkItems(administratorCooCase, 1);
assertWorkItems(administratorCeoCase, 1);
assertWorkItems(jackCeoCase, 1);
assertWorkItems(jackCtoCase, 0);
assertSingleDecision(elaineCeoCase, ACCEPT, null, 2, USER_ELAINE_OID, ACCEPT, false);
assertSingleDecision(guybrushCooCase, REVOKE, "no", 2, USER_ADMINISTRATOR_OID, REVOKE, false);
assertSingleDecision(administratorCooCase, ACCEPT, "ok", 2, USER_ADMINISTRATOR_OID, ACCEPT, false);
assertSingleDecision(administratorCeoCase, ACCEPT, null, 2, USER_ELAINE_OID, ACCEPT, false);
assertNoDecision(jackCeoCase, 2, NO_RESPONSE, false);
assertNoDecision(jackCtoCase, 2, ACCEPT, false);
assertPercentComplete(campaignOid, 83, 83, 80);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.
the class TestCriticalRolesCertification method test020OpenFirstStage.
/*
Expected cases, reviewers and decisions/outcomes:
CEO = 00000000-d34d-b33f-f00d-000000000001
COO = 00000000-d34d-b33f-f00d-000000000002
Stage1: oneAcceptAccepts, default: accept, stop on: revoke (manager)
Case Stage1
================================================
elaine->CEO none (A) -> A
guybrush->COO cheese: A -> A
administrator->COO none (A) -> A
administrator->CEO none (A) -> A
jack->CEO none (A) -> A
jack->CTO none (A) -> A
*/
@Test
public void test020OpenFirstStage() throws Exception {
final String TEST_NAME = "test020OpenFirstStage";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestCriticalRolesCertification.class.getName() + "." + TEST_NAME);
task.setOwner(userAdministrator.asPrismObject());
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
certificationManager.openNextStage(campaignOid, 1, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
AccessCertificationCampaignType campaign = getCampaignWithCases(campaignOid);
display("campaign in stage 1", campaign);
assertAfterCampaignStart(campaign, certificationDefinition, 6);
List<AccessCertificationCaseType> caseList = queryHelper.searchCases(campaignOid, null, null, result);
assertEquals("unexpected # of cases", 6, caseList.size());
AccessCertificationCaseType elaineCeoCase = findCase(caseList, USER_ELAINE_OID, ROLE_CEO_OID);
AccessCertificationCaseType guybrushCooCase = findCase(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID);
AccessCertificationCaseType administratorCooCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID);
AccessCertificationCaseType administratorCeoCase = findCase(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID);
AccessCertificationCaseType jackCeoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID);
AccessCertificationCaseType jackCtoCase = findCase(caseList, USER_JACK_OID, ROLE_CTO_OID);
checkSpecificCase(elaineCeoCase, userElaine);
checkSpecificCase(guybrushCooCase, userGuybrush);
checkSpecificCase(administratorCeoCase, userAdministrator);
checkSpecificCase(administratorCooCase, userAdministrator);
checkSpecificCase(jackCeoCase, userJack);
checkSpecificCase(jackCtoCase, userJack);
assertCaseReviewers(elaineCeoCase, ACCEPT, 1, Collections.emptyList());
assertCaseReviewers(guybrushCooCase, NO_RESPONSE, 1, Collections.singletonList(USER_CHEESE_OID));
assertCaseReviewers(administratorCooCase, ACCEPT, 1, Collections.emptyList());
assertCaseReviewers(administratorCeoCase, ACCEPT, 1, Collections.emptyList());
assertCaseReviewers(jackCeoCase, ACCEPT, 1, Collections.emptyList());
assertCaseReviewers(jackCtoCase, ACCEPT, 1, Collections.emptyList());
assertCaseOutcome(caseList, USER_ELAINE_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, null);
assertCaseOutcome(caseList, USER_GUYBRUSH_OID, ROLE_COO_OID, NO_RESPONSE, NO_RESPONSE, null);
assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_COO_OID, ACCEPT, ACCEPT, null);
assertCaseOutcome(caseList, USER_ADMINISTRATOR_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, null);
assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CEO_OID, ACCEPT, ACCEPT, null);
assertCaseOutcome(caseList, USER_JACK_OID, ROLE_CTO_OID, ACCEPT, ACCEPT, null);
assertPercentComplete(campaign, 83, 83, 0);
}
Aggregations