Search in sources :

Example 71 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class TestOpenDj method test233SearchObjectsPagedNoOffsetSortSn.

@Test
public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception {
    final String TEST_NAME = "test233SearchObjectsPagedNoOffsetSortSn";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(null, 4);
    paging.setOrdering(ObjectOrdering.createOrdering(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_NS, "sn")), OrderDirection.ASCENDING));
    query.setPaging(paging);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    assertSuccess(result);
    display("Search resutls", searchResults);
    assertSearchResults(searchResults, "monk", "hbarbossa", "jbeckett", "jbond");
    assertConnectorOperationIncrement(1, 9);
    assertConnectorSimulatedPagingSearchIncrement(0);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 72 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class TestSanity method searchUserByName.

private UserType searchUserByName(String name) throws Exception {
    //        Document doc = DOMUtil.getDocument();
    //        Element nameElement = doc.createElementNS(SchemaConstants.C_NAME.getNamespaceURI(),
    //                SchemaConstants.C_NAME.getLocalPart());
    //        nameElement.setTextContent(name);
    //        Element filter = QueryUtil.createEqualFilter(doc, null, nameElement);
    //
    //        QueryType query = new QueryType();
    //        query.setFilter(filter);
    ObjectQuery q = ObjectQueryUtil.createNameQuery(UserType.class, prismContext, name);
    QueryType query = QueryJaxbConvertor.createQueryType(q, prismContext);
    OperationResultType resultType = new OperationResultType();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType);
    Holder<ObjectListType> listHolder = new Holder<ObjectListType>();
    assertNoRepoCache();
    modelWeb.searchObjects(ObjectTypes.USER.getTypeQName(), query, null, listHolder, resultHolder);
    assertNoRepoCache();
    ObjectListType objects = listHolder.value;
    TestUtil.assertSuccess("searchObjects has failed", resultHolder.value);
    AssertJUnit.assertEquals("User not found (or found too many)", 1, objects.getObject().size());
    UserType user = (UserType) objects.getObject().get(0);
    AssertJUnit.assertEquals(user.getName(), PrismTestUtil.createPolyStringType(name));
    return user;
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 73 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class TestAbstractRestService method test200searchAllUsers.

@Test
public void test200searchAllUsers() {
    final String TEST_NAME = "test200searchAllUsers";
    displayTestTile(this, TEST_NAME);
    WebClient client = prepareClient();
    client.path("/users/search");
    getDummyAuditService().clear();
    TestUtil.displayWhen(TEST_NAME);
    Response response = client.post(new QueryType());
    TestUtil.displayThen(TEST_NAME);
    displayResponse(response);
    assertStatus(response, 200);
    IntegrationTestTools.display("Audit", getDummyAuditService());
    getDummyAuditService().assertRecords(2);
    getDummyAuditService().assertLoginLogout(SchemaConstants.CHANNEL_REST_URI);
}
Also used : Response(javax.ws.rs.core.Response) WebClient(org.apache.cxf.jaxrs.client.WebClient) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Example 74 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class PageDebugList method deleteObjectsAsync.

private String deleteObjectsAsync(QName type, ObjectQuery objectQuery, boolean raw, String taskName, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
    Task task = createSimpleTask(result.getOperation());
    task.setHandlerUri(ModelPublicConstants.DELETE_TASK_HANDLER_URI);
    if (objectQuery == null) {
        objectQuery = new ObjectQuery();
    }
    QueryType query = QueryJaxbConvertor.createQueryType(objectQuery, getPrismContext());
    PrismPropertyDefinition queryDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.COMPLEX_TYPE, getPrismContext());
    PrismProperty<QueryType> queryProp = queryDef.instantiate();
    queryProp.setRealValue(query);
    task.setExtensionProperty(queryProp);
    PrismPropertyDefinition typeDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE, DOMUtil.XSD_QNAME, getPrismContext());
    PrismProperty<QName> typeProp = typeDef.instantiate();
    typeProp.setRealValue(type);
    task.setExtensionProperty(typeProp);
    PrismPropertyDefinition rawDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OPTION_RAW, DOMUtil.XSD_BOOLEAN, getPrismContext());
    PrismProperty<QName> rawProp = rawDef.instantiate();
    rawProp.setRealValue(raw);
    task.setExtensionProperty(rawProp);
    task.setName(taskName);
    task.savePendingModifications(result);
    TaskManager taskManager = getTaskManager();
    taskManager.switchToBackground(task, result);
    result.setBackgroundTaskOid(task.getOid());
    return task.getOid();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskManager(com.evolveum.midpoint.task.api.TaskManager) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 75 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class ModelWebServiceTest method badPagingSearch.

@Test(expectedExceptions = FaultMessage.class)
public void badPagingSearch() throws FaultMessage, SchemaException, IOException, JAXBException {
    PagingType paging = new PagingType();
    paging.setMaxSize(-1);
    paging.setOffset(-1);
    final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
    setSecurityContext(expectedUser);
    try {
        QueryType queryType = new QueryType();
        queryType.setPaging(paging);
        modelService.searchObjects(UserType.COMPLEX_TYPE, queryType, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
    } catch (FaultMessage ex) {
        ModelTUtil.assertIllegalArgumentFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    Assert.fail("Illegal argument exception was not thrown.");
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Aggregations

QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)57 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)41 Test (org.junit.Test)40 QueryImpl (ddf.catalog.operation.impl.QueryImpl)37 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)36 QName (javax.xml.namespace.QName)34 Test (org.testng.annotations.Test)32 JAXBElement (javax.xml.bind.JAXBElement)27 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)24 ArrayList (java.util.ArrayList)24 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)20 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)17 Matchers.anyString (org.mockito.Matchers.anyString)14 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)13 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)12 Task (com.evolveum.midpoint.task.api.Task)12 Holder (javax.xml.ws.Holder)12 GetFeatureType (ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType)12 QueryType (ogc.schema.opengis.wfs.v_1_0_0.QueryType)12