Search in sources :

Example 6 with F_WORK_ITEM

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

the class CertificationTest method test320AddDeleteModifyResponse.

@Test
public void test320AddDeleteModifyResponse() throws Exception {
    OperationResult result = new OperationResult("test320AddDeleteModifyResponse");
    AccessCertificationWorkItemType wiNoId = new AccessCertificationWorkItemType(prismContext);
    wiNoId.assigneeRef(createObjectRef("888", ObjectTypes.USER));
    wiNoId.setStageNumber(1);
    AccessCertificationWorkItemType wi200 = new AccessCertificationWorkItemType(prismContext);
    // this is dangerous
    wi200.setId(200L);
    wi200.setStageNumber(1);
    wi200.assigneeRef(createObjectRef("200888", ObjectTypes.USER));
    AccessCertificationWorkItemType wi1 = new AccessCertificationWorkItemType();
    wi1.setId(1L);
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE, 6, F_WORK_ITEM).add(wiNoId, wi200).item(F_CASE, 6, F_WORK_ITEM).delete(wi1).item(F_CASE, 6, F_WORK_ITEM, 2, F_OUTPUT, F_OUTCOME).replace(SchemaConstants.MODEL_CERTIFICATION_OUTCOME_ACCEPT).asItemDeltas();
    executeAndCheckModification(modifications, result, 0);
    checkCasesForCampaign(campaign1Oid, 9, result);
    checkCasesTotal(9, result);
    checkWorkItemsForCampaign(campaign1Oid, 10, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, SECOND_NEW_CASE_ID, 1, result);
    checkWorkItemsTotal(10, 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 7 with F_WORK_ITEM

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

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

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

the class CertificationTest method test730CurrentUnansweredCases.

@Test
public void test730CurrentUnansweredCases() throws Exception {
    OperationResult result = new OperationResult("test730CurrentUnansweredCases");
    ObjectQuery query = QueryBuilder.queryFor(AccessCertificationCaseType.class, prismContext).item(AccessCertificationCaseType.F_STAGE_NUMBER).eq().item(T_PARENT, AccessCertificationCampaignType.F_STAGE_NUMBER).and().item(T_PARENT, F_STATE).eq(IN_REVIEW_STAGE).and().exists(F_WORK_ITEM).block().item(F_CLOSE_TIMESTAMP).isNull().and().block().item(F_OUTPUT, F_OUTCOME).isNull().endBlock().endBlock().build();
    List<AccessCertificationCaseType> cases = repositoryService.searchContainers(AccessCertificationCaseType.class, query, createCollection(createDistinct()), result);
    AccessCertificationCampaignType campaign1 = getFullCampaign(campaign1Oid, result).asObjectable();
    AccessCertificationCampaignType campaign2 = getFullCampaign(campaign2Oid, result).asObjectable();
    List<AccessCertificationCaseType> expectedCases = new ArrayList<>();
    addUnansweredActiveCases(expectedCases, campaign1.getCase(), campaign1);
    addUnansweredActiveCases(expectedCases, campaign2.getCase(), campaign2);
    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) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 10 with F_WORK_ITEM

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_WORK_ITEM 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

Test (org.testng.annotations.Test)12 AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 AccessCertificationWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 Session (org.hibernate.Session)5 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)3 Task (com.evolveum.midpoint.task.api.Task)3 WorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemType)3 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 ObjectTypeUtil.toShortString (com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString)1 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)1 WfContextType (com.evolveum.midpoint.xml.ns._public.common.common_3.WfContextType)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1