Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 14, 2024
1 parent 26d2ddf commit 9a36374
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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 <code>#sendStep</code> methods.
*/
@Override
public void finishPreviousStep() {
finishPreviousStep(null);
@Nonnull
public Maybe<String> finishPreviousStep() {
return finishPreviousStep(null);
}

@Override
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/com/epam/reportportal/service/step/StepReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> finishPreviousStep(@Nullable ItemStatus status);

void finishPreviousStep();
@Nonnull
Maybe<String> finishPreviousStep();

@Nonnull
Maybe<String> startNestedStep(@Nonnull StartTestItemRQ startStepRequest);
Expand Down Expand Up @@ -134,15 +136,13 @@ class StepEntry {
private final Date timestamp;
private final FinishTestItemRQ finishTestItemRQ;

public StepEntry(@Nonnull Maybe<String> itemId, @Nonnull Date stepStartTime,
@Nonnull FinishTestItemRQ finishTestItemRQ) {
public StepEntry(@Nonnull Maybe<String> itemId, @Nonnull Date stepStartTime, @Nonnull FinishTestItemRQ finishTestItemRQ) {
this.itemId = itemId;
this.timestamp = stepStartTime;
this.finishTestItemRQ = finishTestItemRQ;
}

public StepEntry(@Nonnull Maybe<String> itemId,
@Nonnull FinishTestItemRQ finishTestItemRQ) {
public StepEntry(@Nonnull Maybe<String> itemId, @Nonnull FinishTestItemRQ finishTestItemRQ) {
this(itemId, Calendar.getInstance().getTime(), finishTestItemRQ);
}

Expand Down Expand Up @@ -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<String> finishPreviousStep(@Nullable ItemStatus status) {return Maybe.empty();}
@Override
public void finishPreviousStep() {}
@Nonnull
public Maybe<String> finishPreviousStep() {return Maybe.empty();}
@Override
@Nonnull
public Maybe<String> startNestedStep(@Nonnull StartTestItemRQ startStepRequest) {return Maybe.empty();}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FinishTestItemRQ> finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client, timeout(1000)).finishTestItem(eq(nestedSteps.get(0)), finishStepCaptor.capture());
Expand All @@ -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<FinishTestItemRQ> finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client, timeout(1000)).finishTestItem(eq(nestedSteps.get(0)), finishStepCaptor.capture());
Expand Down Expand Up @@ -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<FinishTestItemRQ> finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
Expand All @@ -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<FinishTestItemRQ> finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
Expand Down

0 comments on commit 9a36374

Please sign in to comment.