Search in sources :

Example 6 with AccessCertificationWorkItemType

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

the class CertificationTest method test270ModifyWorkItem.

@Test
public void test270ModifyWorkItem() throws Exception {
    OperationResult result = new OperationResult("test270ModifyWorkItem");
    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);
    XMLGregorianCalendar closedTimestamp = XmlTypeConverter.createXMLGregorianCalendar(new Date());
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, NEW_CASE_ID, F_WORK_ITEM, workItem.getId(), AccessCertificationWorkItemType.F_CLOSE_TIMESTAMP).replace(closedTimestamp).asItemDeltas();
    // WHEN
    executeAndCheckModification(modifications, result, 0);
    // THEN
    checkCasesForCampaign(campaign1Oid, 8, result);
    checkCasesTotal(8, result);
    checkWorkItemsForCampaign(campaign1Oid, 10, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, NEW_CASE_ID, 2, result);
    checkWorkItemsTotal(10, result);
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Date(java.util.Date) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType) Test(org.testng.annotations.Test)

Example 7 with AccessCertificationWorkItemType

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

the class CertificationTest method test330ReplaceWorkItemsExistingId.

@Test
public void test330ReplaceWorkItemsExistingId() throws Exception {
    OperationResult result = new OperationResult("test330ReplaceWorkItemsExistingId");
    AccessCertificationWorkItemType wi200 = new AccessCertificationWorkItemType(prismContext);
    //dangerous
    wi200.setId(200L);
    wi200.setStageNumber(44);
    wi200.assigneeRef(createObjectRef("999999", ObjectTypes.USER));
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, 6, F_WORK_ITEM).replace(wi200).asItemDeltas();
    executeAndCheckModification(modifications, result, 0);
    checkCasesForCampaign(campaign1Oid, 9, result);
    checkCasesTotal(9, result);
    checkWorkItemsForCampaign(campaign1Oid, 8, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, SECOND_NEW_CASE_ID, 1, result);
    checkWorkItemsTotal(8, result);
}
Also used : 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 8 with AccessCertificationWorkItemType

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

the class RAccessCertificationCase method toRepo.

private static RAccessCertificationCase toRepo(RAccessCertificationCase rCase, AccessCertificationCaseType case1, RepositoryContext context) throws DtoTranslationException {
    // we don't try to advise hibernate - let it do its work, even if it would cost some SELECTs
    rCase.setTransient(null);
    rCase.setId(RUtil.toInteger(case1.getId()));
    rCase.setObjectRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getObjectRef(), context.prismContext));
    rCase.setTargetRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getTargetRef(), context.prismContext));
    rCase.setTenantRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getTenantRef(), context.prismContext));
    rCase.setOrgRef(RUtil.jaxbRefToEmbeddedRepoRef(case1.getOrgRef(), context.prismContext));
    if (case1.getActivation() != null) {
        RActivation activation = new RActivation();
        RActivation.copyFromJAXB(case1.getActivation(), activation, context);
        rCase.setActivation(activation);
    }
    for (AccessCertificationWorkItemType workItem : case1.getWorkItem()) {
        rCase.getWorkItems().add(RAccessCertificationWorkItem.toRepo(rCase, workItem, context));
    }
    rCase.setReviewRequestedTimestamp(case1.getCurrentStageCreateTimestamp());
    rCase.setReviewDeadline(case1.getCurrentStageDeadline());
    rCase.setRemediedTimestamp(case1.getRemediedTimestamp());
    rCase.setCurrentStageOutcome(case1.getCurrentStageOutcome());
    rCase.setStageNumber(case1.getStageNumber());
    rCase.setOutcome(case1.getOutcome());
    PrismContainerValue<AccessCertificationCaseType> cvalue = case1.asPrismContainerValue();
    String xml;
    try {
        xml = context.prismContext.xmlSerializer().serialize(cvalue, SchemaConstantsGenerated.C_VALUE);
    } catch (SchemaException e) {
        throw new IllegalStateException("Couldn't serialize certification case to string", e);
    }
    LOGGER.trace("RAccessCertificationCase full object\n{}", xml);
    byte[] fullObject = RUtil.getByteArrayFromXml(xml, false);
    rCase.setFullObject(fullObject);
    return rCase;
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RActivation(com.evolveum.midpoint.repo.sql.data.common.embedded.RActivation) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 9 with AccessCertificationWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType 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 10 with AccessCertificationWorkItemType

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

the class CertificationTest method test340ReplaceWorkItemsNewId.

@Test
public void test340ReplaceWorkItemsNewId() throws Exception {
    OperationResult result = new OperationResult("test340ReplaceWorkItemsNewId");
    AccessCertificationWorkItemType wi250 = new AccessCertificationWorkItemType(prismContext);
    //dangerous
    wi250.setId(250L);
    wi250.setStageNumber(440);
    wi250.assigneeRef(createObjectRef("250-999999", ObjectTypes.USER));
    AccessCertificationWorkItemType wi251 = new AccessCertificationWorkItemType(prismContext);
    wi251.setId(251L);
    wi251.setStageNumber(1);
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, 6, F_WORK_ITEM).replace(wi250, wi251).asItemDeltas();
    // TODO counts
    executeAndCheckModification(modifications, result, 0);
    checkCasesForCampaign(campaign1Oid, 9, result);
    checkCasesTotal(9, result);
    checkWorkItemsForCampaign(campaign1Oid, 9, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, SECOND_NEW_CASE_ID, 1, result);
    checkWorkItemsTotal(9, result);
}
Also used : 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)

Aggregations

AccessCertificationWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)15 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)8 Test (org.testng.annotations.Test)7 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 AccessCertificationService (com.evolveum.midpoint.model.api.AccessCertificationService)3 Task (com.evolveum.midpoint.task.api.Task)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 RestartResponseException (org.apache.wicket.RestartResponseException)2 DummyResource (com.evolveum.icf.dummy.resource.DummyResource)1 OutcomeUtils (com.evolveum.midpoint.certification.api.OutcomeUtils)1 com.evolveum.midpoint.certification.impl (com.evolveum.midpoint.certification.impl)1 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)1 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1