Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Nov 8, 2021
2 parents a0b8b89 + 64513a0 commit 6a48e64
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public Component getComponent() {

@Override
public StringResourceModel getTitle() {
return new StringResourceModel("");
return new StringResourceModel("").setDefaultValue("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* Testing bushy role hierarchy. Especially reuse of the same role
* in the rich role hierarchy. It looks like this:
*
* <pre>
* ----
* user
* |
* +------+------+-----+-----+-....
Expand All @@ -52,7 +52,7 @@
* | | | | |
* v v v v v
* Rb1 Rb2 Rb3 Rb4 Rb5
* </pre>
* ----
*
* Naive mode of evaluation would imply cartesian product of all Rax and Rbx
* combinations. That's painfully inefficient. Therefore make sure that the
Expand All @@ -69,17 +69,20 @@ public abstract class AbstractNotoriousTest extends AbstractStoryTest {

private static final int NUMBER_OF_ORDINARY_ROLES = 1; // including superuser role

protected static final int NUMBER_OF_LEVEL_A_ROLES = 100;
protected static final String ROLE_LEVEL_A_NAME_FORMAT = "Role A %06d";
protected static final String ROLE_LEVEL_A_SUBTYPE = "levelA";
protected static final String ROLE_LEVEL_A_OID_FORMAT = "00000000-0000-ffff-2a00-000000%06d";
private static final int NUMBER_OF_LEVEL_A_ROLES = 100;
private static final String ROLE_LEVEL_A_NAME_FORMAT = "Role A %06d";
private static final String ROLE_LEVEL_A_SUBTYPE = "levelA";
private static final String ROLE_LEVEL_A_OID_FORMAT = "00000000-0000-ffff-2a00-000000%06d";

protected static final int NUMBER_OF_LEVEL_B_ROLES = 300;
protected static final String ROLE_LEVEL_B_NAME_FORMAT = "Role B %06d";
protected static final String ROLE_LEVEL_B_ROLETYPE = "levelB";
protected static final String ROLE_LEVEL_B_OID_FORMAT = "00000000-0000-ffff-2b00-000000%06d";
static final int NUMBER_OF_LEVEL_B_ROLES = 300;
private static final String ROLE_LEVEL_B_NAME_FORMAT = "Role B %06d";
static final String ROLE_LEVEL_B_ROLETYPE = "levelB";
private static final String ROLE_LEVEL_B_OID_FORMAT = "00000000-0000-ffff-2b00-000000%06d";

protected CountingInspector inspector;
/** How many times the projector runs per single clockwork run. */
static final int PROJECTOR_PER_CLOCKWORK = 2;

CountingInspector inspector;

protected abstract String getNotoriousOid();

Expand Down Expand Up @@ -124,7 +127,7 @@ protected void fillLevelBRole(RoleType roleType, int i) {
roleType.subtype(ROLE_LEVEL_B_ROLETYPE);
}

protected void fillNotorious(AbstractRoleType roleType) {
void fillNotorious(AbstractRoleType roleType) {
for (int i = 0; i < NUMBER_OF_LEVEL_B_ROLES; i++) {
roleType.beginInducement()
.targetRef(generateRoleBOid(i), RoleType.COMPLEX_TYPE)
Expand Down Expand Up @@ -181,8 +184,8 @@ public void test100AssignRa0ToJack() throws Exception {

assertRoleEvaluationCount(1, 0);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -210,7 +213,7 @@ public void test102RecomputeJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -274,7 +277,7 @@ public void test109UnassignRa0FromJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -302,7 +305,7 @@ public void test110Assign5ARolesToJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 1 + 5));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 1 + 5) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -330,7 +333,7 @@ public void test112RecomputeJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 1 + 5));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 1 + 5) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -359,7 +362,7 @@ public void test119Unassign5ARolesFromJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 1 + 5));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 1 + 5) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -387,7 +390,7 @@ public void test120AssignAllARolesToJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 1 + NUMBER_OF_LEVEL_A_ROLES));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 1 + NUMBER_OF_LEVEL_A_ROLES) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -415,7 +418,7 @@ public void test122RecomputeJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 1 + NUMBER_OF_LEVEL_A_ROLES));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 1 + NUMBER_OF_LEVEL_A_ROLES) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -479,7 +482,7 @@ public void test129UnassignAllARolesFromJack() throws Exception {

displayCountersAndInspector();

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 1 + NUMBER_OF_LEVEL_A_ROLES));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 1 + NUMBER_OF_LEVEL_A_ROLES) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -510,14 +513,14 @@ public void test130AssignRb0ToJack() throws Exception {

assertRoleEvaluationCount(0, 1);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

/**
* Now jack has RoleB0 assigned in two ways: directly and through RA0->notorious->RB0
* This may cause problems e.g. for supernotorious roles where the direct assignment
* This may cause problems e.g. for super-notorious roles where the direct assignment
* may cause evaluation of notorious role as metarole. And then the second evaluation
* may be skipped. Which is wrong.
*/
Expand Down Expand Up @@ -548,8 +551,8 @@ public void test132AssignRa0ToJack() throws Exception {

assertRoleEvaluationCount(1, 1);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2 + 1));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2 + 1) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -579,7 +582,7 @@ public void test134RecomputeJack() throws Exception {

assertRoleEvaluationCount(1, 1);

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2 + 1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2 + 1) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -610,8 +613,8 @@ public void test136UnassignRb0FromJack() throws Exception {

assertRoleEvaluationCount(1, 1);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2 + 1));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2 + 1) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -642,8 +645,8 @@ public void test138AssignRb0ToJackAgain() throws Exception {

assertRoleEvaluationCount(1, 1);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2 + 1));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2 + 1) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -673,7 +676,7 @@ public void test140RecomputeJackAgain() throws Exception {

assertRoleEvaluationCount(1, 1);

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2 + 1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2 + 1) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -704,7 +707,7 @@ public void test142RecomputeJackAlt() throws Exception {

assertRoleEvaluationCount(1, 1);

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2 + 1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2 + 1) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -735,8 +738,8 @@ public void test144UnassignRa0FromJack() throws Exception {

assertRoleEvaluationCount(1, 1);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(NUMBER_OF_LEVEL_B_ROLES + 2 + 1));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (NUMBER_OF_LEVEL_B_ROLES + 2 + 1) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -768,8 +771,8 @@ public void test149UnassignRb0FromJack() throws Exception {

assertRoleEvaluationCount(0, 1);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -805,8 +808,8 @@ public void test150AssignNotoriousDefaultToJack() throws Exception {

assertRoleEvaluationCount(1, 0);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(1 + NUMBER_OF_LEVEL_B_ROLES));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (1 + NUMBER_OF_LEVEL_B_ROLES) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -849,8 +852,23 @@ public void test152AssignNotoriousAltRelationToJack() throws Exception {

assertRoleEvaluationCount(2, 0);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify2(1 + NUMBER_OF_LEVEL_B_ROLES));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);

