Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Return the last alertMessage available even if null
Browse files Browse the repository at this point in the history
This allows to clear a previous alert message

Signed-off-by: Gloria Ciavarrini <gciavarrini@redhat.com>
  • Loading branch information
gciavarrini authored and openshift-merge-robot committed Jun 15, 2023
1 parent ffc1e9c commit 842b574
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import com.redhat.parodos.workflows.work.WorkContext;
import com.redhat.parodos.workflows.work.WorkReport;
Expand Down Expand Up @@ -148,8 +147,7 @@ public WorkContext getWorkContext() {

@Override
public String getAlertMessage() {
return reports.stream().map(WorkReport::getAlertMessage).filter(Objects::nonNull)
.reduce((first, second) -> second).orElse(null);
return reports.stream().reduce((first, second) -> second).map(WorkReport::getAlertMessage).orElse(null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void testGetReports() {
@Test
public void testGetAlertMessage() {
assertThat(completedParallelFlowReport.getAlertMessage()).isEqualTo("alertMessage_2");
assertThat(failedParallelFlowReport.getAlertMessage()).isEqualTo("alertMessage_1");
assertThat(failedParallelFlowReport.getAlertMessage()).isNull();
assertThat(progressParallelFlowReport.getAlertMessage()).isEqualTo("alertMessage_3");
}

Expand Down

0 comments on commit 842b574

Please sign in to comment.