use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestJaxbConstruction method createFilter.
private MapXNode createFilter() {
XNodeFactory factory = getPrismContext().xnodeFactory();
Map<QName, XNode> equalsElementSource = new HashMap<>();
PrimitiveXNode<ItemPathType> pathElement = factory.primitive(new ItemPathType(new ItemName("name")));
equalsElementSource.put(new QName(SchemaConstantsGenerated.NS_QUERY, "path"), pathElement);
PrimitiveXNode<String> valueElement = factory.primitive("čučoriedka");
equalsElementSource.put(new QName(SchemaConstantsGenerated.NS_QUERY, "value"), valueElement);
MapXNode equalsElement = factory.map(equalsElementSource);
return factory.map(new QName(SchemaConstantsGenerated.NS_QUERY, "equal"), equalsElement);
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestParseDiffPatch method assertModificationPolyStringValue.
private void assertModificationPolyStringValue(RawType value, PolyStringType... expectedValues) throws SchemaException {
XNode xnode = value.serializeToXNode();
assertFalse(xnode.isEmpty());
PrismContext pc = value.getPrismContext();
RootXNode rootNode = pc.xnodeFactory().root(new ItemName("dummy"), xnode);
PolyStringType valueAsPoly = pc.parserFor(rootNode).parseRealValue(PolyStringType.class);
boolean found = false;
for (PolyStringType expectedValue : expectedValues) {
if (expectedValue.getOrig().equals(valueAsPoly.getOrig()) && expectedValue.getNorm().equals(valueAsPoly.getNorm())) {
found = true;
break;
}
}
assertTrue(found);
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class SqaleRepoAddDeleteObjectTest method test302AddObjectWithExtensionItemOfNonIndexableType.
@Test
public void test302AddObjectWithExtensionItemOfNonIndexableType() throws ObjectAlreadyExistsException, SchemaException, ObjectNotFoundException {
OperationResult result = createOperationResult();
given("object with extension item of non-indexable type");
String objectName = "user" + getTestNumber();
UserType object = new UserType(prismContext).name(objectName).extension(new ExtensionType(prismContext));
ExtensionType extensionContainer = object.getExtension();
addExtensionValue(extensionContainer, "blob", "bytes".getBytes(StandardCharsets.UTF_8));
when("adding it to the repository");
String returnedOid = repositoryService.addObject(object.asPrismObject(), null, result);
then("operation is successful and ext column is null");
assertThatOperationResult(result).isSuccess();
assertThat(returnedOid).isEqualTo(object.getOid());
MUser row = selectObjectByOid(QUser.class, returnedOid);
assertThat(row.ext).isNull();
and("stored object contains the extension item");
PrismObject<UserType> storedObject = repositoryService.getObject(UserType.class, returnedOid, null, result);
assertThat(storedObject.getExtension().findItem(new ItemName("blob"))).isNotNull();
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class SqaleRepoAddDeleteObjectTest method test301AddObjectWithNonIndexedStringExtension.
@Test
public void test301AddObjectWithNonIndexedStringExtension() throws ObjectAlreadyExistsException, SchemaException, ObjectNotFoundException {
OperationResult result = createOperationResult();
given("object with string extension item");
String objectName = "user" + getTestNumber();
UserType object = new UserType(prismContext).name(objectName).extension(new ExtensionType(prismContext));
ExtensionType extensionContainer = object.getExtension();
addExtensionValue(extensionContainer, "string-ni", "string-value");
when("adding it to the repository");
String returnedOid = repositoryService.addObject(object.asPrismObject(), null, result);
then("operation is successful and ext column is null");
assertThatOperationResult(result).isSuccess();
assertThat(returnedOid).isEqualTo(object.getOid());
MUser row = selectObjectByOid(QUser.class, returnedOid);
assertThat(row.ext).isNull();
and("stored object contains the extension item");
PrismObject<UserType> storedObject = repositoryService.getObject(UserType.class, returnedOid, null, result);
assertThat(storedObject.getExtension().findItem(new ItemName("string-ni"))).isNotNull().extracting(i -> i.getRealValue()).isEqualTo("string-value");
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class SqaleRepoModifyObjectTest method test500SettingExtensionItemValue.
// endregion
// region extension items
@Test
public void test500SettingExtensionItemValue() throws Exception {
OperationResult result = createOperationResult();
MUser originalRow = selectObjectByOid(QUser.class, user1Oid);
given("delta adding string extension item");
ObjectDelta<UserType> delta = prismContext.deltaFor(UserType.class).item(FocusType.F_EXTENSION, new QName("string")).replace("string-value500").asObjectDelta(user1Oid);
when("modifyObject is called");
repositoryService.modifyObject(UserType.class, user1Oid, delta.getModifications(), result);
then("operation is successful");
assertThatOperationResult(result).isSuccess();
and("serialized form (fullObject) is updated");
UserType user = repositoryService.getObject(UserType.class, user1Oid, null, result).asObjectable();
assertThat(user.getVersion()).isEqualTo(String.valueOf(originalRow.version + 1));
ExtensionType extensionContainer = user.getExtension();
assertThat(extensionContainer).isNotNull().extracting(e -> e.asPrismContainerValue().findItem(new ItemName("string"))).isNotNull().extracting(i -> i.getRealValue()).isEqualTo("string-value500");
and("externalized column is updated");
MUser row = selectObjectByOid(QUser.class, user1Oid);
assertThat(row.version).isEqualTo(originalRow.version + 1);
assertThat(row.ext).isNotNull();
assertThat(Jsonb.toMap(row.ext)).containsEntry(extensionKey(extensionContainer, "string"), "string-value500");
}
Aggregations