Search in sources :

Example 26 with AccessCertificationCampaignType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.

the class CertificationTest method addUnansweredActiveCases.

private void addUnansweredActiveCases(List<AccessCertificationCaseType> expectedCases, List<AccessCertificationCaseType> caseList, AccessCertificationCampaignType campaign) {
    for (AccessCertificationCaseType aCase : caseList) {
        if (aCase.getStageNumber() != campaign.getStageNumber()) {
            continue;
        }
        if (campaign.getState() != IN_REVIEW_STAGE) {
            continue;
        }
        boolean emptyDecisionFound = false;
        for (AccessCertificationWorkItemType workItem : aCase.getWorkItem()) {
            if (WorkItemTypeUtil.getOutcome(workItem) == null) {
                emptyDecisionFound = true;
                break;
            }
        }
        if (emptyDecisionFound) {
            LOGGER.info("Expecting case of {}:{}", campaign.getOid(), aCase.getId());
            expectedCases.add(aCase);
        }
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 27 with AccessCertificationCampaignType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.

the class CertificationTest method checkCasesForCampaign.

private void checkCasesForCampaign(String oid, Integer expected, OperationResult result) throws SchemaException, ObjectNotFoundException {
    ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).ownerId(oid).build();
    List<AccessCertificationCaseType> cases = repositoryService.searchContainers(AccessCertificationCaseType.class, query, null, result);
    assertCasesFound(expected, cases, " for " + oid);
    for (AccessCertificationCaseType aCase : cases) {
        PrismObject<AccessCertificationCampaignType> campaign = getOwningCampaignChecked(aCase);
        AssertJUnit.assertEquals("wrong parent OID", oid, campaign.getOid());
    }
    AccessCertificationCampaignType campaign = getFullCampaign(oid, result).asObjectable();
    PrismAsserts.assertEqualsCollectionUnordered("list of cases is different", cases, campaign.getCase().toArray(new AccessCertificationCaseType[0]));
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 28 with AccessCertificationCampaignType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.

the class CertificationTest method test280DeleteWorkItem.

@Test
public void test280DeleteWorkItem() throws Exception {
    OperationResult result = new OperationResult("test280DeleteWorkItem");
    PrismObject<AccessCertificationCampaignType> campaign = getFullCampaign(campaign1Oid, result);
    AccessCertificationCaseType case100 = campaign.asObjectable().getCase().stream().filter(c -> c.getId() == NEW_CASE_ID).findFirst().orElseThrow(() -> new AssertionError("No case 100"));
    assertEquals("Wrong # of work items in case 100", 2, case100.getWorkItem().size());
    AccessCertificationWorkItemType workItem = case100.getWorkItem().stream().filter(wi -> wi.getOriginalAssigneeRef() != null).findFirst().orElse(null);
    assertNotNull("No new work item", workItem);
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, NEW_CASE_ID, F_WORK_ITEM).delete(workItem.clone()).asItemDeltas();
    // WHEN
    executeAndCheckModification(modifications, result, 0);
    // THEN
    checkCasesForCampaign(campaign1Oid, 8, result);
    checkCasesTotal(8, result);
    checkWorkItemsForCampaign(campaign1Oid, 9, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, NEW_CASE_ID, 1, result);
    checkWorkItemsTotal(9, result);
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType) Test(org.testng.annotations.Test)

Example 29 with AccessCertificationCampaignType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.

the class CertificationTest method test720AllCases.

@Test
public void test720AllCases() throws Exception {
    OperationResult result = new OperationResult("test720AllCases");
    List<AccessCertificationCaseType> cases = repositoryService.searchContainers(AccessCertificationCaseType.class, null, null, result);
    AccessCertificationCampaignType campaign1 = getFullCampaign(campaign1Oid, result).asObjectable();
    AccessCertificationCampaignType campaign2 = getFullCampaign(campaign2Oid, result).asObjectable();
    List<AccessCertificationCaseType> expectedCases = new ArrayList<>();
    expectedCases.addAll(campaign1.getCase());
    expectedCases.addAll(campaign2.getCase());
    PrismAsserts.assertEqualsCollectionUnordered("list of cases is different", cases, expectedCases.toArray(new AccessCertificationCaseType[0]));
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 30 with AccessCertificationCampaignType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.

the class RAccessCertificationCampaign method toJAXB.

@Override
public AccessCertificationCampaignType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
    AccessCertificationCampaignType object = new AccessCertificationCampaignType();
    RUtil.revive(object, prismContext);
    RAccessCertificationCampaign.copyToJAXB(this, object, prismContext, options);
    return object;
}
Also used : AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)31 AccessCertificationCampaignType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)28 AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)27 Task (com.evolveum.midpoint.task.api.Task)22 Test (org.testng.annotations.Test)18 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)7 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 AccessCertificationCampaignStateType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType)5 Date (java.util.Date)5 CertificationHandler (com.evolveum.midpoint.certification.impl.handlers.CertificationHandler)4 ObjectTypeUtil.toShortString (com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString)4 AccessCertificationWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)4 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 DeltaBuilder (com.evolveum.midpoint.prism.delta.builder.DeltaBuilder)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3