Skip to content

Commit

Permalink
Fixing add operation for semi-manual resources (MID-4002)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jun 22, 2017
1 parent 2c52617 commit cde3d1d
Show file tree
Hide file tree
Showing 7 changed files with 362 additions and 18 deletions.
Expand Up @@ -19,8 +19,11 @@
import java.util.ArrayList;
import java.util.Collection;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.util.ShadowUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;

/**
* @author semancik
Expand Down Expand Up @@ -120,6 +123,11 @@ public static ResourceObjectIdentification createFromAttributes(ObjectClassCompl
return new ResourceObjectIdentification(objectClassDefinition, primaryIdentifiers, secondaryIdentifiers);
}

public static ResourceObjectIdentification createFromShadow(ObjectClassComplexTypeDefinition objectClassDefinition,
ShadowType shadowType) throws SchemaException {
return createFromAttributes(objectClassDefinition, ShadowUtil.getAttributes(shadowType));
}

public void validatePrimaryIdenfiers() {
if (!hasPrimaryIdentifiers()) {
throw new IllegalStateException("No primary identifiers in " + this);
Expand Down
Expand Up @@ -130,6 +130,9 @@ public abstract class AbstractManualResourceTest extends AbstractConfiguredModel
protected static final String USER_WILL_PASSWORD_OLD = "3lizab3th";
protected static final String USER_WILL_PASSWORD_NEW = "ELIZAbeth";

protected static final String ACCOUNT_JACK_DESCRIPTION_MANUAL = "Manuel";
protected static final String USER_JACK_PASSWORD_OLD = "deadM3NtellN0tales";

private static final File TASK_SHADOW_REFRESH_FILE = new File(TEST_DIR, "task-shadow-refresh.xml");
private static final String TASK_SHADOW_REFRESH_OID = "eb8f5be6-2b51-11e7-848c-2fd84a283b03";

Expand Down Expand Up @@ -2104,6 +2107,8 @@ public void test340RecomputeWillAfter25min() throws Exception {

// TODO: let grace period expire without updating the backing store (semi-manual-only)

// Tests 7xx are in the subclasses

/**
* The 8xx tests is similar routine as 1xx,2xx,3xx, but this time
* with automatic updates using refresh task.
Expand Down Expand Up @@ -2310,7 +2315,7 @@ private void assertAccountWillAfterAssign(final String TEST_NAME) throws Excepti
assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}

private void assertAccountJackAfterAssign(final String TEST_NAME) throws Exception {
protected void assertAccountJackAfterAssign(final String TEST_NAME) throws Exception {
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

Expand Down Expand Up @@ -2382,18 +2387,18 @@ private void assertWillAfterCreateCaseClosed(final String TEST_NAME, boolean bac
}


private void assertPendingOperationDeltas(PrismObject<ShadowType> shadow, int expectedNumber) {
protected void assertPendingOperationDeltas(PrismObject<ShadowType> shadow, int expectedNumber) {
List<PendingOperationType> pendingOperations = shadow.asObjectable().getPendingOperation();
assertEquals("Wroung number of pending operations in "+shadow, expectedNumber, pendingOperations.size());
}

private PendingOperationType assertSinglePendingOperation(PrismObject<ShadowType> shadow,
protected PendingOperationType assertSinglePendingOperation(PrismObject<ShadowType> shadow,
XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) {
return assertSinglePendingOperation(shadow, requestStart, requestEnd,
OperationResultStatusType.IN_PROGRESS, null, null);
}

private PendingOperationType assertSinglePendingOperation(PrismObject<ShadowType> shadow,
protected PendingOperationType assertSinglePendingOperation(PrismObject<ShadowType> shadow,
XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd,
OperationResultStatusType expectedStatus,
XMLGregorianCalendar completionStart, XMLGregorianCalendar completionEnd) {
Expand All @@ -2402,14 +2407,14 @@ private PendingOperationType assertSinglePendingOperation(PrismObject<ShadowType
requestStart, requestEnd, expectedStatus, completionStart, completionEnd);
}

private PendingOperationType assertPendingOperation(
protected PendingOperationType assertPendingOperation(
PrismObject<ShadowType> shadow, PendingOperationType pendingOperation,
XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd) {
return assertPendingOperation(shadow, pendingOperation, requestStart, requestEnd,
OperationResultStatusType.IN_PROGRESS, null, null);
}

private PendingOperationType assertPendingOperation(
protected PendingOperationType assertPendingOperation(
PrismObject<ShadowType> shadow, PendingOperationType pendingOperation,
XMLGregorianCalendar requestStart, XMLGregorianCalendar requestEnd,
OperationResultStatusType expectedStatus,
Expand All @@ -2432,7 +2437,7 @@ private PendingOperationType assertPendingOperation(
return pendingOperation;
}

private PendingOperationType findPendingOperation(PrismObject<ShadowType> shadow,
protected PendingOperationType findPendingOperation(PrismObject<ShadowType> shadow,
OperationResultStatusType expectedResult, ItemPath itemPath) {
List<PendingOperationType> pendingOperations = shadow.asObjectable().getPendingOperation();
for (PendingOperationType pendingOperation: pendingOperations) {
Expand Down

0 comments on commit cde3d1d

Please sign in to comment.