Search in sources :

Example 91 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class ModelDiagController method repositorySelfTestLookupTable.

private void repositorySelfTestLookupTable(Task task, OperationResult testResult) {
    OperationResult result = testResult.createSubresult(REPOSITORY_SELF_TEST_LOOKUP_TABLE);
    PrismObject<LookupTableType> lookupTable;
    try {
        lookupTable = getObjectDefinition(LookupTableType.class).instantiate();
    } catch (SchemaException e) {
        result.recordFatalError(e);
        return;
    }
    LookupTableType lookupTableType = lookupTable.asObjectable();
    String name = generateRandomName();
    PolyStringType namePolyStringType = toPolyStringType(name);
    lookupTableType.setName(namePolyStringType);
    result.addContext("name", name);
    lookupTableType.setDescription(SelfTestData.POLICIJA);
    LookupTableRowType rowType = new LookupTableRowType(prismContext);
    rowType.setKey(INSANE_NATIONAL_STRING);
    rowType.setValue(INSANE_NATIONAL_STRING);
    rowType.setLabel(toPolyStringType(INSANE_NATIONAL_STRING));
    lookupTableType.getRow().add(rowType);
    String oid;
    try {
        oid = repositoryService.addObject(lookupTable, null, result);
    } catch (ObjectAlreadyExistsException | SchemaException | RuntimeException e) {
        result.recordFatalError(e);
        return;
    }
    try {
        {
            OperationResult subresult = result.createSubresult(result.getOperation() + ".getObject");
            PrismObject<LookupTableType> lookupTableRetrieved;
            try {
                Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(LookupTableType.F_ROW, GetOperationOptions.createRetrieve());
                lookupTableRetrieved = repositoryService.getObject(LookupTableType.class, oid, options, subresult);
            } catch (ObjectNotFoundException | SchemaException | RuntimeException e) {
                result.recordFatalError(e);
                return;
            }
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Self-test:lookupTable getObject:\n{}", lookupTableRetrieved.debugDump());
            }
            checkLookupTable(lookupTableRetrieved, name, subresult);
            subresult.recordSuccessIfUnknown();
        }
        {
            OperationResult subresult = result.createSubresult(result.getOperation() + ".getObject.key");
            try {
                RelationalValueSearchQuery subquery = new RelationalValueSearchQuery(LookupTableRowType.F_KEY, INSANE_NATIONAL_STRING, RelationalValueSearchType.EXACT);
                Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(subquery));
                PrismObject<LookupTableType> lookupTableRetrieved = repositoryService.getObject(LookupTableType.class, oid, options, result);
                subresult.addParam("subquery", subquery);
                if (LOGGER.isTraceEnabled()) {
                    LOGGER.trace("Self-test:lookupTable getObject by row key:\n{}", DebugUtil.debugDump(lookupTableRetrieved));
                }
                checkLookupTable(lookupTableRetrieved, name, subresult);
                subresult.recordSuccessIfUnknown();
            } catch (ObjectNotFoundException | SchemaException | RuntimeException e) {
                subresult.recordFatalError(e);
                return;
            }
        }
    } finally {
        try {
            repositoryService.deleteObject(LookupTableType.class, oid, testResult);
        } catch (ObjectNotFoundException | RuntimeException e) {
            result.recordFatalError(e);
            return;
        }
        result.computeStatus();
    }
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RandomString(com.evolveum.midpoint.util.RandomString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) Collection(java.util.Collection)

Example 92 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class MidpointFunctionsImpl method createEmptyObjectWithName.

@Override
public <T extends ObjectType> T createEmptyObjectWithName(Class<T> type, PolyString name) throws SchemaException {
    T objectType = createEmptyObject(type);
    objectType.setName(new PolyStringType(name));
    return objectType;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType)

Example 93 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class MidpointFunctionsImpl method createEmptyObjectWithName.

@Override
public <T extends ObjectType> T createEmptyObjectWithName(Class<T> type, String name) throws SchemaException {
    T objectType = createEmptyObject(type);
    objectType.setName(new PolyStringType(name));
    return objectType;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType)

Example 94 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class ModelDiagController method toPolyStringType.

private PolyStringType toPolyStringType(String orig) {
    PolyStringType polyStringType = new PolyStringType();
    polyStringType.setOrig(orig);
    return polyStringType;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType)

Example 95 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class TestOrgStructMeta method assertUserOrg.

@Override
protected void assertUserOrg(PrismObject<UserType> user, String... orgOids) throws Exception {
    super.assertUserOrg(user, orgOids);
    List<PolyStringType> userOrganizations = user.asObjectable().getOrganization();
    List<PolyStringType> expextedOrgs = new ArrayList<PolyStringType>();
    for (String orgOid : orgOids) {
        PrismObject<OrgType> org = getObject(OrgType.class, orgOid);
        List<String> orgType = org.asObjectable().getOrgType();
        if (orgType.contains("functional")) {
            PolyStringType orgName = org.asObjectable().getName();
            assertTrue("Value " + orgName + " not found in user organization property: " + userOrganizations, userOrganizations.contains(orgName));
            if (!expextedOrgs.contains(orgName)) {
                expextedOrgs.add(orgName);
            }
        }
    }
    assertEquals("Wrong number of user organization property values: " + userOrganizations, expextedOrgs.size(), userOrganizations.size());
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ArrayList(java.util.ArrayList)

Aggregations

PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)94 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 Test (org.testng.annotations.Test)23 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)20 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)14 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)12 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)12 QName (javax.xml.namespace.QName)11 Task (com.evolveum.midpoint.task.api.Task)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)10 File (java.io.File)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 ArrayList (java.util.ArrayList)7 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)5 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)4 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4