Search in sources :

Example 16 with GetOperationOptionsBuilder

use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.

the class SqaleRepoLookupTableTest method test120LookupLanguagesGetByKeyExact.

@Test
public void test120LookupLanguagesGetByKeyExact() throws Exception {
    given();
    OperationResult result = createOperationResult();
    when();
    GetOperationOptionsBuilder optionsBuilder = SchemaService.get().getOperationOptionsBuilder().item(LookupTableType.F_ROW).retrieveQuery().item(LookupTableRowType.F_KEY).eq("sk_SK").end();
    PrismObject<LookupTableType> lookup = repositoryService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" });
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 17 with GetOperationOptionsBuilder

use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.

the class SqaleRepoLookupTableTest method test130LookupLanguagesGetByValueExact.

@Test
public void test130LookupLanguagesGetByValueExact() throws Exception {
    given();
    OperationResult result = createOperationResult();
    when();
    GetOperationOptionsBuilder optionsBuilder = SchemaService.get().getOperationOptionsBuilder().item(LookupTableType.F_ROW).retrieveQuery().item(LookupTableRowType.F_VALUE).eq("sk").end();
    PrismObject<LookupTableType> lookup = repositoryService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    checkLookupResult(lookup, new String[] { "sk_SK", "sk", "Slovak" });
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 18 with GetOperationOptionsBuilder

use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.

the class SqaleRepoLookupTableTest method test121LookupLanguagesGetByKeyStartingWith.

@Test
public void test121LookupLanguagesGetByKeyStartingWith() throws Exception {
    given();
    OperationResult result = createOperationResult();
    when();
    GetOperationOptionsBuilder optionsBuilder = SchemaService.get().getOperationOptionsBuilder().item(LookupTableType.F_ROW).retrieveQuery().item(LookupTableRowType.F_KEY).startsWith("e").end();
    PrismObject<LookupTableType> lookup = repositoryService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }, new String[] { "en_PR", "en", "English (pirate)" });
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 19 with GetOperationOptionsBuilder

use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.

the class SqaleRepoLookupTableTest method test131LookupLanguagesGetByLabelStartingWith.

/**
 * Disabled because it's not clear how to treat polystrings in searches.
 */
@Test
public void test131LookupLanguagesGetByLabelStartingWith() throws Exception {
    given();
    OperationResult result = createOperationResult();
    when();
    String fragment = "Eng";
    GetOperationOptionsBuilder optionsBuilder = SchemaService.get().getOperationOptionsBuilder().item(LookupTableType.F_ROW).retrieveQuery().item(LookupTableRowType.F_LABEL).startsWith(fragment).end();
    PrismObject<LookupTableType> lookup = repositoryService.getObject(LookupTableType.class, LOOKUP_LANGUAGES_OID, optionsBuilder.build(), result);
    then();
    result.computeStatus();
    TestUtil.assertSuccess(result);
    checkLookupResult(lookup, new String[] { "en_US", "en", "English (US)" }, new String[] { "en_PR", "en", "English (pirate)" });
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder) LookupTableType(com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 20 with GetOperationOptionsBuilder

use of com.evolveum.midpoint.schema.GetOperationOptionsBuilder in project midpoint by Evolveum.

the class AddGetObjectTest method addGetCompare.

private List<PrismObject<?>> addGetCompare(File file) throws Exception {
    List<PrismObject<? extends Objectable>> elements = prismContext.parserFor(file).parseObjects();
    List<String> oids = new ArrayList<>();
    OperationResult result = new OperationResult("Simple Add Get Test");
    long time = System.currentTimeMillis();
    for (int i = 0; i < elements.size(); i++) {
        PrismObject object = elements.get(i);
        logger.info("Adding object {}, type {}", i + 1, object.getCompileTimeClass().getSimpleName());
        oids.add(repositoryService.addObject(object, null, result));
    }
    logger.info("Time to add objects ({}): {}", elements.size(), System.currentTimeMillis() - time);
    List<PrismObject<?>> objectsRead = new ArrayList<>();
    int count = 0;
    elements = prismContext.parserFor(file).parseObjects();
    for (int i = 0; i < elements.size(); i++) {
        PrismObject object = elements.get(i);
        try {
            object.asObjectable().setOid(oids.get(i));
            Class<? extends ObjectType> clazz = object.getCompileTimeClass();
            GetOperationOptionsBuilder optionsBuilder = getOperationOptionsBuilder();
            if (UserType.class.equals(clazz)) {
                optionsBuilder = optionsBuilder.item(UserType.F_JPEG_PHOTO).retrieve();
            } else if (LookupTableType.class.equals(clazz)) {
                optionsBuilder = optionsBuilder.item(LookupTableType.F_ROW).retrieve();
            } else if (AccessCertificationCampaignType.class.equals(clazz)) {
                optionsBuilder = optionsBuilder.item(AccessCertificationCampaignType.F_CASE).retrieve();
            } else if (TaskType.class.equals(clazz)) {
                optionsBuilder = optionsBuilder.item(TaskType.F_RESULT).retrieve();
            }
            PrismObject<? extends ObjectType> newObject = repositoryService.getObject(clazz, oids.get(i), optionsBuilder.build(), result);
            logger.info("AFTER READ: {}\nOld\n{}\nnew\n{}", object, object.debugDump(3), newObject.debugDump(3));
            checkContainersSize(newObject, object);
            System.out.println("OLD: " + object.findProperty(ObjectType.F_NAME).getValue());
            System.out.println("NEW: " + newObject.findProperty(ObjectType.F_NAME).getValue());
            objectsRead.add(newObject);
            ObjectDelta delta = object.diff(newObject);
            count += delta.getModifications().size();
            if (delta.getModifications().size() > 0) {
                if (delta.getModifications().size() == 1) {
                    ItemDelta d = (ItemDelta) delta.getModifications().iterator().next();
                    if (ShadowType.F_DEAD.equals(d.getElementName())) {
                        count -= delta.getModifications().size();
                        continue;
                    }
                }
                logger.error(">>> {} Found {} changes for {}\n{}", (i + 1), delta.getModifications().size(), newObject, delta.debugDump(3));
                ItemDelta id = (ItemDelta) delta.getModifications().iterator().next();
                if (id.isReplace()) {
                    logger.debug("{}", id.getValuesToReplace().iterator().next());
                }
                logger.error("{}", prismContext.xmlSerializer().serialize(newObject));
            }
        } catch (Throwable ex) {
            logger.error("Exception occurred for {}", object, ex);
            throw new RuntimeException("Exception during processing of " + object + ": " + ex.getMessage(), ex);
        }
    }
    AssertJUnit.assertEquals("Found changes during add/get test " + count, 0, count);
    return objectsRead;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder)

Aggregations

GetOperationOptionsBuilder (com.evolveum.midpoint.schema.GetOperationOptionsBuilder)20 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)13 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)9 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)9 Test (org.testng.annotations.Test)9 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)4 QName (javax.xml.namespace.QName)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ArrayList (java.util.ArrayList)3 NinjaContext (com.evolveum.midpoint.ninja.impl.NinjaContext)2 NinjaException (com.evolveum.midpoint.ninja.impl.NinjaException)2 Log (com.evolveum.midpoint.ninja.util.Log)2 NinjaUtils (com.evolveum.midpoint.ninja.util.NinjaUtils)2 OperationStatus (com.evolveum.midpoint.ninja.util.OperationStatus)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)2 Task (com.evolveum.midpoint.task.api.Task)2 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 List (java.util.List)2