Search in sources :

Example 46 with ItemName

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);
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) XNode(com.evolveum.midpoint.prism.xnode.XNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) ItemName(com.evolveum.midpoint.prism.path.ItemName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) XNodeFactory(com.evolveum.midpoint.prism.xnode.XNodeFactory)

Example 47 with ItemName

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);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) PrismTestUtil.getPrismContext(com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) XNode(com.evolveum.midpoint.prism.xnode.XNode) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 48 with ItemName

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();
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 49 with ItemName

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");
}
Also used : MArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.MArchetype) MReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.MReportData) com.evolveum.midpoint.repo.sqale.qmodel.object(com.evolveum.midpoint.repo.sqale.qmodel.object) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.qmodel.ref(com.evolveum.midpoint.repo.sqale.qmodel.ref) QSystemConfiguration(com.evolveum.midpoint.repo.sqale.qmodel.system.QSystemConfiguration) BigDecimal(java.math.BigDecimal) DOMUtil(com.evolveum.midpoint.util.DOMUtil) Map(java.util.Map) QNode(com.evolveum.midpoint.repo.sqale.qmodel.node.QNode) BigInteger(java.math.BigInteger) MContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainer) MConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnector) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) RepoAddOptions.createOverwrite(com.evolveum.midpoint.repo.api.RepoAddOptions.createOverwrite) QContainer(com.evolveum.midpoint.repo.sqale.qmodel.common.QContainer) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MFocus(com.evolveum.midpoint.repo.sqale.qmodel.focus.MFocus) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UUID(java.util.UUID) Instant(java.time.Instant) QLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow) StandardCharsets(java.nio.charset.StandardCharsets) QMessageTemplate(com.evolveum.midpoint.repo.sqale.qmodel.notification.QMessageTemplate) com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem(com.evolveum.midpoint.repo.sqale.qmodel.cases.workitem) QGenericObject(com.evolveum.midpoint.repo.sqale.qmodel.focus.QGenericObject) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) List(java.util.List) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) QName(javax.xml.namespace.QName) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) QResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.QResource) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MResource(com.evolveum.midpoint.repo.sqale.qmodel.resource.MResource) QCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.QCase) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) QConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnectorHost) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) MConnectorHost(com.evolveum.midpoint.repo.sqale.qmodel.connector.MConnectorHost) QReport(com.evolveum.midpoint.repo.sqale.qmodel.report.QReport) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) Containerable(com.evolveum.midpoint.prism.Containerable) MLookupTableRow(com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.MLookupTableRow) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) DeleteObjectResult(com.evolveum.midpoint.repo.api.DeleteObjectResult) MNode(com.evolveum.midpoint.repo.sqale.qmodel.node.MNode) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) SimpleExpressionUtil.velocityExpression(com.evolveum.midpoint.schema.util.SimpleExpressionUtil.velocityExpression) ChronoUnit(java.time.temporal.ChronoUnit) ItemName(com.evolveum.midpoint.prism.path.ItemName) QReportData(com.evolveum.midpoint.repo.sqale.qmodel.report.QReportData) MCase(com.evolveum.midpoint.repo.sqale.qmodel.cases.MCase) QArchetype(com.evolveum.midpoint.repo.sqale.qmodel.role.QArchetype) SqaleRepositoryService(com.evolveum.midpoint.repo.sqale.SqaleRepositoryService) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) ItemName(com.evolveum.midpoint.prism.path.ItemName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 50 with ItemName

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");
}
Also used : QService(com.evolveum.midpoint.repo.sqale.qmodel.role.QService) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SqaleUtils(com.evolveum.midpoint.repo.sqale.SqaleUtils) MService(com.evolveum.midpoint.repo.sqale.qmodel.role.MService) JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) BigDecimal(java.math.BigDecimal) Assertions(org.assertj.core.api.Assertions) MReference(com.evolveum.midpoint.repo.sqale.qmodel.ref.MReference) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) BeforeClass(org.testng.annotations.BeforeClass) MContainerType(com.evolveum.midpoint.repo.sqale.qmodel.common.MContainerType) MiscUtil(com.evolveum.midpoint.util.MiscUtil) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) MTask(com.evolveum.midpoint.repo.sqale.qmodel.task.MTask) QConnector(com.evolveum.midpoint.repo.sqale.qmodel.connector.QConnector) SystemException(com.evolveum.midpoint.util.exception.SystemException) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) MObject(com.evolveum.midpoint.repo.sqale.qmodel.object.MObject) QUserMapping(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUserMapping) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) java.util(java.util) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Item(com.evolveum.midpoint.prism.Item) Jsonb(com.evolveum.midpoint.repo.sqale.jsonb.Jsonb) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Assert.assertEquals(org.testng.Assert.assertEquals) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) QObjectReferenceMapping(com.evolveum.midpoint.repo.sqale.qmodel.ref.QObjectReferenceMapping) MShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.MShadow) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) TestUtil(com.evolveum.midpoint.test.util.TestUtil) Comparator.comparing(java.util.Comparator.comparing) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) MObjectType(com.evolveum.midpoint.repo.sqale.qmodel.object.MObjectType) QObjectReference(com.evolveum.midpoint.repo.sqale.qmodel.ref.QObjectReference) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) com.evolveum.midpoint.repo.sqale.qmodel.assignment(com.evolveum.midpoint.repo.sqale.qmodel.assignment) PrismObject(com.evolveum.midpoint.prism.PrismObject) QShadow(com.evolveum.midpoint.repo.sqale.qmodel.shadow.QShadow) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) ItemName(com.evolveum.midpoint.prism.path.ItemName) RepoModifyOptions(com.evolveum.midpoint.repo.api.RepoModifyOptions) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) Assert.assertTrue(org.testng.Assert.assertTrue) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QTask(com.evolveum.midpoint.repo.sqale.qmodel.task.QTask) com.evolveum.midpoint.repo.sqale.qmodel.accesscert(com.evolveum.midpoint.repo.sqale.qmodel.accesscert) QName(javax.xml.namespace.QName) ItemName(com.evolveum.midpoint.prism.path.ItemName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

ItemName (com.evolveum.midpoint.prism.path.ItemName)89 Test (org.testng.annotations.Test)24 QName (javax.xml.namespace.QName)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)13 NotNull (org.jetbrains.annotations.NotNull)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 Task (com.evolveum.midpoint.task.api.Task)6 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)5 MUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser)5 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)5 Element (org.w3c.dom.Element)5 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 ArrayList (java.util.ArrayList)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3