Search in sources :

Example 31 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 32 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 33 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)

Example 34 with AccessCertificationCampaignType

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

the class RAccessCertificationCampaign method copyFromJAXB.

public static void copyFromJAXB(AccessCertificationCampaignType jaxb, RAccessCertificationCampaign repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException {
    RObject.copyFromJAXB(jaxb, repo, repositoryContext, generatorResult);
    repo.setName(RPolyString.copyFromJAXB(jaxb.getName()));
    repo.setDefinitionRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getDefinitionRef(), repositoryContext.prismContext));
    List<AccessCertificationCaseType> cases = jaxb.getCase();
    if (!cases.isEmpty()) {
        for (AccessCertificationCaseType case1 : cases) {
            RAccessCertificationCase rCase = RAccessCertificationCase.toRepo(repo, case1, repositoryContext);
            // redundant?
            rCase.setTransient(generatorResult.isTransient(case1.asPrismContainerValue()));
            repo.getCase().add(rCase);
        }
    }
    repo.setOwnerRefCampaign(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getOwnerRef(), repositoryContext.prismContext));
    repo.setHandlerUri(jaxb.getHandlerUri());
    repo.setStart(jaxb.getStartTimestamp());
    repo.setEnd(jaxb.getEndTimestamp());
    repo.setState(RUtil.getRepoEnumValue(jaxb.getState(), RAccessCertificationCampaignState.class));
    repo.setStageNumber(jaxb.getStageNumber());
}
Also used : RAccessCertificationCampaignState(com.evolveum.midpoint.repo.sql.data.common.enums.RAccessCertificationCampaignState) AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) RAccessCertificationCase(com.evolveum.midpoint.repo.sql.data.common.container.RAccessCertificationCase)

Example 35 with AccessCertificationCampaignType

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

the class CertificationCaseHelper method updateLoadedCertificationCase.

// TODO find a better name
public AccessCertificationCaseType updateLoadedCertificationCase(GetContainerableResult result, Map<String, PrismObject<AccessCertificationCampaignType>> ownersMap, Collection<SelectorOptions<GetOperationOptions>> options, Session session, OperationResult operationResult) throws SchemaException {
    AccessCertificationCaseType aCase = RAccessCertificationCase.createJaxb(result.getFullObject(), prismContext, false);
    generalHelper.validateContainerable(aCase, AccessCertificationCaseType.class);
    String ownerOid = result.getOwnerOid();
    PrismObject<AccessCertificationCampaignType> campaign = resolveCampaign(ownerOid, ownersMap, session, operationResult);
    if (campaign != null && !campaign.asObjectable().getCase().contains(aCase)) {
        campaign.asObjectable().getCase().add(aCase);
    }
    return aCase;
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) 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