Skip to content

Commit

Permalink
Reworking inbound expressions (MID-3542,MID-5255)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed May 3, 2019
1 parent a54970c commit 18678f4
Show file tree
Hide file tree
Showing 16 changed files with 409 additions and 188 deletions.
Expand Up @@ -62,18 +62,6 @@ public ResourceShadowDiscriminator(String resourceOid, ShadowKindType kind, Stri
setKind(kind);
}

// public ResourceShadowDiscriminator(String resourceOid, ShadowKindType kind, String intent, boolean tombstone) {
// this.resourceOid = resourceOid;
// this.tombstone = tombstone;
// setIntent(intent);
// setKind(kind);
// }
//
// public ResourceShadowDiscriminator(String resourceOid, ShadowKindType kind, String intent) {
// this(resourceOid, kind, intent, false);
// }


public ResourceShadowDiscriminator(ShadowDiscriminatorType accRefType) {
this(accRefType.getResourceRef().getOid(), accRefType.getKind(), accRefType.getIntent(), accRefType.getTag(), false);
}
Expand Down
Expand Up @@ -9268,6 +9268,18 @@
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="predefined" type="tns:ValueSetDefinitionPredefinedType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
Pre-defined set definition, such as all or none.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="condition" type="c:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -9284,6 +9296,40 @@
* reference to schema enumeration -->
</xsd:sequence>
</xsd:complexType>

<xsd:simpleType name="ValueSetDefinitionPredefinedType">
<xsd:annotation>
<xsd:documentation>
Pre-defined set definition, such as all or none.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
<a:since>4.0</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="all">
<xsd:annotation>
<xsd:documentation>
All possible elements will be part of the set.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="ALL"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="none">
<xsd:annotation>
<xsd:documentation>
No values will be part of the set.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="NONE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="ValueFilterType">
<xsd:annotation>
Expand Down
Expand Up @@ -525,7 +525,7 @@ private <F extends FocusType> void loadLinkRefsFromFocus(LensContext<F> context,
}
LensProjectionContext existingAccountContext = findAccountContext(oid, context);

if (!canBeLoaded(context, existingAccountContext)){
if (!canBeLoaded(context, existingAccountContext)) {
continue;
}

Expand Down

Large diffs are not rendered by default.

Expand Up @@ -85,87 +85,82 @@ public void test000Sanity() throws Exception {
}

@Test
public void test101ModifyUserEmployeeTypePirate() throws Exception {
final String TEST_NAME = "test101ModifyUserEmployeeTypePirate";
public void test101ModifyUserSubtypePirate() throws Exception {
final String TEST_NAME = "test101ModifyUserSubtypePirate";
displayTestTitle(TEST_NAME);

// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class,
USER_JACK_OID, UserType.F_SUBTYPE, "PIRATE");
// Make sure that the user has no employeeNumber so it will be generated by userTemplate
userDelta.addModificationReplaceProperty(UserType.F_EMPLOYEE_NUMBER);
userDelta.addModificationAddProperty(SchemaConstants.PATH_ACTIVATION_VALID_FROM, XmlTypeConverter
.createXMLGregorianCalendar(System.currentTimeMillis()));
deltas.add(userDelta);

// WHEN
displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
executeChanges(userDelta, null, task, result);

// THEN
displayThen(TEST_NAME);
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
display("User after", userJack);

PrismAsserts.assertPropertyValue(userJack, UserType.F_DESCRIPTION, "Where's the rum?");
AssignmentType pirateAssignment = assertAssignedRole(userJack, ROLE_PIRATE_GREEN_OID);
assertEquals("Wrong originMappingName", "pirate-assignment", pirateAssignment.getMetadata().getOriginMappingName());
assertAssignments(userJack, 1);

UserType userJackType = userJack.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userJackType.getLinkRef().size());

assertSuccess(result);

assertEquals("Unexpected number of organizationalUnits", 1, userJackType.getOrganizationalUnit().size());
assertEquals("Wrong organizationalUnit", PrismTestUtil.createPolyStringType("The crew of pirate"), userJackType.getOrganizationalUnit().get(0));


jackEmployeeNumber = userJackType.getEmployeeNumber();
assertNotNull("Wrong employee number. Expected not null value, got " + jackEmployeeNumber, jackEmployeeNumber);
assertSuccess(result);

jackEmployeeNumber = assertUserAfter(USER_JACK_OID)
.assertDescription("Where's the rum?")
.assignments()
.single()
.assertRole(ROLE_PIRATE_GREEN_OID)
.metadata()
.assertOriginMappingName("pirate-assignment")
.end()
.end()
.end()
.assertLinks(1)
.assertOrganizationalUnits("The crew of pirate")
.assertEmployeeNumber()
.getObject().asObjectable().getEmployeeNumber();
}

