diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java index 374de31ba9..986c1d9660 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProcessor.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.chainofresponsibility; +package com.baeldung.chainofresponsibility; public abstract class AuthenticationProcessor { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java index 7b8771ca41..4d5e3bde24 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/AuthenticationProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.chainofresponsibility; +package com.baeldung.chainofresponsibility; public interface AuthenticationProvider { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java index 3bf20cfc85..5f994bad89 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthAuthenticationProcessor.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.chainofresponsibility; +package com.baeldung.chainofresponsibility; public class OAuthAuthenticationProcessor extends AuthenticationProcessor { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java index 92d5f94245..37f419b6e2 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/OAuthTokenProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.chainofresponsibility; +package com.baeldung.chainofresponsibility; public class OAuthTokenProvider implements AuthenticationProvider { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java index cd927932ad..3a0c35a9b9 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/SamlAuthenticationProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.chainofresponsibility; +package com.baeldung.chainofresponsibility; public class SamlAuthenticationProvider implements AuthenticationProvider { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java index 3885b2b79b..39038b1374 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordAuthenticationProcessor.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.chainofresponsibility; +package com.baeldung.chainofresponsibility; public class UsernamePasswordAuthenticationProcessor extends AuthenticationProcessor { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java index 9877039446..14dc93b8fc 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/chainofresponsibility/UsernamePasswordProvider.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.chainofresponsibility; +package com.baeldung.chainofresponsibility; public class UsernamePasswordProvider implements AuthenticationProvider { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/client/TextFileApplication.java b/patterns/design-patterns/src/main/java/com/baeldung/command/client/TextFileApplication.java index 30dcf08e89..878b67e0cf 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/command/client/TextFileApplication.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/command/client/TextFileApplication.java @@ -1,10 +1,10 @@ -package com.baeldung.pattern.command.client; +package com.baeldung.command.client; -import com.baeldung.pattern.command.command.OpenTextFileOperation; -import com.baeldung.pattern.command.command.SaveTextFileOperation; -import com.baeldung.pattern.command.command.TextFileOperation; -import com.baeldung.pattern.command.invoker.TextFileOperationExecutor; -import com.baeldung.pattern.command.receiver.TextFile; +import com.baeldung.command.command.OpenTextFileOperation; +import com.baeldung.command.command.SaveTextFileOperation; +import com.baeldung.command.command.TextFileOperation; +import com.baeldung.command.invoker.TextFileOperationExecutor; +import com.baeldung.command.receiver.TextFile; public class TextFileApplication { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java b/patterns/design-patterns/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java index c90a162b88..74adce0116 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/command/command/OpenTextFileOperation.java @@ -1,6 +1,6 @@ -package com.baeldung.pattern.command.command; +package com.baeldung.command.command; -import com.baeldung.pattern.command.receiver.TextFile; +import com.baeldung.command.receiver.TextFile; public class OpenTextFileOperation implements TextFileOperation { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java b/patterns/design-patterns/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java index b908e2c44c..f0462622e3 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/command/command/SaveTextFileOperation.java @@ -1,6 +1,6 @@ -package com.baeldung.pattern.command.command; +package com.baeldung.command.command; -import com.baeldung.pattern.command.receiver.TextFile; +import com.baeldung.command.receiver.TextFile; public class SaveTextFileOperation implements TextFileOperation { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/command/TextFileOperation.java b/patterns/design-patterns/src/main/java/com/baeldung/command/command/TextFileOperation.java index 506bb23d99..2d0267d315 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/command/command/TextFileOperation.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/command/command/TextFileOperation.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.command.command; +package com.baeldung.command.command; @FunctionalInterface public interface TextFileOperation { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java b/patterns/design-patterns/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java index bd2213706e..67c6dedd89 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/command/invoker/TextFileOperationExecutor.java @@ -1,6 +1,6 @@ -package com.baeldung.pattern.command.invoker; +package com.baeldung.command.invoker; -import com.baeldung.pattern.command.command.TextFileOperation; +import com.baeldung.command.command.TextFileOperation; import java.util.ArrayList; import java.util.List; diff --git a/patterns/design-patterns/src/main/java/com/baeldung/command/receiver/TextFile.java b/patterns/design-patterns/src/main/java/com/baeldung/command/receiver/TextFile.java index c0b2d3c41e..0163102256 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/command/receiver/TextFile.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/command/receiver/TextFile.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.command.receiver; +package com.baeldung.command.receiver; public class TextFile { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/application/Application.java b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/application/Application.java index 9ab34c3cd8..353a369837 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/application/Application.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/application/Application.java @@ -1,11 +1,9 @@ -package com.baeldung.pattern.templatemethod.application; +package com.baeldung.templatemethod.application; -import com.baeldung.pattern.templatemethod.model.Computer; -import com.baeldung.pattern.templatemethod.model.StandardComputer; -import com.baeldung.pattern.templatemethod.model.HighEndComputer; -import com.baeldung.pattern.templatemethod.model.ComputerBuilder; -import com.baeldung.pattern.templatemethod.model.HighEndComputerBuilder; -import com.baeldung.pattern.templatemethod.model.StandardComputerBuilder; +import com.baeldung.templatemethod.model.Computer; +import com.baeldung.templatemethod.model.ComputerBuilder; +import com.baeldung.templatemethod.model.HighEndComputerBuilder; +import com.baeldung.templatemethod.model.StandardComputerBuilder; public class Application { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/Computer.java b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/Computer.java index 1419398f62..129a8d4c65 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/Computer.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/Computer.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.templatemethod.model; +package com.baeldung.templatemethod.model; import java.util.HashMap; import java.util.Map; diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java index 515a6940f5..b5c7ee3987 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/ComputerBuilder.java @@ -1,6 +1,5 @@ -package com.baeldung.pattern.templatemethod.model; +package com.baeldung.templatemethod.model; -import com.baeldung.pattern.templatemethod.model.Computer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java index 0684b1b233..55394d1df6 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputer.java @@ -1,6 +1,5 @@ -package com.baeldung.pattern.templatemethod.model; +package com.baeldung.templatemethod.model; -import com.baeldung.pattern.templatemethod.model.Computer; import java.util.Map; public class HighEndComputer extends Computer { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java index c992aa2bff..2ee6f93f9b 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/HighEndComputerBuilder.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.templatemethod.model; +package com.baeldung.templatemethod.model; public class HighEndComputerBuilder extends ComputerBuilder { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java index 4e1d857016..3abe240316 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputer.java @@ -1,6 +1,5 @@ -package com.baeldung.pattern.templatemethod.model; +package com.baeldung.templatemethod.model; -import com.baeldung.pattern.templatemethod.model.Computer; import java.util.Map; public class StandardComputer extends Computer { diff --git a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java index cc81dddc1b..da2c2e9b2d 100644 --- a/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java +++ b/patterns/design-patterns/src/main/java/com/baeldung/templatemethod/model/StandardComputerBuilder.java @@ -1,4 +1,4 @@ -package com.baeldung.pattern.templatemethod.model; +package com.baeldung.templatemethod.model; public class StandardComputerBuilder extends ComputerBuilder { diff --git a/patterns/design-patterns/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java b/patterns/design-patterns/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java index 824b104f81..4556232815 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java +++ b/patterns/design-patterns/src/test/java/com/baeldung/chainofresponsibility/ChainOfResponsibilityIntegrationTest.java @@ -1,14 +1,9 @@ package com.baeldung.chainofresponsibility; -import org.junit.Test; -import com.baeldung.pattern.chainofresponsibility.AuthenticationProcessor; -import com.baeldung.pattern.chainofresponsibility.OAuthAuthenticationProcessor; -import com.baeldung.pattern.chainofresponsibility.OAuthTokenProvider; -import com.baeldung.pattern.chainofresponsibility.UsernamePasswordProvider; -import com.baeldung.pattern.chainofresponsibility.SamlAuthenticationProvider; -import com.baeldung.pattern.chainofresponsibility.UsernamePasswordAuthenticationProcessor; import static org.junit.Assert.assertTrue; +import org.junit.Test; + public class ChainOfResponsibilityIntegrationTest { private static AuthenticationProcessor getChainOfAuthProcessor() { diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java b/patterns/design-patterns/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java index 1c72bfdd2f..eac62313f7 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java +++ b/patterns/design-patterns/src/test/java/com/baeldung/command/test/OpenTextFileOperationUnitTest.java @@ -1,10 +1,12 @@ -package com.baeldung.pattern.command.test; +package com.baeldung.command.test; + +import static org.assertj.core.api.Assertions.assertThat; -import com.baeldung.pattern.command.command.OpenTextFileOperation; -import com.baeldung.pattern.command.command.TextFileOperation; -import com.baeldung.pattern.command.receiver.TextFile; import org.junit.Test; -import static org.assertj.core.api.Assertions.*; + +import com.baeldung.command.command.OpenTextFileOperation; +import com.baeldung.command.command.TextFileOperation; +import com.baeldung.command.receiver.TextFile; public class OpenTextFileOperationUnitTest { diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java b/patterns/design-patterns/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java index a7bc1f3025..3e47f10366 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java +++ b/patterns/design-patterns/src/test/java/com/baeldung/command/test/SaveTextFileOperationUnitTest.java @@ -1,10 +1,12 @@ -package com.baeldung.pattern.command.test; +package com.baeldung.command.test; + +import static org.assertj.core.api.Assertions.assertThat; -import com.baeldung.pattern.command.command.SaveTextFileOperation; -import com.baeldung.pattern.command.command.TextFileOperation; -import com.baeldung.pattern.command.receiver.TextFile; import org.junit.Test; -import static org.assertj.core.api.Assertions.*; + +import com.baeldung.command.command.SaveTextFileOperation; +import com.baeldung.command.command.TextFileOperation; +import com.baeldung.command.receiver.TextFile; public class SaveTextFileOperationUnitTest { diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java b/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java index efafa0d8a2..3861b1109e 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java +++ b/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileOperationExecutorUnitTest.java @@ -1,14 +1,17 @@ -package com.baeldung.pattern.command.test; +package com.baeldung.command.test; + +import static org.assertj.core.api.Assertions.assertThat; -import com.baeldung.pattern.command.command.OpenTextFileOperation; -import com.baeldung.pattern.command.command.SaveTextFileOperation; -import com.baeldung.pattern.command.command.TextFileOperation; -import com.baeldung.pattern.command.invoker.TextFileOperationExecutor; -import com.baeldung.pattern.command.receiver.TextFile; import java.util.function.Function; -import org.junit.Test; -import static org.assertj.core.api.Assertions.*; + import org.junit.BeforeClass; +import org.junit.Test; + +import com.baeldung.command.command.OpenTextFileOperation; +import com.baeldung.command.command.SaveTextFileOperation; +import com.baeldung.command.command.TextFileOperation; +import com.baeldung.command.invoker.TextFileOperationExecutor; +import com.baeldung.command.receiver.TextFile; public class TextFileOperationExecutorUnitTest { @@ -65,4 +68,11 @@ public class TextFileOperationExecutorUnitTest { Function executeMethodReference = SaveTextFileOperation::execute; assertThat(executeMethodReference.apply(new SaveTextFileOperation(new TextFile("file1.txt")))).isEqualTo("Saving file file1.txt"); } + + @Test + public void givenOpenAndSaveTextFileOperationExecutorInstance_whenCalledExecuteOperationWithLambdaExpression_thenBothAssertion() { + TextFileOperationExecutor textFileOperationExecutor = new TextFileOperationExecutor(); + assertThat(textFileOperationExecutor.executeOperation(() -> "Opening file file1.txt")).isEqualTo("Opening file file1.txt"); + assertThat(textFileOperationExecutor.executeOperation(() -> "Saving file file1.txt")).isEqualTo("Saving file file1.txt"); + } } diff --git a/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileUnitTest.java b/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileUnitTest.java index 32b83897c9..e35c785f3e 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileUnitTest.java +++ b/patterns/design-patterns/src/test/java/com/baeldung/command/test/TextFileUnitTest.java @@ -1,9 +1,11 @@ -package com.baeldung.pattern.command.test; +package com.baeldung.command.test; + +import static org.assertj.core.api.Assertions.assertThat; -import com.baeldung.pattern.command.receiver.TextFile; -import org.junit.Test; -import static org.assertj.core.api.Assertions.*; import org.junit.BeforeClass; +import org.junit.Test; + +import com.baeldung.command.receiver.TextFile; public class TextFileUnitTest { diff --git a/patterns/design-patterns/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java b/patterns/design-patterns/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java index 4ad4debb27..2c721be5da 100644 --- a/patterns/design-patterns/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java +++ b/patterns/design-patterns/src/test/java/com/baeldung/templatemethod/test/TemplateMethodPatternIntegrationTest.java @@ -1,14 +1,16 @@ package com.baeldung.templatemethod.test; -import com.baeldung.pattern.templatemethod.model.Computer; -import com.baeldung.pattern.templatemethod.model.HighEndComputerBuilder; -import com.baeldung.pattern.templatemethod.model.StandardComputerBuilder; -import org.junit.Assert; +import static org.hamcrest.CoreMatchers.instanceOf; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertThat; + +import com.baeldung.templatemethod.model.Computer; +import com.baeldung.templatemethod.model.HighEndComputerBuilder; +import com.baeldung.templatemethod.model.StandardComputerBuilder; public class TemplateMethodPatternIntegrationTest {