Skip to content

Commit

Permalink
Document/simplify parts of TestPreviewChanges
Browse files Browse the repository at this point in the history
Also, replaced calls to .asObjectDeltaCast(..) with simple
.asObjectDelta(..). These two are now equivalent.
  • Loading branch information
mederly committed Nov 28, 2022
1 parent 0412ae6 commit 5a68a52
Show file tree
Hide file tree
Showing 23 changed files with 235 additions and 226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testAssignmentNullIdApplyToObject() throws Exception {
.description("jamalalicha patlama paprtala");
ObjectDelta<UserType> userDelta = getPrismContext().deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT).add(a)
.asObjectDeltaCast(USER_JACK_OID);
.asObjectDelta(USER_JACK_OID);

// WHEN
userDelta.applyTo(user);
Expand All @@ -74,7 +74,7 @@ public void testAddInducementNullIdApplyToObject() throws Exception {
.description("jamalalicha patlama paprtala");
ObjectDelta<RoleType> roleDelta = getPrismContext().deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT).add(i)
.asObjectDeltaCast(ROLE_CONSTRUCTION_OID);
.asObjectDelta(ROLE_CONSTRUCTION_OID);

// WHEN
roleDelta.applyTo(role);
Expand Down Expand Up @@ -287,7 +287,7 @@ public void testAddAssignmentSameOidDifferentTargetType() throws Exception {
ObjectDelta<UserType> userDelta = getPrismContext().deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT)
.add(new AssignmentType().id(2L).targetRef("target-oid-1", OrgType.COMPLEX_TYPE))
.asObjectDeltaCast("oid1");
.asObjectDelta("oid1");

// WHEN
userDelta.applyTo(user);
Expand Down Expand Up @@ -338,7 +338,7 @@ public void testSubtractAssignmentFromModifyDelta() throws Exception {
assignment9999.setId(9999L);
ObjectDelta<UserType> delta = getPrismContext().deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT).delete(assignment9999)
.asObjectDeltaCast(user.getOid());
.asObjectDelta(user.getOid());

