Skip to content

Commit

Permalink
Adapt existing iterative task assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Feb 24, 2021
1 parent 3763954 commit 647ddf6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
Expand Up @@ -121,6 +121,14 @@ public static int getItemsProcessedWithFailure(IterativeTaskInformationType info
}
}

public static int getItemsProcessedWithSkip(IterativeTaskInformationType info) {
if (info != null) {
return getCounts(getProcessingComponents(info), TaskTypeUtil::isSkip);
} else {
return 0;
}
}

/**
* Provides aggregated operation statistics from this task and all its subtasks.
* Works with stored operation stats, obviously. (We have no task instances here.)
Expand Down Expand Up @@ -277,4 +285,7 @@ public static boolean isFailure(ProcessedItemSetType set) {
return set.getOutcome() != null && set.getOutcome().getOutcome() == ItemProcessingOutcomeType.FAILURE;
}

public static boolean isSkip(ProcessedItemSetType set) {
return set.getOutcome() != null && set.getOutcome().getOutcome() == ItemProcessingOutcomeType.SKIP;
}
}
Expand Up @@ -407,6 +407,7 @@ public void test150ImportFromResourceDummy() throws Exception {
.assertTransitions(5)
.end()
.iterativeTaskInformation()
.display()
.assertTotalCounts(7, 0)
.end()
.assertProgress(7);
Expand Down Expand Up @@ -484,6 +485,7 @@ public void test155ImportFromResourceDummyAgain() throws Exception {
.assertTransitions(2)
.end()
.iterativeTaskInformation()
.display()
.assertTotalCounts(7, 0)
.end()
.assertProgress(7);
Expand Down Expand Up @@ -571,6 +573,7 @@ public void test160ImportFromResourceDummyLime() throws Exception {
.assertTransitions(2)
.end()
.iterativeTaskInformation()
.display()
.assertTotalCounts(3, 0)
.end()
.assertProgress(3);
Expand Down Expand Up @@ -832,6 +835,7 @@ public void test200ReconcileDummy() throws Exception {
.assertTransitions(2)
.end()
.iterativeTaskInformation()
.display()
.assertTotalCounts(9, 0) // protected accounts are processed also in the third stage
.end();
//.assertProgress(7); // TODO - specify meaning of progress for reconciliation tasks
Expand Down Expand Up @@ -1097,6 +1101,7 @@ public void test220ReconcileDummyBrokenGuybrush() throws Exception {
.assertTransitions(2)
.end()
.iterativeTaskInformation()
.display()
.assertTotalCounts(8, 1)
.end();
//.assertProgress(7); // TODO - specify meaning of progress for reconciliation tasks
Expand Down Expand Up @@ -1282,6 +1287,7 @@ public void test230ReconcileDummyRename() throws Exception {
.assertTransitions(3)
.end()
.iterativeTaskInformation()
.display()
.assertTotalCounts(10, 0)
.end();
//.assertProgress(8); // TODO - specify meaning of progress for reconciliation tasks
Expand Down
Expand Up @@ -27,9 +27,21 @@ public class IterativeTaskInfoAsserter<RA> extends AbstractAsserter<RA> {
this.information = information;
}

public IterativeTaskInfoAsserter<RA> assertTotalCounts(int success, int failure) {
public IterativeTaskInfoAsserter<RA> assertTotalCounts(int nonFailure, int failure) {
assertNonFailureCount(nonFailure);
assertFailureCount(failure);
return this;
}

public IterativeTaskInfoAsserter<RA> assertTotalCounts(int success, int failure, int skip) {
assertSuccessCount(success);
assertFailureCount(failure);
assertSkipCount(skip);
return this;
}

public IterativeTaskInfoAsserter<RA> assertNonFailureCount(int success) {
assertEquals("Wrong value of total 'non-failure' counter", success, getNonFailureCount());
return this;
}

Expand All @@ -38,6 +50,11 @@ public IterativeTaskInfoAsserter<RA> assertSuccessCount(int success) {
return this;
}

public IterativeTaskInfoAsserter<RA> assertSkipCount(int skip) {
assertEquals("Wrong value of total skip counter", skip, getSkipCount());
return this;
}

public IterativeTaskInfoAsserter<RA> assertSuccessCount(int min, int max) {
assertBetween(getSuccessCount(), min, max, "Total success counter");
return this;
Expand Down Expand Up @@ -84,6 +101,14 @@ private int getFailureCount() {
return TaskTypeUtil.getItemsProcessedWithFailure(information);
}

private int getSkipCount() {
return TaskTypeUtil.getItemsProcessedWithSkip(information);
}

private int getNonFailureCount() {
return getSuccessCount() + getSkipCount();
}

private String getLastFailedObjectName() {
return TaskTypeUtil.getLastProcessedObjectName(information, TaskTypeUtil::isFailure);
}
Expand Down

0 comments on commit 647ddf6

Please sign in to comment.