// How many times an abstract role (notorious + B-level) is evaluated for the existing assignment
int expectedEvaluationsForExistingAssignment = (1 + NUMBER_OF_LEVEL_B_ROLES) * PROJECTOR_PER_CLOCKWORK;

// How many times an abstract role (notorious + B-level) is evaluated for the assignment being added.
// The expected value differs for "member-like" (org:manager) and "non member-like" (org:owner) relations.
// The non member-like relations are evaluated only when going into "plus" set, i.e. during the first projector run.
// (It is different from the situation when they are being unassigned, see test159. It should be consolidated
// somehow, see AssignmentTripleEvaluator#processReallyUnchangedAssignment and MID-6403) The member-like
// relations are evaluated during each projector run.
int expectedEvaluationsForNewAssignment = (1 + NUMBER_OF_LEVEL_B_ROLES) *
(relationRegistry.isMember(getAltRelation()) ? PROJECTOR_PER_CLOCKWORK : 1);

assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT,
expectedEvaluationsForExistingAssignment + expectedEvaluationsForNewAssignment);

assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -887,8 +905,8 @@ public void test154RecomputeJack() throws Exception {

assertRoleEvaluationCount(2, 0);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(getTest15xRoleEvaluationIncrement()));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, getTest15xRoleEvaluationIncrement() * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -929,8 +947,8 @@ public void test156RecomputeJackAlt() throws Exception {

assertRoleEvaluationCount(2, 0);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(getTest15xRoleEvaluationIncrement()));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, getTest15xRoleEvaluationIncrement() * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -962,8 +980,8 @@ public void test158UnassignNotoriousDefaultFromJack() throws Exception {

assertRoleEvaluationCount(2, 1);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify(getTest15xRoleEvaluationIncrement()));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, getTest15xRoleEvaluationIncrement() * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -1001,8 +1019,8 @@ public void test159UnassignNotoriousAltRelationFromJack() throws Exception {

assertRoleEvaluationCount(1, 0);

assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, hackify(1));
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, hackify1((1 + NUMBER_OF_LEVEL_B_ROLES)));
assertCounterIncrement(InternalCounters.PROJECTOR_RUN_COUNT, PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.ROLE_EVALUATION_COUNT, (1 + NUMBER_OF_LEVEL_B_ROLES) * PROJECTOR_PER_CLOCKWORK);
assertCounterIncrement(InternalCounters.PRISM_OBJECT_COMPARE_COUNT, 0);
}

Expand Down Expand Up @@ -1038,6 +1056,7 @@ private void assertJackRoleAMembershipRef(PrismObject<UserType> user, int number
assertRoleMembershipRefs(user, numberOfLevelARoles + 1 + NUMBER_OF_LEVEL_B_ROLES);
}

@SuppressWarnings("SameParameterValue")
private void assertRoleMembershipRefs(PrismObject<UserType> user, String oidFormat, int num, QName relation) {
for (int i = 0; i < num; i++) {
assertRoleMembershipRefNonExclusive(user, generateRoleOid(oidFormat, i), RoleType.COMPLEX_TYPE, relation);
Expand All @@ -1058,11 +1077,11 @@ protected void assertRoleEvaluationCount(int numberOfLevelAAssignments, int numb
// for subclasses
}

protected void assertNoNotoriousParentOrgRef(PrismObject<UserType> userAfter) {
private void assertNoNotoriousParentOrgRef(PrismObject<UserType> userAfter) {
assertHasNoOrg(userAfter, getNotoriousOid());
}

protected void assertNotoriousParentOrgRef(PrismObject<UserType> userAfter) {
private void assertNotoriousParentOrgRef(PrismObject<UserType> userAfter) {
assertNotoriousParentOrgRefRelations(userAfter, SchemaConstants.ORG_DEFAULT);
}

Expand All @@ -1088,17 +1107,4 @@ private void displayCountersAndInspector() {
InternalCounters.PRISM_OBJECT_COMPARE_COUNT);
displayDumpable("Inspector", inspector);
}

protected int hackify(int i) {
// TODO: projector now runs two times instead of one.
return i * 2;
}

protected int hackify2(int i) {
return i * 4;
}

protected int hackify1(int i) {
return hackify(i);
}
}

0 comments on commit 6a48e64

Please sign in to comment.