use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class LookupTableTest method executeAndCheckModification.
protected void executeAndCheckModification(List<ItemDelta<?, ?>> modifications, OperationResult result, int versionDelta, List<String> keysWithGeneratedTimestamps, List<String> replacedKeys) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException, IOException {
RepoModifyOptions modifyOptions = getModifyOptions();
if (RepoModifyOptions.isExecuteIfNoChanges(modifyOptions) && versionDelta == 0) {
versionDelta = 1;
}
PrismObject<LookupTableType> before = getFullTable(tableOid, result);
repositoryService.modifyObject(LookupTableType.class, tableOid, modifications, modifyOptions, result);
checkTable(tableOid, result, before, modifications, Integer.parseInt(before.getVersion()) + versionDelta, keysWithGeneratedTimestamps, replacedKeys);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class LookupTableTest method checkTable.
private void checkTable(String oid, OperationResult result, PrismObject<LookupTableType> expectedObject, List<ItemDelta<?, ?>> modifications, int expectedVersion, List<String> keysWithNewGeneratedTimestamps, List<String> replacedKeys) throws SchemaException, ObjectNotFoundException, IOException {
expectedObject.setOid(oid);
// remove keys that will be replaced
if (replacedKeys != null) {
Iterator<LookupTableRowType> iterator = expectedObject.asObjectable().getRow().iterator();
while (iterator.hasNext()) {
if (replacedKeys.contains(iterator.next().getKey())) {
iterator.remove();
}
}
}
if (modifications != null) {
ItemDelta.applyTo(modifications, expectedObject);
}
LOGGER.trace("Expected object = \n{}", expectedObject.debugDump());
PrismObject<LookupTableType> actualObject = getFullTable(oid, result);
LOGGER.trace("Actual object from repo = \n{}", actualObject.debugDump());
// before comparison, check and remove generated timestamps
if (keysWithNewGeneratedTimestamps != null) {
for (String key : keysWithNewGeneratedTimestamps) {
LookupTableRowType row = findRow(actualObject, key, true);
checkCurrentTimestamp(row);
row.setLastChangeTimestamp(null);
LookupTableRowType rowExp = findRow(expectedObject, key, false);
if (rowExp != null) {
rowExp.setLastChangeTimestamp(null);
}
}
}
PrismAsserts.assertEquivalent("Table is not as expected", expectedObject, actualObject);
AssertJUnit.assertEquals("Incorrect version", expectedVersion, Integer.parseInt(actualObject.getVersion()));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class RLookupTable method copyFromJAXB.
public static void copyFromJAXB(LookupTableType jaxb, RLookupTable repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException, SchemaException {
RObject.copyFromJAXB(jaxb, repo, repositoryContext, generatorResult);
repo.setName(RPolyString.copyFromJAXB(jaxb.getName()));
List<LookupTableRowType> rows = jaxb.getRow();
if (!rows.isEmpty()) {
repo.setRows(new HashSet<>());
for (LookupTableRowType row : rows) {
RLookupTableRow rRow = RLookupTableRow.toRepo(repo, row);
rRow.setTransient(generatorResult.isTransient(row.asPrismContainerValue()));
repo.getRows().add(rRow);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class RLookupTable method toJAXB.
@Override
public LookupTableType toJAXB(PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) throws DtoTranslationException {
LookupTableType object = new LookupTableType();
RUtil.revive(object, prismContext);
RLookupTable.copyToJAXB(this, object, prismContext, options);
return object;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType in project midpoint by Evolveum.
the class LookupTableTest method test108AddTableOverwriteExisting.
@Test
public void test108AddTableOverwriteExisting() throws Exception {
PrismObject<LookupTableType> table = prismContext.parseObject(new File(TEST_DIR, "table-1.xml"));
OperationResult result = new OperationResult("test108AddTableOverwriteExisting");
// doesn't work without specifying OID
table.setOid(tableOid);
tableOid = repositoryService.addObject(table, RepoAddOptions.createOverwrite(), result);
// rereading, as repo strips cases from the campaign (!)
PrismObject<LookupTableType> expected = prismContext.parseObject(new File(TEST_DIR, "table-1.xml"));
checkTable(tableOid, expected, result);
}
Aggregations