Search in sources :

Example 76 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString 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 77 with PolyString

use of com.evolveum.midpoint.prism.polystring.PolyString 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)

Example 78 with PolyString

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

the class LookupTableTest method test230ModifyTableAndRow.

@Test
public void test230ModifyTableAndRow() throws Exception {
    OperationResult result = new OperationResult("test230ModifyTableAndRow");
    List<ItemDelta<?, ?>> modifications = DeltaBuilder.deltaFor(LookupTableType.class, prismContext).item(F_NAME).replace(new PolyString("Table 111", "table 111")).item(F_ROW, 2, F_KEY).replace("key 2").asItemDeltas();
    executeAndCheckModification(modifications, result, 1, Arrays.asList("key 2"));
}
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)

Example 79 with PolyString

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

the class UserProfileServiceMock method findByUsername.

private PrismObject<UserType> findByUsername(String username, OperationResult result) throws SchemaException, ObjectNotFoundException {
    PolyString usernamePoly = new PolyString(username);
    ObjectQuery query = ObjectQueryUtil.createNormNameQuery(usernamePoly, prismContext);
    LOGGER.trace("Looking for user, query:\n" + query.debugDump());
    List<PrismObject<UserType>> list = repositoryService.searchObjects(UserType.class, query, null, result);
    LOGGER.trace("Users found: {}.", (list != null ? list.size() : 0));
    if (list == null || list.size() != 1) {
        return null;
    }
    return list.get(0);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 80 with PolyString

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

the class AbstractIntegrationTest method assertShadowCommon.

protected void assertShadowCommon(PrismObject<ShadowType> shadow, String oid, String username, ResourceType resourceType, QName objectClass, final MatchingRule<String> nameMatchingRule, boolean requireNormalizedIdentfiers, boolean useMatchingRuleForShadowName) throws SchemaException {
    assertShadow(shadow);
    if (oid != null) {
        assertEquals("Shadow OID mismatch (prism)", oid, shadow.getOid());
    }
    ShadowType resourceObjectShadowType = shadow.asObjectable();
    if (oid != null) {
        assertEquals("Shadow OID mismatch (jaxb)", oid, resourceObjectShadowType.getOid());
    }
    assertEquals("Shadow objectclass", objectClass, resourceObjectShadowType.getObjectClass());
    assertEquals("Shadow resourceRef OID", resourceType.getOid(), shadow.asObjectable().getResourceRef().getOid());
    PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    assertNotNull("Null attributes in shadow for " + username, attributesContainer);
    assertFalse("Empty attributes in shadow for " + username, attributesContainer.isEmpty());
    if (useMatchingRuleForShadowName) {
        MatchingRule<PolyString> polyMatchingRule = new MatchingRule<PolyString>() {

            @Override
            public QName getName() {
                return nameMatchingRule.getName();
            }

            @Override
            public boolean isSupported(QName xsdType) {
                return nameMatchingRule.isSupported(xsdType);
            }

            @Override
            public boolean match(PolyString a, PolyString b) throws SchemaException {
                return nameMatchingRule.match(a.getOrig(), b.getOrig());
            }

            @Override
            public boolean matchRegex(PolyString a, String regex) throws SchemaException {
                return nameMatchingRule.matchRegex(a.getOrig(), regex);
            }

            @Override
            public PolyString normalize(PolyString original) throws SchemaException {
                return new PolyString(nameMatchingRule.normalize(original.getOrig()));
            }
        };
        PrismAsserts.assertPropertyValueMatch(shadow, ShadowType.F_NAME, polyMatchingRule, PrismTestUtil.createPolyString(username));
    } else {
        PrismAsserts.assertPropertyValue(shadow, ShadowType.F_NAME, PrismTestUtil.createPolyString(username));
    }
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(objectClass);
    if (ocDef.getSecondaryIdentifiers().isEmpty()) {
        ResourceAttributeDefinition idDef = ocDef.getPrimaryIdentifiers().iterator().next();
        PrismProperty<String> idProp = attributesContainer.findProperty(idDef.getName());
        assertNotNull("No primary identifier (" + idDef.getName() + ") attribute in shadow for " + username, idProp);
        if (nameMatchingRule == null) {
            assertEquals("Unexpected primary identifier in shadow for " + username, username, idProp.getRealValue());
        } else {
            if (requireNormalizedIdentfiers) {
                assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue());
            } else {
                PrismAsserts.assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue());
            }
        }
    } else {
        ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next();
        PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName());
        assertNotNull("No secondary identifier (" + idSecDef.getName() + ") attribute in shadow for " + username, idProp);
        if (nameMatchingRule == null) {
            assertEquals("Unexpected secondary identifier in shadow for " + username, username, idProp.getRealValue());
        } else {
            if (requireNormalizedIdentfiers) {
                assertEquals("Unexpected secondary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue());
            } else {
                PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue());
            }
        }
    }
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Containerable(com.evolveum.midpoint.prism.Containerable) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule)

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