From b8b8ed889b1536d9359891d7ab7ec7b8d36bb66b Mon Sep 17 00:00:00 2001 From: panos-kakos <102670093+panos-kakos@users.noreply.github.com> Date: Wed, 16 Nov 2022 19:42:28 +0000 Subject: [PATCH] [JAVA-13963] Align code with article + clean up (#13013) Co-authored-by: panagiotiskakos --- .../CompletableFutureLongRunningUnitTest.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) rename core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/{ => concurrent}/completablefuture/CompletableFutureLongRunningUnitTest.java (95%) diff --git a/core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java b/core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/concurrent/completablefuture/CompletableFutureLongRunningUnitTest.java similarity index 95% rename from core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java rename to core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/concurrent/completablefuture/CompletableFutureLongRunningUnitTest.java index d9cf8ae019..9e0a9e2abe 100644 --- a/core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java +++ b/core-java-modules/core-java-concurrency-simple/src/test/java/com/baeldung/concurrent/completablefuture/CompletableFutureLongRunningUnitTest.java @@ -1,8 +1,6 @@ -package com.baeldung.completablefuture; +package com.baeldung.concurrent.completablefuture; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.concurrent.CancellationException; import java.util.concurrent.CompletableFuture; @@ -17,8 +15,6 @@ import static org.junit.Assert.assertTrue; public class CompletableFutureLongRunningUnitTest { - private static final Logger LOG = LoggerFactory.getLogger(CompletableFutureLongRunningUnitTest.class); - @Test public void whenRunningCompletableFutureAsynchronously_thenGetMethodWaitsForResult() throws InterruptedException, ExecutionException { Future completableFuture = calculateAsync(); @@ -78,7 +74,7 @@ public class CompletableFutureLongRunningUnitTest { public void whenAddingThenAcceptToFuture_thenFunctionExecutesAfterComputationIsFinished() throws ExecutionException, InterruptedException { CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> "Hello"); - CompletableFuture future = completableFuture.thenAccept(s -> LOG.debug("Computation returned: " + s)); + CompletableFuture future = completableFuture.thenAccept(s -> System.out.println("Computation returned: " + s)); future.get(); } @@ -87,7 +83,7 @@ public class CompletableFutureLongRunningUnitTest { public void whenAddingThenRunToFuture_thenFunctionExecutesAfterComputationIsFinished() throws ExecutionException, InterruptedException { CompletableFuture completableFuture = CompletableFuture.supplyAsync(() -> "Hello"); - CompletableFuture future = completableFuture.thenRun(() -> LOG.debug("Computation finished.")); + CompletableFuture future = completableFuture.thenRun(() -> System.out.println("Computation finished.")); future.get(); } @@ -120,7 +116,7 @@ public class CompletableFutureLongRunningUnitTest { @Test public void whenUsingThenAcceptBoth_thenWaitForExecutionOfBothFutures() throws ExecutionException, InterruptedException { CompletableFuture.supplyAsync(() -> "Hello") - .thenAcceptBoth(CompletableFuture.supplyAsync(() -> " World"), (s1, s2) -> LOG.debug(s1 + s2)); + .thenAcceptBoth(CompletableFuture.supplyAsync(() -> " World"), (s1, s2) -> System.out.println(s1 + s2)); } @Test