Skip to content

Commit

Permalink
Add a test for failing getObject+forceRetry
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed May 10, 2021
1 parent a158f3b commit bc3f551
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Expand Up @@ -12,6 +12,8 @@
import java.util.Collection;
import javax.xml.datatype.XMLGregorianCalendar;

import com.evolveum.midpoint.test.TestResource;

import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Listeners;
Expand Down Expand Up @@ -67,6 +69,8 @@ public class TestDummyConsistency extends AbstractDummyTest {
private static final String ACCOUNT_MURRAY_USERNAME = "murray";
private static final String ACCOUNT_MURRAY_FULL_NAME = "Murray";

private static final TestResource<ShadowType> ACCOUNT_LATE = new TestResource<>(TEST_DIR, "account-late.xml", "9f2bc5b3-61ea-4b59-9ee4-901affe5c8c8");

private XMLGregorianCalendar lastRequestStartTs;
private XMLGregorianCalendar lastRequestEndTs;
private XMLGregorianCalendar lastAttemptStartTs;
Expand Down Expand Up @@ -2063,6 +2067,37 @@ public void test910ModifyMorganFullNameTwiceCommunicationFailure() throws Except
.assertValue(dummyResourceCtl.getAttributeFullnameQName(), ACCOUNT_MORGAN_FULLNAME_CHM);
}

@Test(enabled = false)
public void test920ForceRetryOnUnAddedAccount() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
syncServiceMock.reset();

dummyResource.setBreakMode(BreakMode.NETWORK);

PrismObject<ShadowType> account = prismContext.parseObject(ACCOUNT_LATE.file);
account.checkConsistence();
display("Adding shadow", account);

when();
String addedObjectOid = provisioningService.addObject(account, null, null, task, result);

then();
display("Result", result);
assertInProgress(result);

when("get with forceRetry");
var options = schemaService.getOperationOptionsBuilder()
.forceRetry()
.build();

provisioningService.getObject(ShadowType.class, addedObjectOid, options, task, result);

then("get with forceRetry");
assertSuccess(result);
}

private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception {

// @formatter:off
Expand Down
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<shadow oid="9f2bc5b3-61ea-4b59-9ee4-901affe5c8c8"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-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/ef2bc95b-76e0-59e2-86d6-9999dddddddd">
<resourceRef oid="ef2bc95b-76e0-59e2-86d6-9999dddddddd" />
<objectClass>ri:AccountObjectClass</objectClass>
<kind>account</kind>
<attributes>
<icfs:name>late</icfs:name>
</attributes>
</shadow>

0 comments on commit bc3f551

Please sign in to comment.