// WHEN
PrismContainerDefinition<AssignmentType> assignmentDef = PrismTestUtil.getSchemaRegistry()
Expand Down Expand Up @@ -460,7 +460,7 @@ public void testFactorModifyDeltaForItem() throws Exception {
.add(ObjectTypeUtil.createAssignmentTo("oid-r", ObjectTypes.ROLE, getPrismContext()))
.item(UserType.F_ASSIGNMENT, 100L, AssignmentType.F_LIFECYCLE_STATE).replace("draft")
.item(UserType.F_GIVEN_NAME).replace("bill")
.asObjectDeltaCast(OID);
.asObjectDelta(OID);

// WHEN
ObjectDelta.FactorOutResultSingle<UserType> out = delta.factorOut(singleton(ItemPath.create(UserType.F_ASSIGNMENT)), true);
Expand Down Expand Up @@ -491,7 +491,7 @@ public void testFactorModifyDeltaForItemValues() throws Exception {
.item(UserType.F_ASSIGNMENT, 100L, AssignmentType.F_DESCRIPTION).replace("descr")
.item(UserType.F_ASSIGNMENT, 77L, AssignmentType.F_LIFECYCLE_STATE).replace("active")
.item(UserType.F_GIVEN_NAME).replace("bill")
.asObjectDeltaCast(OID);
.asObjectDelta(OID);

// WHEN
ObjectDelta.FactorOutResultMulti<UserType> out = delta.factorOutValues(ItemPath.create(UserType.F_ASSIGNMENT), true);
Expand Down Expand Up @@ -529,15 +529,15 @@ public void testObjectDeltaUnion() throws Exception {
// GIVEN
ProtectedStringType value = new ProtectedStringType();
value.setClearValue("hi");
PasswordType newPassword = new PasswordType(getPrismContext()).value(value);
PasswordType newPassword = new PasswordType().value(value);
ObjectDelta<UserType> userDelta1 = getPrismContext().deltaFor(UserType.class)
.item(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD).replace(newPassword)
.asObjectDeltaCast("001");
MetadataType newMetadata = new MetadataType(getPrismContext()).requestorComment("comment");
.asObjectDelta("001");
MetadataType newMetadata = new MetadataType().requestorComment("comment");
ObjectDelta<UserType> userDelta2 = getPrismContext().deltaFor(UserType.class)
.item(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_METADATA)
.add(newMetadata)
.asObjectDeltaCast("001");
.asObjectDelta("001");

// WHEN
ObjectDelta<UserType> userDeltaUnion = ObjectDeltaCollectionsUtil.union(userDelta1, userDelta2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void test100ApplyNameDelta() throws Exception {
PrismObject<UserType> temp = jack.clone();
ObjectDelta<UserType> delta = getPrismContext().deltaFor(UserType.class)
.item(UserType.F_NAME).replace("jjj")
.asObjectDeltaCast(temp.getOid());
.asObjectDelta(temp.getOid());
measure("delta.applyTo.name",
"Applies name change delta to jack",
() -> { delta.applyTo(temp); return true; });
Expand All @@ -47,7 +47,7 @@ public void test102ApplyPasswordValueDelta() throws Exception {
PrismObject<UserType> temp = jack.clone();
ObjectDelta<UserType> delta = getPrismContext().deltaFor(UserType.class)
.item(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE).replace("cleartext")
.asObjectDeltaCast(temp.getOid());
.asObjectDelta(temp.getOid());
measure("delta.applyTo.credentials",
"Applies credentials change delta to jack",
() -> { delta.applyTo(temp); return true; });
Expand All @@ -64,7 +64,7 @@ public void test104ApplyExtensionItemDelta() throws Exception {
PrismObject<UserType> temp = jack.clone();
ObjectDelta<UserType> delta = getPrismContext().deltaFor(UserType.class)
.item(ItemPath.create(UserType.F_EXTENSION, "bar23"), def("bar23")).replace("bbb")
.asObjectDeltaCast(temp.getOid());
.asObjectDelta(temp.getOid());
measure("delta.applyTo(jack)", "", () -> { delta.applyTo(temp); return true; });
PrismObject<UserType> jack2 = jack.clone();
delta.applyTo(jack2);
Expand All @@ -81,7 +81,7 @@ public void test110ApplyDeltaWith5Modifications() throws Exception {
.item(ItemPath.create(UserType.F_EXTENSION, "bar23"), def("bar23")).replace("bbb")
.item(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE).replace("cleartext")
.item(UserType.F_ADMIN_GUI_CONFIGURATION).replace(new AdminGuiConfigurationType(getPrismContext()))
.asObjectDeltaCast(temp.getOid());
.asObjectDelta(temp.getOid());
measure("delta.applyTo.5mod",
"Applies 5 modification delta to jack",
() -> { delta.applyTo(temp); return true; });
Expand Down Expand Up @@ -132,7 +132,7 @@ public void test120ApplyDeltaWith30Modifications() throws Exception {
.item(ItemPath.create(UserType.F_EXTENSION, "bar27"), def("bar27")).replace("bbb")
.item(ItemPath.create(UserType.F_EXTENSION, "bar28"), def("bar28")).replace("bbb")
.item(ItemPath.create(UserType.F_EXTENSION, "bar29"), def("bar29")).replace("bbb")
.asObjectDeltaCast(temp.getOid());
.asObjectDelta(temp.getOid());
measure("delta.applyTo.30mod",
"Applies delta with 30 modifications",
() -> { delta.applyTo(temp); return true; });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private void activateRole(String oid, Holder<LensContext<?>> contextHolder, Task
ObjectDelta<RoleType> delta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_LIFECYCLE_STATE)
.replace(SchemaConstants.LIFECYCLE_ACTIVE)
.asObjectDeltaCast(oid);
.asObjectDelta(oid);
RecordingProgressListener listener = new RecordingProgressListener();
try {
modelService.executeChanges(singleton(delta), null, task, singleton(listener), result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ public void test400UserFred() throws Exception {

ObjectDelta<UserType> descriptionDelta = prismContext.deltaFor(UserType.class)
.item(UserType.F_DESCRIPTION).replace(pastTime)
.asObjectDeltaCast(fredAsCreated.getOid());
.asObjectDelta(fredAsCreated.getOid());

LensContext<UserType> lensContext = createUserLensContext();
fillContextWithUser(lensContext, fredAsCreated.getOid(), result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public void test300ModifyInducement() throws Exception {

ObjectDelta<RoleType> delta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT, 1L, AssignmentType.F_DESCRIPTION).replace("hi")
.asObjectDeltaCast(roleImmutableInducementsOid);
.asObjectDelta(roleImmutableInducementsOid);
LensContext<RoleType> context = createLensContext(RoleType.class);
context.createFocusContext().setPrimaryDelta(delta);
displayDumpable("Input context", context);
Expand Down Expand Up @@ -806,7 +806,7 @@ public void test310ModifyInducementPass() throws Exception {

ObjectDelta<RoleType> delta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT, 1L, AssignmentType.F_DESCRIPTION).replace("hi")
.asObjectDeltaCast(roleNoInducementsAddDeleteOid);
.asObjectDelta(roleNoInducementsAddDeleteOid);
LensContext<RoleType> context = createLensContext(RoleType.class);
context.createFocusContext().setPrimaryDelta(delta);
displayDumpable("Input context", context);
Expand All @@ -832,7 +832,7 @@ public void test320ModifyInducementPass2() throws Exception {

ObjectDelta<RoleType> delta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT, 1L, AssignmentType.F_DESCRIPTION).replace("hi")
.asObjectDeltaCast(roleNoInducementsAddDeleteViaExpressionOid);
.asObjectDelta(roleNoInducementsAddDeleteViaExpressionOid);
LensContext<RoleType> context = createLensContext(RoleType.class);
context.createFocusContext().setPrimaryDelta(delta);
displayDumpable("Input context", context);
Expand All @@ -858,7 +858,7 @@ public void test330AddInducement() throws Exception {

ObjectDelta<RoleType> delta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT).add(new AssignmentType(prismContext).targetRef("1", OrgType.COMPLEX_TYPE))
.asObjectDeltaCast(roleNoInducementsAddDeleteOid);
.asObjectDelta(roleNoInducementsAddDeleteOid);
LensContext<RoleType> context = createLensContext(RoleType.class);
context.createFocusContext().setPrimaryDelta(delta);
displayDumpable("Input context", context);
Expand Down Expand Up @@ -890,8 +890,8 @@ public void test340AddInducementViaExpression() throws Exception {
OperationResult result = task.getResult();

ObjectDelta<RoleType> delta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_INDUCEMENT).replace(new AssignmentType(prismContext).targetRef("1", OrgType.COMPLEX_TYPE))
.asObjectDeltaCast(roleNoInducementsAddDeleteViaExpressionOid);
.item(RoleType.F_INDUCEMENT).replace(new AssignmentType().targetRef("1", OrgType.COMPLEX_TYPE))
.asObjectDelta(roleNoInducementsAddDeleteViaExpressionOid);
LensContext<RoleType> context = createLensContext(RoleType.class);
context.createFocusContext().setPrimaryDelta(delta);
displayDumpable("Input context", context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void test130JackUnassignRolePirate() throws Exception {
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT)
.delete(pirateAssignment.clone())
.asObjectDeltaCast(USER_JACK_OID);
.asObjectDelta(USER_JACK_OID);
executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult());

// THEN
Expand Down Expand Up @@ -205,7 +205,7 @@ public void test200BobAssign2a3a() throws Exception {
.item(UserType.F_ASSIGNMENT)
.add(createAssignmentTo(roleATest2aOid, ObjectTypes.ROLE, prismContext),
createAssignmentTo(roleATest3aOid, ObjectTypes.ROLE, prismContext))
.asObjectDeltaCast(userBobOid);
.asObjectDelta(userBobOid);
executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult());

// THEN
Expand Down Expand Up @@ -238,7 +238,7 @@ public void test210BobAssign2b3b() throws Exception {
.item(UserType.F_ASSIGNMENT)
.add(createAssignmentTo(roleATest2bOid, ObjectTypes.ROLE, prismContext),
createAssignmentTo(roleATest3bOid, ObjectTypes.ROLE, prismContext))
.asObjectDeltaCast(userBobOid);
.asObjectDelta(userBobOid);
executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult());

// THEN
Expand Down Expand Up @@ -383,7 +383,7 @@ public void test250EveAssign2b() throws Exception {
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT)
.add(assignment2b)
.asObjectDeltaCast(userEveOid);
.asObjectDelta(userEveOid);
executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult());

// THEN
Expand Down Expand Up @@ -412,7 +412,7 @@ public void test300MakeRoleWrong() throws Exception {
when();
ObjectDelta<RoleType> delta = prismContext.deltaFor(RoleType.class)
.item(RoleType.F_DESCRIPTION).replace("wrong")
.asObjectDeltaCast(roleATestWrongOid);
.asObjectDelta(roleATestWrongOid);
executeChangesAssertSuccess(delta, null, getTestTask(), getTestOperationResult());

// THEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public void test150ModifyUserJackModifyAssignment() throws Exception {
prismContext.deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT, id, AssignmentType.F_DESCRIPTION)
.replace("hi")
.asObjectDeltaCast(jack.getOid()), null, task, result);
.asObjectDelta(jack.getOid()), null, task, result);

then();
result.computeStatus();
Expand Down Expand Up @@ -501,7 +501,7 @@ public void test160ModifyUserJackDeleteAssignment() throws Exception {
prismContext.deltaFor(UserType.class)
.item(UserType.F_ASSIGNMENT)
.delete(new AssignmentType().id(id))
.asObjectDeltaCast(jack.getOid()), null, task, result);
.asObjectDelta(jack.getOid()), null, task, result);

then();
result.computeStatus();
Expand Down

0 comments on commit 5a68a52

Please sign in to comment.