use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.
the class TestOpenDjNegative method test195SynchronizeAllClasses.
@Test
public void test195SynchronizeAllClasses() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, null, null, null);
try {
mockLiveSyncTaskHandler.synchronize(coords, new DummyTokenStorageImpl(), task, result);
AssertJUnit.fail("synchronize succeeded unexpectedly");
} catch (CommunicationException e) {
// Now the problem is right in the sync ConnId call.
displayExpectedException(e);
}
result.computeStatus();
TestUtil.assertFailure(result);
}
use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.
the class TestOpenDjNegative method test190Synchronize.
@Test
public void test190Synchronize() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, new QName(RESOURCE_NS, OBJECT_CLASS_INETORGPERSON_NAME));
try {
mockLiveSyncTaskHandler.synchronize(coords, new DummyTokenStorageImpl(), task, result);
AssertJUnit.fail("synchronize succeeded unexpectedly");
} catch (ConfigurationException e) {
// When asking for specific object class, we expect configuration exception.
// (Because there's no schema.)
displayExpectedException(e);
}
result.computeStatus();
TestUtil.assertFailure(result);
}
use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.
the class TestDummyNegative method test270LiveSyncBrokenAccountsExternalUid.
@Test
public void test270LiveSyncBrokenAccountsExternalUid() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
DummyTokenStorageImpl tokenStorage = new DummyTokenStorageImpl();
cleanupAccounts(RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID, result);
RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.controller.setSyncStyle(DummySyncStyle.SMART);
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.oid, SchemaConstants.RI_ACCOUNT_OBJECT_CLASS);
List<LiveSyncEvent> events = new ArrayList<>();
LiveSyncEventHandler handler = new LiveSyncEventHandler() {
@Override
public void allEventsSubmitted(OperationResult result) {
}
@Override
public boolean handle(LiveSyncEvent event, OperationResult opResult) {
events.add(event);
event.acknowledge(true, opResult);
return true;
}
};
provisioningService.synchronize(coords, null, tokenStorage, handler, task, result);
assertThat(events).isEmpty();
createAccountExternalUid(GOOD_ACCOUNT, 1, null);
createAccountExternalUid(INCONVERTIBLE_ACCOUNT, 2, "WRONG");
createAccountExternalUid(UNSTORABLE_ACCOUNT, "WRONG", null);
createAccountExternalUid(TOTALLY_UNSTORABLE_ACCOUNT, 4, null);
when();
provisioningService.synchronize(coords, null, tokenStorage, handler, task, result);
then();
display("events", events);
assertThat(events.size()).as("events found").isEqualTo(4);
List<PrismObject<ShadowType>> objects = events.stream().filter(event -> event.getChangeDescription() != null).map(event -> event.getChangeDescription().getShadowedResourceObject()).collect(Collectors.toList());
assertSelectedAccountByName(objects, GOOD_ACCOUNT).assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(GOOD_ACCOUNT_UID).assertName(GOOD_ACCOUNT).attributes().assertSize(3).end().assertSuccessOrNoFetchResult();
PrismObject<ShadowType> goodAfter = findShadowByPrismName(GOOD_ACCOUNT, RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.object, result);
assertShadow(goodAfter, GOOD_ACCOUNT).display().assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(GOOD_ACCOUNT_UID).attributes().assertSize(3).end();
assertSelectedAccountByName(objects, INCONVERTIBLE_ACCOUNT_UID).assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(INCONVERTIBLE_ACCOUNT_UID).assertName(INCONVERTIBLE_ACCOUNT_UID).attributes().assertSize(// uid=uid:inconvertible (for some reason number=2 is not there)
1).end();
// name is now derived from UID
PrismObject<ShadowType> inconvertibleAfter = findShadowByPrismName(INCONVERTIBLE_ACCOUNT_UID, RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.object, result);
assertShadow(inconvertibleAfter, INCONVERTIBLE_ACCOUNT).display().assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(INCONVERTIBLE_ACCOUNT_UID).attributes().assertSize(1).end();
assertSelectedAccountByName(objects, UNSTORABLE_ACCOUNT_UID).assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(UNSTORABLE_ACCOUNT_UID).assertName(UNSTORABLE_ACCOUNT_UID).attributes().assertSize(// uid=unstorable
1).end();
// name is now derived from UID
PrismObject<ShadowType> unstorableAfter = findShadowByPrismName(UNSTORABLE_ACCOUNT_UID, RESOURCE_DUMMY_BROKEN_ACCOUNTS_EXTERNAL_UID.object, result);
assertShadow(unstorableAfter, UNSTORABLE_ACCOUNT).display().assertOid().assertKind(ShadowKindType.ACCOUNT).assertPrimaryIdentifierValue(UNSTORABLE_ACCOUNT_UID).attributes().assertSize(1).end();
// The fetch result is not in the shadows. The exception is recorded in events.
List<LiveSyncEvent> noChangeEvents = events.stream().filter(event -> event.getChangeDescription() == null).collect(Collectors.toList());
if (isSqaleRepository()) {
// Totally unstorable account is storable
return;
}
assertThat(noChangeEvents).hasSize(1);
LiveSyncEvent failedEvent = noChangeEvents.get(0);
displayDumpable("failed event", failedEvent);
assertThat(failedEvent.isError()).isTrue();
}
use of com.evolveum.midpoint.provisioning.impl.DummyTokenStorageImpl in project midpoint by Evolveum.
the class TestOpenDjNegative method test590Synchronize.
@Test
public void test590Synchronize() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
ResourceShadowDiscriminator coords = new ResourceShadowDiscriminator(RESOURCE_OPENDJ_OID, new QName(RESOURCE_NS, OBJECT_CLASS_INETORGPERSON_NAME));
try {
mockLiveSyncTaskHandler.synchronize(coords, new DummyTokenStorageImpl(), task, result);
AssertJUnit.fail("addObject succeeded unexpectedly");
} catch (CommunicationException e) {
// The schema is there. So we expect the exception when contacting the resource.
displayExpectedException(e);
}
assertFailure(result);
}
Aggregations