Search in sources :

Example 66 with ItemDelta

use of com.evolveum.midpoint.prism.delta.ItemDelta 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 67 with ItemDelta

use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.

the class CertificationTest method test240AddCases.

@Test
public void test240AddCases() throws Exception {
    OperationResult result = new OperationResult("test240AddDeleteCases");
    AccessCertificationCaseType caseNoId = new AccessCertificationCaseType(prismContext);
    caseNoId.setObjectRef(createObjectRef("123", ObjectTypes.USER));
    caseNoId.setTargetRef(createObjectRef("456", ObjectTypes.ROLE));
    caseNoId.setStageNumber(1);
    // explicit ID is dangerous (possibility of conflict!)
    AccessCertificationCaseType case100 = new AccessCertificationCaseType(prismContext);
    case100.setId(NEW_CASE_ID);
    case100.setObjectRef(createObjectRef("100123", ObjectTypes.USER));
    case100.setTargetRef(createObjectRef("100456", ObjectTypes.ROLE));
    case100.beginWorkItem().assigneeRef(createObjectRef("ref1", ObjectTypes.USER)).end();
    case100.setStageNumber(1);
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_CASE).add(caseNoId, case100).asItemDeltas();
    executeAndCheckModification(modifications, result, 0);
    checkCasesForCampaign(campaign1Oid, 9, result);
    checkCasesTotal(9, result);
    checkWorkItemsForCampaign(campaign1Oid, 11, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 1, 2, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, 2, 1, result);
    checkWorkItemsForCampaignAndCase(campaign1Oid, NEW_CASE_ID, 1, result);
    checkWorkItemsTotal(11, 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) Test(org.testng.annotations.Test)

Example 68 with ItemDelta

use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.

the class CertificationTest method test230ModifyAllLevels.

@Test
public void test230ModifyAllLevels() throws Exception {
    OperationResult result = new OperationResult("test230ModifyAllLevels");
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext).item(F_NAME).replace(new PolyString("Campaign 2", "campaign 2")).item(F_STATE).replace(IN_REMEDIATION).item(F_CASE, 2, F_CURRENT_STAGE_OUTCOME).replace(SchemaConstants.MODEL_CERTIFICATION_OUTCOME_NO_RESPONSE).item(F_CASE, 2, AccessCertificationCaseType.F_STAGE_NUMBER).replace(400).item(F_CASE, 1, F_WORK_ITEM, 1, F_OUTPUT).replace(new AbstractWorkItemOutputType().outcome(SchemaConstants.MODEL_CERTIFICATION_OUTCOME_NOT_DECIDED).comment("low")).asItemDeltas();
    executeAndCheckModification(modifications, result, 1);
    checksCountsStandard(result);
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) Test(org.testng.annotations.Test)

Example 69 with ItemDelta

use of com.evolveum.midpoint.prism.delta.ItemDelta 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 70 with ItemDelta

use of com.evolveum.midpoint.prism.delta.ItemDelta in project midpoint by Evolveum.

the class LookupTableTest method test210ModifyRowProperties.

@Test
public void test210ModifyRowProperties() throws Exception {
    OperationResult result = new OperationResult("test210ModifyRowProperties");
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(LookupTableType.class, prismContext).item(F_ROW, 1, F_KEY).replace("key 1").item(F_ROW, 2, F_VALUE).replace().item(F_ROW, 3, F_LABEL).replace(new PolyString("label 3")).item(F_ROW, 3, F_LAST_CHANGE_TIMESTAMP).replace(XmlTypeConverter.createXMLGregorianCalendar(new Date(99, 10, 10))).asItemDeltas();
    executeAndCheckModification(modifications, result, 0, Arrays.asList("key 1", "2 key"));
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test)

Aggregations

ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)185 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)87 Test (org.testng.annotations.Test)66 ArrayList (java.util.ArrayList)64 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)56 Task (com.evolveum.midpoint.task.api.Task)40 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)33 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)30 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)26 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)21 QName (javax.xml.namespace.QName)21 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)20 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)19 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)15 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)14 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)14 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)14 PrismObject (com.evolveum.midpoint.prism.PrismObject)13 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)12