From 9a363746769877479e80fe55bb370ccaf27401cb Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Thu, 14 Nov 2024 18:05:25 +0300 Subject: [PATCH] Test fixes --- .../service/step/DefaultStepReporter.java | 13 ++++++++----- .../service/step/StepReporter.java | 18 ++++++++++-------- .../service/step/ManualNestedStepTest.java | 12 ++++++++---- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/epam/reportportal/service/step/DefaultStepReporter.java b/src/main/java/com/epam/reportportal/service/step/DefaultStepReporter.java index d9cba68e..230b9783 100644 --- a/src/main/java/com/epam/reportportal/service/step/DefaultStepReporter.java +++ b/src/main/java/com/epam/reportportal/service/step/DefaultStepReporter.java @@ -193,20 +193,23 @@ private void failParents() { * @param status finish status */ @Override - public void finishPreviousStep(@Nullable ItemStatus status) { - finishPreviousStepInternal(status).ifPresent(e -> { + @Nonnull + public Maybe finishPreviousStep(@Nullable ItemStatus status) { + return finishPreviousStepInternal(status).map(e -> { if (ItemStatus.FAILED.name().equalsIgnoreCase(e.getFinishTestItemRQ().getStatus())) { failParents(); } - }); + return e.getItemId(); + }).orElse(Maybe.empty()); } /** * Finish current step started by any of #sendStep methods. */ @Override - public void finishPreviousStep() { - finishPreviousStep(null); + @Nonnull + public Maybe finishPreviousStep() { + return finishPreviousStep(null); } @Override diff --git a/src/main/java/com/epam/reportportal/service/step/StepReporter.java b/src/main/java/com/epam/reportportal/service/step/StepReporter.java index b1e4ef0d..04ccf965 100644 --- a/src/main/java/com/epam/reportportal/service/step/StepReporter.java +++ b/src/main/java/com/epam/reportportal/service/step/StepReporter.java @@ -66,9 +66,11 @@ public interface StepReporter { void sendStep(@Nonnull ItemStatus status, @Nonnull String name, @Nullable Throwable throwable, @Nullable File... files); - void finishPreviousStep(@Nullable ItemStatus status); + @Nonnull + Maybe finishPreviousStep(@Nullable ItemStatus status); - void finishPreviousStep(); + @Nonnull + Maybe finishPreviousStep(); @Nonnull Maybe startNestedStep(@Nonnull StartTestItemRQ startStepRequest); @@ -134,15 +136,13 @@ class StepEntry { private final Date timestamp; private final FinishTestItemRQ finishTestItemRQ; - public StepEntry(@Nonnull Maybe itemId, @Nonnull Date stepStartTime, - @Nonnull FinishTestItemRQ finishTestItemRQ) { + public StepEntry(@Nonnull Maybe itemId, @Nonnull Date stepStartTime, @Nonnull FinishTestItemRQ finishTestItemRQ) { this.itemId = itemId; this.timestamp = stepStartTime; this.finishTestItemRQ = finishTestItemRQ; } - public StepEntry(@Nonnull Maybe itemId, - @Nonnull FinishTestItemRQ finishTestItemRQ) { + public StepEntry(@Nonnull Maybe itemId, @Nonnull FinishTestItemRQ finishTestItemRQ) { this(itemId, Calendar.getInstance().getTime(), finishTestItemRQ); } @@ -193,9 +193,11 @@ public void sendStep(@Nonnull ItemStatus status, @Nonnull String name, @Nullable @Override public void sendStep(@Nonnull ItemStatus status, @Nonnull String name, @Nullable Throwable throwable, @Nullable File... files) {} @Override - public void finishPreviousStep(@Nullable ItemStatus status) {} + @Nonnull + public Maybe finishPreviousStep(@Nullable ItemStatus status) {return Maybe.empty();} @Override - public void finishPreviousStep() {} + @Nonnull + public Maybe finishPreviousStep() {return Maybe.empty();} @Override @Nonnull public Maybe startNestedStep(@Nonnull StartTestItemRQ startStepRequest) {return Maybe.empty();} diff --git a/src/test/java/com/epam/reportportal/service/step/ManualNestedStepTest.java b/src/test/java/com/epam/reportportal/service/step/ManualNestedStepTest.java index 3911a0f2..b9bc58ea 100644 --- a/src/test/java/com/epam/reportportal/service/step/ManualNestedStepTest.java +++ b/src/test/java/com/epam/reportportal/service/step/ManualNestedStepTest.java @@ -162,7 +162,8 @@ public void verify_failed_nested_step_marks_parent_test_as_failed_nested_finish( sr.sendStep(ItemStatus.FAILED, stepName); verify(client, timeout(1000)).startTestItem(eq(testMethodUuid), any()); - sr.finishPreviousStep(); + //noinspection ResultOfMethodCallIgnored + sr.finishPreviousStep().blockingGet(); ArgumentCaptor finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); verify(client, timeout(1000)).finishTestItem(eq(nestedSteps.get(0)), finishStepCaptor.capture()); @@ -182,7 +183,8 @@ public void verify_failed_nested_finish_step_marks_parent_test_as_failed_nested_ sr.sendStep(stepName); verify(client, timeout(1000)).startTestItem(eq(testMethodUuid), any()); - sr.finishPreviousStep(ItemStatus.FAILED); + //noinspection ResultOfMethodCallIgnored + sr.finishPreviousStep(ItemStatus.FAILED).blockingGet(); ArgumentCaptor finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); verify(client, timeout(1000)).finishTestItem(eq(nestedSteps.get(0)), finishStepCaptor.capture()); @@ -364,7 +366,8 @@ public void verify_nested_step_manual_failure_set() { String logMessage = "Test message"; sr.sendStep(stepName, logMessage); sr.setStepStatus(ItemStatus.FAILED); - sr.finishPreviousStep(); + //noinspection ResultOfMethodCallIgnored + sr.finishPreviousStep().blockingGet(); verify(client, timeout(1000)).startTestItem(eq(testMethodUuid), any(StartTestItemRQ.class)); ArgumentCaptor finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); @@ -386,7 +389,8 @@ public void verify_nested_step_manual_failure_set_overrides_any_other_status() { String logMessage = "Test message"; sr.sendStep(ItemStatus.PASSED, stepName, logMessage); sr.setStepStatus(ItemStatus.PASSED); - sr.finishPreviousStep(ItemStatus.FAILED); + //noinspection ResultOfMethodCallIgnored + sr.finishPreviousStep(ItemStatus.FAILED).blockingGet(); verify(client, timeout(1000)).startTestItem(eq(testMethodUuid), any(StartTestItemRQ.class)); ArgumentCaptor finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);