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" });
}
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" });
}
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)" });
}
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)" });
}
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;
}
Aggregations