Skip to content

Commit

Permalink
More paging tests
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jun 18, 2018
1 parent c2cb142 commit 654ee93
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 18 deletions.
Expand Up @@ -1954,13 +1954,15 @@ public Integer countObjects(ObjectQuery query, Task task, final OperationResult
.getEffectiveCapability(CountObjectsCapabilityType.class, resourceType);
if (countObjectsCapabilityType == null) {
// Unable to count. Return null which means "I do not know"
LOGGER.trace("countObjects: cannot count (no counting capability)");
result.recordNotApplicableIfUnknown();
return null;
} else {
CountObjectsSimulateType simulate = countObjectsCapabilityType.getSimulate();
if (simulate == null) {
// We have native capability

LOGGER.trace("countObjects: counting with native count capability");
ConnectorInstance connector = ctx.getConnector(ReadCapabilityType.class, result);
try {
ObjectQuery attributeQuery = createAttributeQuery(query);
Expand All @@ -1985,6 +1987,7 @@ public Integer countObjects(ObjectQuery query, Task task, final OperationResult

} else if (simulate == CountObjectsSimulateType.PAGED_SEARCH_ESTIMATE) {

LOGGER.trace("countObjects: simulating counting with paged search estimate");
if (!objectClassDef.isPagedSearchEnabled(resourceType)) {
throw new ConfigurationException(
"Configured count object capability to be simulated using a paged search but paged search capability is not present");
Expand Down Expand Up @@ -2035,6 +2038,7 @@ public String toString() {

} else if (simulate == CountObjectsSimulateType.SEQUENTIAL_SEARCH) {

LOGGER.trace("countObjects: simulating counting with sequential search (likely perfomance impact)");
// traditional way of counting objects (i.e. counting them one
// by one)
final Holder<Integer> countHolder = new Holder<>(0);
Expand Down
Expand Up @@ -43,8 +43,6 @@ public class ProvisioningTestUtil {
public static final File COMMON_TEST_DIR_FILE = new File("src/test/resources/common/");
public static final File TEST_DIR_IMPL_FILE = new File("src/test/resources/impl/");

public static final File RESOURCE_OPENDJ_FILE = new File(COMMON_TEST_DIR_FILE, "resource-opendj.xml");

public static final String RESOURCE_DUMMY_NS = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-9999dddddddd";

public static final String DOT_JPG_FILENAME = "src/test/resources/common/dot.jpg";
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,11 +50,11 @@
public abstract class AbstractOpenDjTest extends AbstractIntegrationTest {

protected static final File TEST_DIR = new File("src/test/resources/opendj");

protected static final File RESOURCE_OPENDJ_FILE = ProvisioningTestUtil.RESOURCE_OPENDJ_FILE;
public static final File RESOURCE_OPENDJ_FILE = new File(TEST_DIR, "resource-opendj.xml");
protected static final File RESOURCE_OPENDJ_INITIALIZED_FILE = new File(TEST_DIR, "resource-opendj-initialized.xml");
protected static final String RESOURCE_OPENDJ_OID = "ef2bc95b-76e0-59e2-86d6-3d4f02d3ffff";
protected static final String RESOURCE_OPENDJ_NS = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-3d4f02d3ffff";
public static final String RESOURCE_OPENDJ_OID = "ef2bc95b-76e0-59e2-86d6-3d4f02d3ffff";
public static final String RESOURCE_OPENDJ_NS = "http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-3d4f02d3ffff";

protected static final File RESOURCE_OPENDJ_BAD_CREDENTIALS_FILE = new File(TEST_DIR, "resource-opendj-bad-credentials.xml");
protected static final String RESOURCE_OPENDJ_BAD_CREDENTIALS_OID = "8bc3ff5a-ef5d-11e4-8bba-001e8c717e5b";
Expand Down Expand Up @@ -143,6 +143,7 @@ public abstract class AbstractOpenDjTest extends AbstractIntegrationTest {

protected static final File QUERY_COMPLEX_FILTER_FILE = new File(TEST_DIR, "query-complex-filter.xml");
protected static final File QUERY_ALL_ACCOUNTS_FILE = new File(TEST_DIR, "query-filter-all-accounts.xml");
protected static final File QUERY_ALL_LDAP_GROUPS_FILE = new File(TEST_DIR, "query-filter-all-ldap-groups.xml");
protected static final File QUERY_VANHELGEN_FILE = new File(TEST_DIR, "query-vanhelgen.xml");

protected static final String OBJECT_CLASS_INETORGPERSON_NAME = "inetOrgPerson";
Expand Down
Expand Up @@ -2043,9 +2043,13 @@ private void assertSearchResults(List<PrismObject<ShadowType>> searchResults, St
}
}

/**
* Account counting is simulated.
* For "dumber" resource it is defined in schemaHandling as a object-type-specific capability.
*/
@Test
public void test250CountObjects() throws Exception {
final String TEST_NAME = "test250CountObjects";
public void test250CountAccounts() throws Exception {
final String TEST_NAME = "test250CountAccounts";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
Expand All @@ -2055,14 +2059,49 @@ public void test250CountObjects() throws Exception {
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);

// WHEN
displayWhen(TEST_NAME);
Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);
display("All accounts count", count);

assertEquals("Unexpected number of search results", (Integer)14, count);
}

/**
* Account counting is simulated.
* But "dumber" resource do not have any simulation for this.
*/
@Test
public void test252CountLdapGroups() throws Exception {
final String TEST_NAME = "test252CountLdapGroups";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_LDAP_GROUPS_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);

// WHEN
displayWhen(TEST_NAME);
Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);
display("All LDAP groups count", count);

assertEquals("Unexpected number of search results", getExpectedLdapGroupCountTest25x(), count);
}

protected Integer getExpectedLdapGroupCountTest25x() {
return 1;
}


/**
* The exception comes from the resource. There is no shadow for this object.
*/
Expand Down
Expand Up @@ -53,5 +53,13 @@ protected int getNumberOfBaseContextShadows() {
protected void assertConnectorOperationIncrement(int expectedIncrementSmart, int expectedIncrementDumb) {
assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, expectedIncrementDumb);
}

/**
* But "dumber" resource do not have any count simulation for groups.
*/
@Override
protected Integer getExpectedLdapGroupCountTest25x() {
return null;
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,7 +57,7 @@ public class TestSynchronization extends AbstractIntegrationTest {

private static final File TEST_DIR = new File("src/test/resources/synchronization/");

private static final File RESOURCE_OPENDJ_FILE = ProvisioningTestUtil.RESOURCE_OPENDJ_FILE;
private static final File RESOURCE_OPENDJ_FILE = AbstractOpenDjTest.RESOURCE_OPENDJ_FILE;

private static final File SYNC_TASK_FILE = new File(TEST_DIR, "sync-task-example.xml");
private static final String SYNC_TASK_OID = "91919191-76e0-59e2-86d6-3d4f02d3ffff";
Expand Down
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2018 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<q:query xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:i='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:dj="http://midpoint.evolveum.com/xml/ns/samples/localhostOpenDJ"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:foo="http://foo.com/" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-3d4f02d3ffff">

<!-- Query filter example -->
<q:filter>
<q:and>
<q:ref>
<q:path>i:resourceRef</q:path>
<q:value>
<c:oid>ef2bc95b-76e0-59e2-86d6-3d4f02d3ffff</c:oid>
</q:value>
</q:ref>
<q:equal>
<q:path>i:kind</q:path>
<q:value>entitlement</q:value>
</q:equal>
<q:equal>
<q:path>i:intent</q:path>
<q:value>ldapGroup</q:value>
</q:equal>
</q:and>
</q:filter>
</q:query>
Expand Up @@ -127,9 +127,6 @@
<cap:pagedSearch>
<cap:defaultSortField>ri:uid</cap:defaultSortField>
</cap:pagedSearch>
<cap:countObjects>
<cap:simulate>sequentialSearch</cap:simulate>
</cap:countObjects>
</configuredCapabilities>
</objectType>

Expand Down Expand Up @@ -247,6 +244,9 @@
<cap:read/>
<cap:update/>
<cap:delete/>
<cap:countObjects>
<cap:simulate>pagedSearchEstimate</cap:simulate>
</cap:countObjects>
</configured>
</capabilities>

Expand Down
Expand Up @@ -247,6 +247,9 @@
<cap:read/>
<cap:update/>
<cap:delete/>
<cap:countObjects>
<cap:simulate>pagedSearchEstimate</cap:simulate>
</cap:countObjects>
</configured>
</capabilities>

Expand Down
Expand Up @@ -126,9 +126,6 @@
<cap:pagedSearch>
<cap:defaultSortField>ri:uid</cap:defaultSortField>
</cap:pagedSearch>
<cap:countObjects>
<cap:simulate>sequentialSearch</cap:simulate>
</cap:countObjects>
</configuredCapabilities>
</objectType>

Expand Down Expand Up @@ -246,6 +243,9 @@
<cap:read/>
<cap:update/>
<cap:delete/>
<cap:countObjects>
<cap:simulate>pagedSearchEstimate</cap:simulate>
</cap:countObjects>
</configured>
</capabilities>

Expand Down
Expand Up @@ -402,6 +402,9 @@ private String keyToNamespaceSuffix(ConnectorKey key) {
@Override
public PrismSchema generateConnectorConfigurationSchema(ConnectorType connectorType) throws ObjectNotFoundException {
ConnectorInfo cinfo = getConnectorInfo(connectorType);
if (cinfo == null) {
throw new ObjectNotFoundException("Connector "+connectorType+" cannot be found by ConnId framework");
}
return generateConnectorConfigurationSchema(cinfo, connectorType);
}

Expand Down
Expand Up @@ -23,7 +23,7 @@
<name>ICF com.evolveum.polygon.connector.ldap.LdapConnector</name>
<framework>http://midpoint.evolveum.com/xml/ns/public/connector/icf-1</framework>
<connectorType>com.evolveum.polygon.connector.ldap.LdapConnector</connectorType>
<connectorVersion>1.6</connectorVersion>
<connectorVersion>1.7-SNAPSHOT</connectorVersion>
<connectorBundle>com.evolveum.polygon.connector-ldap</connectorBundle>
<namespace>http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.polygon.connector-ldap/com.evolveum.polygon.connector.ldap.LdapConnector</namespace>
<schema>
Expand Down

0 comments on commit 654ee93

Please sign in to comment.