Skip to content

Commit

Permalink
Diag fixes. Extending import test.
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jun 25, 2014
1 parent c4787b0 commit 9306db3
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 35 deletions.
Expand Up @@ -1392,6 +1392,7 @@ public String debugDump(int indent) {
}
sb.append("id=").append(PrettyPrinter.prettyPrint(getId()));
}
appendOriginDump(sb);
List<Item<?>> items = getItems();
if (items != null) {
Iterator<Item<?>> i = getItems().iterator();
Expand Down
Expand Up @@ -572,12 +572,7 @@ public String toString() {
}

private void dumpSuffix(StringBuilder builder) {
if (getOriginType() != null || getOriginObject() != null) {
builder.append(", origin: ");
builder.append(getOriginType());
builder.append(":");
builder.append(getOriginObject());
}
appendOriginDump(builder);
if (getRawElement() != null) {
builder.append(", raw element: ");
builder.append(PrettyPrinter.prettyPrint(getRawElement()));
Expand Down
Expand Up @@ -18,6 +18,8 @@
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.exception.SchemaException;

import org.w3c.dom.Element;
Expand Down Expand Up @@ -312,6 +314,17 @@ void diffMatchingRepresentation(PrismValue otherValue,
* The value is returned without any decorations or type demarcations (such as PPV, PRV, etc.)
*/
public abstract String toHumanReadableString();

protected void appendOriginDump(StringBuilder builder) {
if (DebugUtil.isDetailedDebugDump()) {
if (getOriginType() != null || getOriginObject() != null) {
builder.append(", origin: ");
builder.append(getOriginType());
builder.append(":");
builder.append(getOriginObject());
}
}
}

public static <T> Set<T> getRealValuesOfCollection(Collection<PrismPropertyValue<T>> collection) {
Set<T> retval = new HashSet<T>(collection.size());
Expand Down
Expand Up @@ -411,6 +411,8 @@ private Mapping<PrismContainerValue<ShadowAssociationType>> evaluateAssociation(
PrismContainerDefinition<ShadowAssociationType> outputDefinition = getAssociationContainerDefinition();
Mapping<PrismContainerValue<ShadowAssociationType>> mapping = mappingFactory.createMapping(outboundMappingType,
"for association " + PrettyPrinter.prettyPrint(assocName) + " in " + source);
mapping.setOriginType(OriginType.ASSIGNMENTS);
mapping.setOriginObject(source);

RefinedAssociationDefinition rAssocDef = refinedObjectClassDefinition.findAssociation(assocName);
if (rAssocDef == null) {
Expand Down
Expand Up @@ -59,6 +59,7 @@
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.ProvisioningScriptSpec;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
Expand Down Expand Up @@ -98,6 +99,12 @@ public class TestImportRecon extends AbstractInitializedModelIntegrationTest {
private static final String ACCOUNT_CAPSIZE_NAME = "capsize";
private static final String ACCOUNT_CAPSIZE_FULLNAME = "Kata Capsize";

private static final String USER_AUGUSTUS_NAME = "augustus";
private static final File ACCOUNT_TAUGUSTUS_FILE = new File(TEST_DIR, "account-taugustus-dummy.xml");
private static final String ACCOUNT_TAUGUSTUS_OID = "22220000-2200-0000-0000-444400004456";
private static final String ACCOUNT_TAUGUSTUS_NAME = "Taugustus";
private static final String ACCOUNT_TAUGUSTUS_FULLNAME = "Augustus DeWaat";

protected static final File RESOURCE_DUMMY_AZURE_FILE = new File(TEST_DIR, "resource-dummy-azure.xml");
protected static final File RESOURCE_DUMMY_AZURE_DEPRECATED_FILE = new File(TEST_DIR, "resource-dummy-azure-deprecated.xml");
protected static final String RESOURCE_DUMMY_AZURE_OID = "10000000-0000-0000-0000-00000000a204";
Expand Down Expand Up @@ -169,8 +176,12 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
PrismObject<ShadowType> accountStan = PrismTestUtil.parseObject(ACCOUNT_STAN_FILE);
provisioningService.addObject(accountStan, null, null, initTask, initResult);

addObject(SHADOW_GROUP_DUMMY_TESTERS_FILE, initTask, initResult);

InternalMonitor.reset();
InternalMonitor.setTraceShadowFetchOperation(true);

DebugUtil.setDetailedDebugDump(true);
}

protected File getDummyResourceLimeFile() {
Expand Down Expand Up @@ -1080,6 +1091,62 @@ public void test410ReconcileDummyLimeDeleteLinkedAccount() throws Exception {
// Audit record structure is somehow complex here.
// assertReconAuditModifications(4, TASK_RECONCILE_DUMMY_LIME_OID);
}

/**
* Imports a testing account (Taugustus)
*/
@Test
public void test500ImportTAugustusFromResourceDummy() throws Exception {
final String TEST_NAME = "test500ImportTAugustusFromResourceDummy";
TestUtil.displayTestTile(this, TEST_NAME);

// GIVEN
Task task = createTask(TestImportRecon.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);

PrismObject<ShadowType> accountStan = PrismTestUtil.parseObject(ACCOUNT_TAUGUSTUS_FILE);
provisioningService.addObject(accountStan, null, null, task, result);

// Preconditions
assertUsers(10);
dummyAuditService.clear();
rememberShadowFetchOperationCount();

// WHEN
TestUtil.displayWhen(TEST_NAME);
modelService.importFromResource(ACCOUNT_TAUGUSTUS_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display(result);
TestUtil.assertSuccess(result);

// First fetch: import handler reading the account
// Second fetch: fetchback to correctly process inbound (import changes the account).
// assertShadowFetchOperationCountIncrement(2);

// WHY???
assertShadowFetchOperationCountIncrement(1);

assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByOid(USER_GUYBRUSH_OID, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(ACCOUNT_STAN_NAME, RESOURCE_DUMMY_OID);
assertImportedUserByUsername(USER_AUGUSTUS_NAME, RESOURCE_DUMMY_OID);

// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);

assertUsers(11);

// Check audit
assertImportAuditModifications(1);

}

private void assertImportAuditModifications(int expectedModifications) {
display("Audit", dummyAuditService);
Expand Down
78 changes: 78 additions & 0 deletions model/model-intest/src/test/resources/common/resource-dummy.xml
Expand Up @@ -312,6 +312,20 @@
</script>
</expression>
</outbound>
<inbound>
<!-- This avoids "kickback" of a name from account to a user. -->
<strength>weak</strength>
<expression>
<script>
<code>
input?.substring(1)
</code>
</script>
</expression>
<target>
<path>$user/name</path>
</target>
</inbound>
</attribute>
<attribute>
<ref>ri:fullname</ref>
Expand All @@ -325,6 +339,12 @@
</script>
</expression>
</outbound>
<inbound>
<strength>weak</strength>
<target>
<path>$user/fullName</path>
</target>
</inbound>
</attribute>
<attribute>
<ref>ri:location</ref>
Expand Down Expand Up @@ -371,6 +391,9 @@
<activation>
<administrativeStatus>
<outbound/>
<inbound>
<strength>weak</strength>
</inbound>
</administrativeStatus>
</activation>

Expand Down Expand Up @@ -548,7 +571,15 @@ end

<synchronization>
<objectSynchronization>
<objectClass>ri:AccountObjectClass</objectClass>
<kind>account</kind>
<intent>default</intent>
<enabled>true</enabled>
<condition>
<script>
<code>!basic.getAttributeValue(shadow, 'http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3', 'name').startsWith("T")</code>
</script>
</condition>
<correlation>
<q:equal>
<q:path>name</q:path>
Expand Down Expand Up @@ -584,6 +615,53 @@ end
</action>
</reaction>
</objectSynchronization>

<objectSynchronization>
<objectClass>ri:AccountObjectClass</objectClass>
<kind>account</kind>
<intent>test</intent>
<enabled>true</enabled>
<condition>
<script>
<code>basic.getAttributeValue(shadow, 'http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3', 'name').startsWith("T")</code>
</script>
</condition>
<correlation>
<q:equal>
<q:path>name</q:path>
<expression>
<script>
<code>basic.getAttributeValue(shadow, 'http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3', 'name').substring(1)</code>
</script>
</expression>
</q:equal>
</correlation>
<reaction>
<situation>linked</situation>
<synchronize>true</synchronize>
</reaction>
<reaction>
<situation>deleted</situation>
<synchronize>true</synchronize>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#unlink</handlerUri>
</action>
</reaction>
<reaction>
<situation>unlinked</situation>
<synchronize>true</synchronize>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#link</handlerUri>
</action>
</reaction>
<reaction>
<situation>unmatched</situation>
<synchronize>true</synchronize>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addFocus</handlerUri>
</action>
</reaction>
</objectSynchronization>
</synchronization>

</resource>
44 changes: 22 additions & 22 deletions model/model-intest/src/test/resources/logback-test.xml
Expand Up @@ -28,9 +28,9 @@
<logger name="com.evolveum.midpoint.common.LoggingConfigurationManager" level="TRACE" />
<logger name="com.evolveum.midpoint.model.intest" level="TRACE" />
<logger name="com.evolveum.midpoint.model" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.sync.LiveSyncTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.sync.ReconciliationTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.sync.SynchronizeAccountResultHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.LiveSyncTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.ReconciliationTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.SynchronizeAccountResultHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.impl.ChangeNotificationDispatcherImpl" level="DEBUG" />
<logger name="com.evolveum.midpoint.test" level="TRACE" />
<logger name="com.evolveum.midpoint.model.common.Clock" level="TRACE" />
Expand All @@ -40,20 +40,20 @@

<!-- "TRACE" is just too much info, "DEBUG" should be enough for the following talkative components ...
if any of the following is set to "TRACE" then it was changed by mistake and should be changed back -->
<logger name="com.evolveum.midpoint.model.lens.projector" level="TRACE" />
<logger name="com.evolveum.midpoint.model.lens.projector.Projector" level="TRACE" />
<logger name="com.evolveum.midpoint.model.lens.projector.FocusProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.lens.projector.FocusConstraintsChecker" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.lens.projector.FocusPolicyProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.lens" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.lens.Clockwork" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.lens.ChangeExecutor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.lens.ShadowConstraintsChecker" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.lens.LensUtil" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.expr" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.util" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.sync" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.sync.CorrelationConfirmationEvaluator" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.Projector" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.FocusProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.FocusConstraintsChecker" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.projector.FocusPolicyProcessor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.Clockwork" level="TRACE" />
<logger name="com.evolveum.midpoint.model.impl.lens.ChangeExecutor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.ShadowConstraintsChecker" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.lens.LensUtil" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.expr" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.util" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.CorrelationConfirmationEvaluator" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning" level="DEBUG" />
<logger name="com.evolveum.midpoint.expression" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.common.expression" level="DEBUG" />
Expand All @@ -65,11 +65,11 @@
<logger name="com.evolveum.midpoint.common.monitor" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.controller.SystemConfigurationHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.notifications" level="DEBUG" />
<logger name="com.evolveum.midpoint.security" level="TRACE" />
<logger name="com.evolveum.midpoint.model.sync.FocusValidityScannerTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.util.AbstractSearchIterativeTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.sync.SynchronizationService" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.controller.ModelController" level="TRACE" />
<logger name="com.evolveum.midpoint.security" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.FocusValidityScannerTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.util.AbstractSearchIterativeTaskHandler" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.SynchronizationService" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.controller.ModelController" level="DEBUG" />

<logger name="com.evolveum.midpoint.repo" level="INFO" />

Expand Down
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2014 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.
-->

<account oid="22220000-2200-0000-0000-444400004456"
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance/10000000-0000-0000-0000-000000000004">
<resourceRef oid="10000000-0000-0000-0000-000000000004"/>
<objectClass>ri:AccountObjectClass</objectClass>
<attributes>
<icfs:name>Taugustus</icfs:name>
<ri:fullname>Augustus DeWaat</ri:fullname>
<ri:location>Booty Island</ri:location>
</attributes>
<activation>
<administrativeStatus>enabled</administrativeStatus>
</activation>
</account>

0 comments on commit 9306db3

Please sign in to comment.