Skip to content

Commit

Permalink
Fixed bug related to changing existing decision.
Browse files Browse the repository at this point in the history
Small GUI change.
  • Loading branch information
mederly committed May 27, 2015
1 parent 5cb0add commit 3360589
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
Expand Up @@ -116,12 +116,12 @@ public void onClick(AjaxRequestTarget target, IModel<SelectableBean<AccessCertif

@Override
public String getFirstCap(){
return PageCertDefinitions.this.createStringResource("PageCertDefinitions.button.showCampaigns").getString();
return PageCertDefinitions.this.createStringResource("PageCertDefinitions.button.createCampaign").getString();
}

@Override
public String getSecondCap(){
return PageCertDefinitions.this.createStringResource("PageCertDefinitions.button.createCampaign").getString();
return PageCertDefinitions.this.createStringResource("PageCertDefinitions.button.showCampaigns").getString();
}

@Override
Expand All @@ -131,12 +131,12 @@ public String getFirstColorCssClass(){

@Override
public void firstClicked(AjaxRequestTarget target, IModel<SelectableBean<AccessCertificationDefinitionType>> model){
showCampaignsPerformed(target, model.getObject().getValue());
createCampaignPerformed(target, model.getObject().getValue());
}

@Override
public void secondClicked(AjaxRequestTarget target, IModel<SelectableBean<AccessCertificationDefinitionType>> model){
createCampaignPerformed(target, model.getObject().getValue());
showCampaignsPerformed(target, model.getObject().getValue());
}
};
columns.add(column);
Expand Down
Expand Up @@ -175,7 +175,7 @@ void recordDecision(AccessCertificationCampaignType campaign, long caseId, Acces
// let's remove existing decision and add the new one
if (existingDecision != null) {
ContainerDelta<AccessCertificationDecisionType> decisionDeleteDelta =
ContainerDelta.createModificationDelete(decisionPath, AccessCertificationCampaignType.class, prismContext, decision);
ContainerDelta.createModificationDelete(decisionPath, AccessCertificationCampaignType.class, prismContext, existingDecision.clone());
deltaList.add(decisionDeleteDelta);
}

Expand Down
Expand Up @@ -314,6 +314,50 @@ public void test100RecordDecision() throws Exception {
assertEquals("wrong enabled", Boolean.TRUE, superuserCase.isEnabled());
}

@Test
public void test105RecordAcceptJackCeo() throws Exception {
final String TEST_NAME = "test105RecordAcceptJackCeo";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(BasicCertificationTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

List<AccessCertificationCaseType> caseList = certificationManager.searchCases(campaignOid, null, null, task, result);
AccessCertificationCaseType ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID);

// WHEN
TestUtil.displayWhen(TEST_NAME);
AccessCertificationDecisionType decision = new AccessCertificationDecisionType(prismContext);
decision.setResponse(AccessCertificationResponseType.ACCEPT);
decision.setComment("ok");
decision.setStageNumber(1);
// reviewerRef will be taken from the current user
long id = ceoCase.asPrismContainerValue().getId();
certificationManager.recordDecision(campaignOid, id, decision, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

caseList = certificationManager.searchCases(campaignOid, null, null, task, result);
display("caseList", caseList);
checkAllCases(caseList);

ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID);
assertEquals("changed case ID", Long.valueOf(id), ceoCase.asPrismContainerValue().getId());
assertEquals("wrong # of decisions", 1, ceoCase.getDecision().size());
AccessCertificationDecisionType storedDecision = ceoCase.getDecision().get(0);
assertEquals("wrong response", AccessCertificationResponseType.ACCEPT, storedDecision.getResponse());
assertEquals("wrong comment", "ok", storedDecision.getComment());
assertEquals("wrong reviewerRef", ObjectTypeUtil.createObjectRef(USER_ADMINISTRATOR_OID, ObjectTypes.USER), storedDecision.getReviewerRef());
assertEquals("wrong stage number", 1, storedDecision.getStageNumber());
assertApproximateTime("timestamp", new Date(), storedDecision.getTimestamp());
assertEquals("wrong current response", AccessCertificationResponseType.ACCEPT, ceoCase.getCurrentResponse());
assertEquals("wrong enabled", Boolean.TRUE, ceoCase.isEnabled());
}

@Test
public void test110RecordRevokeJackCeo() throws Exception {
final String TEST_NAME = "test110RecordRevokeJackCeo";
Expand Down Expand Up @@ -346,6 +390,7 @@ public void test110RecordRevokeJackCeo() throws Exception {
checkAllCases(caseList);

ceoCase = findCase(caseList, USER_JACK_OID, ROLE_CEO_OID);
display("CEO case", ceoCase.asPrismContainerValue());
assertEquals("changed case ID", Long.valueOf(id), ceoCase.asPrismContainerValue().getId());
assertEquals("wrong # of decisions", 1, ceoCase.getDecision().size());
AccessCertificationDecisionType storedDecision = ceoCase.getDecision().get(0);
Expand Down

0 comments on commit 3360589

Please sign in to comment.