/**
* Switch employeeType from PIRATE to BUCCANEER. This makes one condition to go false and the other to go
* Switch subtype from PIRATE to BUCCANEER. This makes one condition to go false and the other to go
* true. For the same role assignement value. So nothing should be changed.
*/
@Test
public void test102ModifyUserEmployeeTypeBuccaneer() throws Exception {
final String TEST_NAME = "test102ModifyUserEmployeeTypeBuccaneer";
public void test102ModifyUserSubtypeBuccaneer() throws Exception {
final String TEST_NAME = "test102ModifyUserSubtypeBuccaneer";
displayTestTitle(TEST_NAME);

// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class,
USER_JACK_OID, UserType.F_SUBTYPE, "BUCCANEER");
deltas.add(userDelta);

// WHEN
modelService.executeChanges(deltas, null, task, result);
displayWhen(TEST_NAME);
executeChanges(userDelta, null, task, result);

// THEN
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
display("User after", userJack);

PrismAsserts.assertPropertyValue(userJack, UserType.F_DESCRIPTION, "Where's the rum?");
AssignmentType buccaneerAssignment = assertAssignedRole(userJack, ROLE_BUCCANEER_GREEN_OID);
assertEquals("Wrong originMappingName", "buccaneer-assignment", buccaneerAssignment.getMetadata().getOriginMappingName());
assertAssignments(userJack, 1);

UserType userJackType = userJack.asObjectable();
assertEquals("Unexpected number of accountRefs", 1, userJackType.getLinkRef().size());

result.computeStatus();
TestUtil.assertSuccess(result);
PrismAsserts.assertEqualsCollectionUnordered("Wrong organizationalUnit", userJackType.getOrganizationalUnit(), PrismTestUtil.createPolyStringType("The crew of buccaneer"));
assertEquals("Employee number has changed", jackEmployeeNumber, userJackType.getEmployeeNumber());
displayThen(TEST_NAME);
assertSuccess(result);

assertUserAfter(USER_JACK_OID)
.assertDescription("Where's the rum?")
.assignments()
.single()
.assertRole(ROLE_BUCCANEER_GREEN_OID)
.metadata()
.assertOriginMappingName("buccaneer-assignment")
.end()
.end()
.end()
.assertLinks(1)
.assertOrganizationalUnits("The crew of buccaneer")
.assertEmployeeNumber(jackEmployeeNumber);
}

@Test
Expand Down
Expand Up @@ -1580,8 +1580,7 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc
displayTestTitle(TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestModelServiceContract.class.getName()
+ "." + TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);

Expand All @@ -1604,12 +1603,11 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc

// WHEN
displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);
executeChanges(deltas, null, task, result);

// THEN
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
assertSuccess(result);
// There is strong mapping. Complete account is fetched.
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);

Expand All @@ -1634,7 +1632,7 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc

// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertRecords(3);
dummyAuditService.assertRecords(2);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(1);
Expand Down
Expand Up @@ -82,6 +82,8 @@ public class TestMultiAccount extends AbstractInitializedModelIntegrationTest {

private String accountMahdiOid;

private String userPaulOid;

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
Expand Down Expand Up @@ -194,8 +196,7 @@ public void test100ImportMuadDib() throws Exception {
.displayWithProjections()
.assertFullName(ACCOUNT_PAUL_ATREIDES_FULL_NAME)
.assertEmployeeNumber(ACCOUNT_PAUL_ATREIDES_ID)
// TODO
// .assertOrganizationalUnits(ACCOUNT_PAUL_ATREIDES_FULL_NAME, ACCOUNT_MUAD_DIB_FULL_NAME)
.assertOrganizationalUnits(ACCOUNT_PAUL_ATREIDES_FULL_NAME, ACCOUNT_MUAD_DIB_FULL_NAME)
.links()
.assertLinks(2)
.link(accountPaulOid)
Expand All @@ -221,6 +222,54 @@ public void test100ImportMuadDib() throws Exception {

}

@Test
public void test102ReconcileUserPaul() throws Exception {
final String TEST_NAME = "test102ReconcileUserPaul";
displayTestTitle(TEST_NAME);

// GIVEN
Task task = createTask(AbstractSynchronizationStoryTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();

userPaulOid = findUserByUsername(ACCOUNT_PAUL_ATREIDES_USERNAME).getOid();

// WHEN
displayWhen(TEST_NAME);
reconcileUser(userPaulOid, task, result);

// THEN
displayThen(TEST_NAME);

accountMuaddibOid = assertUserAfter(userPaulOid)
.displayWithProjections()
.assertFullName(ACCOUNT_PAUL_ATREIDES_FULL_NAME)
.assertEmployeeNumber(ACCOUNT_PAUL_ATREIDES_ID)
// TODO
.assertOrganizationalUnits(ACCOUNT_PAUL_ATREIDES_FULL_NAME, ACCOUNT_MUAD_DIB_FULL_NAME)
.links()
.assertLinks(2)
.link(accountPaulOid)
.resolveTarget()
.display()
.assertKind(ShadowKindType.ACCOUNT)
.assertIntent(SchemaConstants.INTENT_DEFAULT)
.assertTag(accountPaulOid)
.end()
.end()
.by()
.notTags(accountPaulOid)
.find()
.resolveTarget()
.display()
.assertKind(ShadowKindType.ACCOUNT)
.assertIntent(SchemaConstants.INTENT_DEFAULT)
.assertTagIsOid()
.getOid();

assertUsers(getNumberOfUsers() + 1);

}

/**
* Import another account that correlates to Paul. This has the same resource+kind+intent.
* But this is an admin account (title=duke). Therefore it will have different intent.
Expand Down

0 comments on commit 18678f4

Please sign in to comment.