Skip to content

Commit

Permalink
Add yet another capability merge test
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 12, 2022
1 parent 815394c commit f57120c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,13 @@ default ResourceAttributeContainer instantiate(ItemName itemName) {

//region Capabilities
/**
* TODO
* Checks the presence of capability in:
*
* 1. resource object definition (applicable only to resource object _type_ definitions),
* 2. additional connectors in resource (only if enabled there),
* 3. the main connector.
*
* Returns the present capability, but only if it's enabled.
*/
<T extends CapabilityType> T getEnabledCapability(@NotNull Class<T> capabilityClass, ResourceType resource);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@

import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CountObjectsSimulateType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.*;

import org.testng.annotations.Test;

Expand Down Expand Up @@ -406,6 +403,36 @@ public void test210ObjectTypesFull() throws Exception {
assertThat(addFocusAction.getName()).isEqualTo("add-focus");
assertThat(addFocusAction.isSynchronize()).isTrue(); // types-1
assertThat(addFocusAction.getDocumentation()).isEqualTo("Adding a focus"); // parent

ReadCapabilityType read = accountDef.getEnabledCapability(ReadCapabilityType.class, current.asObjectable());
assertThat(read).as("read capability").isNotNull();

// Note that resource-level and object-type-level capabilities are currently NOT combined (merged) together.
// They are being replaced. This is years-old behavior that we won't change today.
// (In this particular case, caching-only is set at the resource level in the template.)
assertThat(read.isCachingOnly()).as("caching-only flag").isNull();

// Here we check that
// @formatter:off
assertResource(current, "after")
.assertConfiguredCapabilities(2)
.configuredCapability(ReadCapabilityType.class) // inherited
.assertPropertyEquals(ReadCapabilityType.F_ENABLED, false)
.assertPropertyEquals(ReadCapabilityType.F_CACHING_ONLY, true)
.end()
.configuredCapability(UpdateCapabilityType.class) // types-1
.end();
// @formatter:on

// This one is object-class specific and is inherited from the template
AsyncUpdateCapabilityType asyncUpdate =
accountDef.getEnabledCapability(AsyncUpdateCapabilityType.class, current.asObjectable());
assertThat(asyncUpdate).as("async update capability").isNotNull();

// And this one is new in types-1/account/default
PagedSearchCapabilityType pagedSearch =
accountDef.getEnabledCapability(PagedSearchCapabilityType.class, current.asObjectable());
assertThat(pagedSearch).as("paged search capability").isNotNull();
}

/** Hacked: gets the value of (assuming) single property value filter in the pattern. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3"
xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
<name>object-types-1</name>
Expand Down Expand Up @@ -74,6 +75,12 @@
</q:equal>
</filter>
</protected>
<configuredCapabilities>
<cap:pagedSearch/>
<cap:read>
<cap:enabled>true</cap:enabled>
</cap:read>
</configuredCapabilities>
<synchronization>
<reaction> <!-- should be added as a new value -->
<situation>unmatched</situation>
Expand All @@ -96,4 +103,9 @@
</synchronization>
</objectType>
</schemaHandling>
<capabilities>
<configured>
<cap:update/>
</configured>
</capabilities>
</resource>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:mr="http://prism.evolveum.com/xml/ns/public/matching-rule-3"
xmlns:cap="http://midpoint.evolveum.com/xml/ns/public/resource/capabilities-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">

Expand Down Expand Up @@ -130,6 +131,9 @@
</q:equal>
</filter>
</protected>
<configuredCapabilities>
<cap:asyncUpdate/>
</configuredCapabilities>
<synchronization>
<reaction>
<name>reaction1</name>
Expand Down Expand Up @@ -162,4 +166,12 @@
<objectClass>ri:CustomprivilegeObjectClass</objectClass>
</objectType>
</schemaHandling>
<capabilities>
<configured>
<cap:read>
<cap:enabled>false</cap:enabled>
<cap:cachingOnly>true</cap:cachingOnly>
</cap:read>
</configured>
</capabilities>
</resource>

0 comments on commit f57120c

Please sign in to comment.