From 26b4b82949ae2afb4e2aab94a2c96ee07acff5aa Mon Sep 17 00:00:00 2001
From: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Date: Wed, 3 Jul 2024 18:55:09 +0200
Subject: [PATCH] style: include `OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION`
(#5274)
---
spotbugs-exclude.xml | 3 ---
.../com/thealgorithms/searches/BreadthFirstSearchTest.java | 4 ++--
.../java/com/thealgorithms/searches/DepthFirstSearchTest.java | 4 ++--
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 8648b910..9aa2e50f 100644
--- a/spotbugs-exclude.xml
+++ b/spotbugs-exclude.xml
@@ -123,9 +123,6 @@
-
-
-
diff --git a/src/test/java/com/thealgorithms/searches/BreadthFirstSearchTest.java b/src/test/java/com/thealgorithms/searches/BreadthFirstSearchTest.java
index 2a32a4dd..d05856dd 100644
--- a/src/test/java/com/thealgorithms/searches/BreadthFirstSearchTest.java
+++ b/src/test/java/com/thealgorithms/searches/BreadthFirstSearchTest.java
@@ -53,7 +53,7 @@ public class BreadthFirstSearchTest {
// check value
Optional> value = bfs.search(root, expectedValue);
- assertEquals(expectedValue, value.orElse(new Node<>("")).getValue());
+ assertEquals(expectedValue, value.orElseGet(() -> new Node<>("")).getValue());
// check path
assertArrayEquals(expectedPath.toArray(), bfs.getVisited().toArray());
@@ -65,7 +65,7 @@ public class BreadthFirstSearchTest {
List expectedPath = List.of("A", "B", "C", "D", "E", "F");
// check value
- Optional> value = Optional.of(bfs.search(root, expectedValue).orElse(new Node<>(null)));
+ Optional> value = Optional.of(bfs.search(root, expectedValue).orElseGet(() -> new Node<>(null)));
assertEquals(expectedValue, value.get().getValue());
// check path
diff --git a/src/test/java/com/thealgorithms/searches/DepthFirstSearchTest.java b/src/test/java/com/thealgorithms/searches/DepthFirstSearchTest.java
index af21b570..2785d48b 100644
--- a/src/test/java/com/thealgorithms/searches/DepthFirstSearchTest.java
+++ b/src/test/java/com/thealgorithms/searches/DepthFirstSearchTest.java
@@ -54,7 +54,7 @@ public class DepthFirstSearchTest {
// check value
Optional> value = dfs.recursiveSearch(root, expectedValue);
- assertEquals(expectedValue, value.orElse(new Node<>(null)).getValue());
+ assertEquals(expectedValue, value.orElseGet(() -> new Node<>(null)).getValue());
// check path
assertArrayEquals(expectedPath.toArray(), dfs.getVisited().toArray());
@@ -67,7 +67,7 @@ public class DepthFirstSearchTest {
// check value
Optional> value = dfs.recursiveSearch(root, expectedValue);
- assertEquals(expectedValue, value.orElse(new Node<>(null)).getValue());
+ assertEquals(expectedValue, value.orElseGet(() -> new Node<>(null)).getValue());
// check path
assertArrayEquals(expectedPath.toArray(), dfs.getVisited().toArray());