Skip to content

Commit

Permalink
Adapt TestThresholdsStoryLiveSyncSimulate
Browse files Browse the repository at this point in the history
It is quite questionable how should we report transitions between
sync states when doing simulated synchronization.
  • Loading branch information
mederly committed Dec 13, 2022
1 parent bbe38e5 commit 02fd77f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ public interface TaskSynchronizationStatisticsCollector {
* We assume that we have a shadow with OID by that time.
* (If the OID is null we ignore further synchronization situation updates.)
*/
void onSynchronizationStart(@Nullable String processingIdentifier, @Nullable String shadowOid,
@Nullable SynchronizationSituationType situation);
void onSynchronizationStart(
@Nullable String processingIdentifier, @Nullable String shadowOid, @Nullable SynchronizationSituationType situation);

/**
* Informs the task that no synchronization will take place.
* Note that in theory it is possible that {@link #onSynchronizationStart(String, String, SynchronizationSituationType)} is called first.
*/
void onSynchronizationExclusion(@Nullable String processingIdentifier,
@NotNull SynchronizationExclusionReasonType exclusionReason);
void onSynchronizationExclusion(
@Nullable String processingIdentifier, @NotNull SynchronizationExclusionReasonType exclusionReason);

/**
* Informs the task that sync situation has changed for given shadow OID.
* There could be more such changes. But we are interested in the last one.
* If the shadow OID is null, we ignore such updates.
*/
void onSynchronizationSituationChange(@Nullable String processingIdentifier, @Nullable String shadowOid,
@Nullable SynchronizationSituationType situation);
void onSynchronizationSituationChange(
@Nullable String processingIdentifier, @Nullable String shadowOid, @Nullable SynchronizationSituationType situation);

/**
* Starts collecting synchronization statistics within the task.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.evolveum.midpoint.test.TestResource;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;

import static com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType.LINKED;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType.UNMATCHED;

/**
Expand All @@ -22,7 +23,8 @@
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class TestThresholdsStoryLiveSyncSimulate extends TestThresholdsStoryLiveSync {

static final TestResource<TaskType> TASK_LIVESYNC_OPENDJ_SIMULATE = new TestResource<>(TEST_DIR, "task-opendj-livesync-simulate.xml", "02e134e0-a740-4730-be6d-6521e63198e7");
private static final TestResource<TaskType> TASK_LIVESYNC_OPENDJ_SIMULATE = new TestResource<>(
TEST_DIR, "task-opendj-livesync-simulate.xml", "02e134e0-a740-4730-be6d-6521e63198e7");

@Override
protected TestResource<TaskType> getTaskTestResource() {
Expand Down Expand Up @@ -55,6 +57,7 @@ protected boolean isPreview() {
protected void assertAfterFirstImport(TaskType taskAfter) {
assertSyncToken(taskAfter, 3);

// @formatter:off
assertTask(taskAfter, "after")
.rootActivityState()
.itemProcessingStatistics()
Expand All @@ -63,8 +66,12 @@ protected void assertAfterFirstImport(TaskType taskAfter) {
.assertLastFailureObjectName("uid=user8,ou=people,dc=example,dc=com")
.end()
.synchronizationStatistics()
.assertTransition(null, UNMATCHED, UNMATCHED, null, 4, 1, 0)
.assertTransitions(1);
// the transition is recorded as to LINKED because we know it's simulated
// TODO decide about how it should be
.assertTransition(null, UNMATCHED, LINKED, null, 4, 0, 0)
.assertTransition(null, UNMATCHED, UNMATCHED, null, 0, 1, 0)
.assertTransitions(2);
// @formatter:on
}

/**
Expand All @@ -90,6 +97,7 @@ protected void assertAfterFirstImport(TaskType taskAfter) {
protected void assertAfterSecondImport(TaskType taskAfter) {
assertSyncToken(taskAfter, 3);

// @formatter:off
assertTask(taskAfter, "after")
.rootActivityState()
.itemProcessingStatistics()
Expand All @@ -98,8 +106,11 @@ protected void assertAfterSecondImport(TaskType taskAfter) {
.assertLastFailureObjectName("uid=user8,ou=people,dc=example,dc=com")
.end()
.synchronizationStatistics()
.assertTransition(UNMATCHED, UNMATCHED, UNMATCHED, null, 4, 1, 0)
.assertTransitions(1);
// See the above method
.assertTransition(null, UNMATCHED, LINKED, null, 4, 0, 0)
.assertTransition(null, UNMATCHED, UNMATCHED, null, 0, 1, 0)
.assertTransitions(2);
// @formatter:on
}

/**
Expand Down

0 comments on commit 02fd77f

Please sign in to comment.