use of org.apache.openejb.jee.oejb2.QueryType in project ddf by codice.
the class TestWfsSource method testSortingAscendingSortingNotSupported.
/**
* Verify that the SortBy is NOT set. In this case, sorting is not supported in the capabilities.
*/
@Test
public void testSortingAscendingSortingNotSupported() throws Exception {
// Setup
final String searchPhrase = "*";
final String mockTemporalFeatureProperty = "myTemporalFeatureProperty";
final String mockFeatureType = "{http://example.com}" + SAMPLE_FEATURE_NAME + 0;
final int pageSize = 1;
// Set ImplementsSorting to FALSE (sorting not supported)
FilterCapabilities mockCapabilitiesSortingNotSupported = MockWfsServer.getFilterCapabilities();
ConformanceType conformance = mockCapabilitiesSortingNotSupported.getConformance();
List<DomainType> domainTypes = conformance.getConstraint();
for (DomainType domainType : domainTypes) {
if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
ValueType valueType = new ValueType();
valueType.setValue("FALSE");
domainType.setDefaultValue(valueType);
break;
}
}
WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, mockCapabilitiesSortingNotSupported, GeospatialUtil.EPSG_4326_URN, 1, false, false, 0);
MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
List<MetacardMapper> mappers = new ArrayList<MetacardMapper>(1);
mappers.add(mockMetacardMapper);
source.setMetacardToFeatureMapper(mappers);
QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
query.setPageSize(pageSize);
SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
query.setSortBy(sortBy);
// Perform Test
GetFeatureType featureType = source.buildGetFeatureRequest(query);
// Verify
QueryType queryType = (QueryType) featureType.getAbstractQueryExpression().get(0).getValue();
assertFalse(queryType.isSetAbstractSortingClause());
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class QueryInterpreter2Test method getQuery.
@Nullable
private ObjectQuery getQuery(File file, Class type) throws SchemaException, IOException {
QueryType queryType = PrismTestUtil.parseAtomicValue(file, QueryType.COMPLEX_TYPE);
LOGGER.info("QUERY TYPE TO CONVERT : {}", ObjectQueryUtil.dump(queryType, prismContext));
ObjectQuery query = null;
try {
// TODO
query = QueryJaxbConvertor.createObjectQuery(type, queryType, prismContext);
} catch (Exception ex) {
LOGGER.info("error while converting query: " + ex.getMessage(), ex);
}
return query;
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class TestOpenDj method test202SearchObjectsCompexFilter.
@Test
public void test202SearchObjectsCompexFilter() throws Exception {
final String TEST_NAME = "test202SearchObjectsCompexFilter";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_COMPLEX_FILTER_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
provisioningService.applyDefinition(ShadowType.class, query, task, result);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismObject<ShadowType>> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
for (PrismObject<ShadowType> objType : objListType) {
assertNotNull("Null search result", objType);
display("found object", objType);
}
assertEquals("Unexpected number of objects found", 1, objListType.size());
assertConnectorOperationIncrement(1, 3);
assertConnectorSimulatedPagingSearchIncrement(0);
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class TestOpenDj method test250CountObjects.
@Test
public void test250CountObjects() throws Exception {
final String TEST_NAME = "test250CountObjects";
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);
// WHEN
Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result);
// THEN
result.computeStatus();
assertSuccess(result);
assertEquals("Unexpected number of search results", (Integer) 14, count);
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class TestOpenDj method test330SearchForPosixAccount.
/**
* Search for account created directly on resource (no shadow in repo). The account has
* posixAccount auxiliary object class. Provisioning should figure that out.
*/
@Test
public void test330SearchForPosixAccount() throws Exception {
final String TEST_NAME = "test330SearchForPosixAccount";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_VANHELGEN_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
provisioningService.applyDefinition(ShadowType.class, query, task, result);
Entry entry = openDJController.addEntryFromLdifFile(ACCOUNT_POSIX_VANHELGEN_LDIF_FILE);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
List<PrismObject<ShadowType>> objListType = provisioningService.searchObjects(ShadowType.class, query, null, null, result);
// THEN
for (PrismObject<ShadowType> objType : objListType) {
assertNotNull("Null search result", objType);
display("found object", objType);
}
assertEquals("Unexpected number of objects found", 1, objListType.size());
PrismObject<ShadowType> provisioningShadow = objListType.get(0);
assertAttribute(provisioningShadow, "cn", "Edward Van Helgen");
assertAttribute(provisioningShadow, "homeDirectory", "/home/vanhelgen");
assertAttribute(provisioningShadow, "uidNumber", 1002);
assertConnectorOperationIncrement(1, 3);
assertConnectorSimulatedPagingSearchIncrement(0);
assertShadows(17);
}
Aggregations