Search in sources :

Example 71 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestUserTemplate method test162ModifyUserGivenNameAgainPhantomChange.

@Test
public void test162ModifyUserGivenNameAgainPhantomChange() throws Exception {
    final String TEST_NAME = "test162ModifyUserGivenNameAgainPhantomChange";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    display("User before", userBefore);
    dummyAuditService.clear();
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, prismContext, // this is a phantom change
    new PolyString("JACKIE"));
    deltas.add(userDelta);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    display("User after", userJack);
    PrismAsserts.assertPropertyValue(userJack.findContainer(UserType.F_EXTENSION), PIRACY_BAD_LUCK, 123L);
    display("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(1);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertTarget(USER_JACK_OID);
    dummyAuditService.assertExecutionSuccess();
    ObjectDeltaOperation<?> objectDeltaOperation = dummyAuditService.getExecutionDelta(0);
    // givenName + modifyTimestamp
    assertEquals("unexpected number of modifications in audited delta", 2, objectDeltaOperation.getObjectDelta().getModifications().size());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 72 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class TestUserTemplate method test160ModifyUserGivenNameAgain.

@Test
public void test160ModifyUserGivenNameAgain() throws Exception {
    TestUtil.displayTestTile(this, "test160ModifyUserGivenNameAgain");
    // GIVEN
    Task task = taskManager.createTaskInstance(TestUserTemplate.class.getName() + ".test160ModifyUserGivenNameAgain");
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    ObjectDelta<UserType> userDelta = ObjectDelta.createModificationReplaceProperty(UserType.class, USER_JACK_OID, UserType.F_GIVEN_NAME, prismContext, new PolyString("JACKIE"));
    deltas.add(userDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismAsserts.assertPropertyValue(userJack.findContainer(UserType.F_EXTENSION), PIRACY_BAD_LUCK, 123L);
    display("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(2);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertTarget(USER_JACK_OID);
    dummyAuditService.assertExecutionSuccess();
    ObjectDeltaOperation<?> objectDeltaOperation = dummyAuditService.getExecutionDelta(0, ChangeType.MODIFY, UserType.class);
    // givenName + badLuck + modifyTimestamp
    assertEquals("unexpected number of modifications in audited delta", 4, objectDeltaOperation.getObjectDelta().getModifications().size());
    PropertyDelta badLuckDelta = objectDeltaOperation.getObjectDelta().findPropertyDelta(new ItemPath(UserType.F_EXTENSION, PIRACY_BAD_LUCK));
    assertNotNull("badLuck delta was not found", badLuckDelta);
    List<PrismValue> oldValues = (List<PrismValue>) badLuckDelta.getEstimatedOldValues();
    assertNotNull("badLuck delta has null estimatedOldValues field", oldValues);
    PrismAsserts.assertEqualsCollectionUnordered("badLuck delta has wrong estimatedOldValues", oldValues, new PrismPropertyValue<Long>(123L), new PrismPropertyValue<Long>(456L));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismValue(com.evolveum.midpoint.prism.PrismValue) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) List(java.util.List) ArrayList(java.util.ArrayList) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 73 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class LookupTableHelper method setupLookupTableRowsQuery.

private Criteria setupLookupTableRowsQuery(Session session, RelationalValueSearchQuery queryDef, String oid) {
    Criteria criteria = session.createCriteria(RLookupTableRow.class);
    criteria.add(Restrictions.eq("ownerOid", oid));
    if (queryDef != null && queryDef.getColumn() != null && queryDef.getSearchType() != null && StringUtils.isNotEmpty(queryDef.getSearchValue())) {
        String param = queryDef.getColumn().getLocalPart();
        String value = queryDef.getSearchValue();
        if (LookupTableRowType.F_LABEL.equals(queryDef.getColumn())) {
            param = "label.norm";
            PolyString poly = new PolyString(value);
            poly.recompute(new PrismDefaultPolyStringNormalizer());
            value = poly.getNorm();
        }
        switch(queryDef.getSearchType()) {
            case EXACT:
                criteria.add(Restrictions.eq(param, value));
                break;
            case STARTS_WITH:
                criteria.add(Restrictions.like(param, value + "%"));
                break;
            case SUBSTRING:
                criteria.add(Restrictions.like(param, "%" + value + "%"));
        }
    }
    return criteria;
}
Also used : PrismDefaultPolyStringNormalizer(com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Criteria(org.hibernate.Criteria) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 74 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class EncodingTest method toPolyString.

private PolyString toPolyString(String orig) {
    PolyString polyString = new PolyString(orig);
    polyString.recompute(prismContext.getDefaultPolyStringNormalizer());
    return polyString;
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 75 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString in project midpoint by Evolveum.

the class EncodingTest method checkUserPropertyPolyString.

private <O extends ObjectType> void checkUserPropertyPolyString(PrismObject<O> object, QName propQName, OperationResult parentResult, String... expectedValues) {
    String propName = propQName.getLocalPart();
    OperationResult result = parentResult.createSubresult(parentResult.getOperation() + "." + propName);
    PrismProperty<PolyString> prop = object.findProperty(propQName);
    Collection<PolyString> actualValues = prop.getRealValues();
    result.addArbitraryCollectionAsParam("actualValues", actualValues);
    assertMultivaluePolyString("User, property '" + propName + "'", expectedValues, actualValues, result);
    result.recordSuccessIfUnknown();
}
Also used : PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RandomString(com.evolveum.midpoint.util.RandomString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Aggregations

PolyString (com.evolveum.midpoint.prism.polystring.PolyString)168 Test (org.testng.annotations.Test)103 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)90 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)67 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)53 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)44 Task (com.evolveum.midpoint.task.api.Task)41 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)27 PrismObject (com.evolveum.midpoint.prism.PrismObject)21 QName (javax.xml.namespace.QName)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)16 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)15 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)12 ArrayList (java.util.ArrayList)12 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)10 File (java.io.File)10 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)8 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)8