From b2a04072bd5b96a621a9e4e0dde8f8e91605d327 Mon Sep 17 00:00:00 2001 From: Sergey Kapralov Date: Wed, 3 Aug 2022 10:21:55 +0300 Subject: [PATCH] #20: Outlined all tests and their dependencies to a separate module --- oo-memoized/memoized-chm/pom.xml | 4 ++ oo-memoized/memoized-core/pom.xml | 19 -------- .../oo/memoized/core/package-info.java | 26 ----------- oo-memoized/memoized-tests/pom.xml | 43 +++++++++++++++++++ .../memoized/assertions}/AssertCallTimes.java | 8 ++-- .../memoized/assertions}/AssertDisposal.java | 6 ++- .../oo/memoized/assertions}/TestCallable.java | 6 ++- .../assertions}/AssertCallTimesTest.java | 8 ++-- .../assertions}/AssertDisposalTest.java | 4 +- .../oo/memoized/assertions}/BluntMemory.java | 8 +++- .../oo/memoized/assertions}/package-info.java | 4 +- .../oo/memoized/chm/MemoryCHMTest.java | 6 +-- .../oo/memoized/chm/package-info.java | 2 +- oo-memoized/pom.xml | 11 +++++ 14 files changed, 89 insertions(+), 66 deletions(-) delete mode 100644 oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/package-info.java create mode 100644 oo-memoized/memoized-tests/pom.xml rename oo-memoized/{memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core => memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions}/AssertCallTimes.java (92%) rename oo-memoized/{memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core => memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions}/AssertDisposal.java (93%) rename oo-memoized/{memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core => memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions}/TestCallable.java (93%) rename oo-memoized/{memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core => memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions}/AssertCallTimesTest.java (93%) rename oo-memoized/{memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core => memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions}/AssertDisposalTest.java (96%) rename oo-memoized/{memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core => memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions}/BluntMemory.java (90%) rename oo-memoized/{memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core => memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions}/package-info.java (95%) rename oo-memoized/{memoized-chm => memoized-tests}/src/test/java/com/pragmaticobjects/oo/memoized/chm/MemoryCHMTest.java (95%) rename oo-memoized/{memoized-chm => memoized-tests}/src/test/java/com/pragmaticobjects/oo/memoized/chm/package-info.java (98%) diff --git a/oo-memoized/memoized-chm/pom.xml b/oo-memoized/memoized-chm/pom.xml index bae53f8a..f48e1f25 100644 --- a/oo-memoized/memoized-chm/pom.xml +++ b/oo-memoized/memoized-chm/pom.xml @@ -14,5 +14,9 @@ com.pragmaticobjects.oo.memoized memoized-core + + org.slf4j + slf4j-api + \ No newline at end of file diff --git a/oo-memoized/memoized-core/pom.xml b/oo-memoized/memoized-core/pom.xml index 516d872d..81372bec 100644 --- a/oo-memoized/memoized-core/pom.xml +++ b/oo-memoized/memoized-core/pom.xml @@ -9,23 +9,4 @@ memoized-core jar ${project.artifactId} - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-simple - test - - - com.pragmaticobjects.oo.tests - tests-junit5 - - - org.assertj - assertj-core - - \ No newline at end of file diff --git a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/package-info.java b/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/package-info.java deleted file mode 100644 index 1bccf308..00000000 --- a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * =========================================================================== - * memoized-core - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Copyright (C) 2019 - 2022 Kapralov Sergey - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * ============================================================================ - */ -package com.pragmaticobjects.oo.memoized.core; diff --git a/oo-memoized/memoized-tests/pom.xml b/oo-memoized/memoized-tests/pom.xml new file mode 100644 index 00000000..92da87ae --- /dev/null +++ b/oo-memoized/memoized-tests/pom.xml @@ -0,0 +1,43 @@ + + + + oo-memoized + com.pragmaticobjects.oo.memoized + 0.0.0-SNAPSHOT + + 4.0.0 + + memoized-assertions + jar + ${project.artifactId} + + + + com.pragmaticobjects.oo.memoized + memoized-core + + + com.pragmaticobjects.oo.memoized + memoized-chm + + + com.pragmaticobjects.oo.tests + tests-junit5 + + + org.assertj + assertj-core + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + test + + + \ No newline at end of file diff --git a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/AssertCallTimes.java b/oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/AssertCallTimes.java similarity index 92% rename from oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/AssertCallTimes.java rename to oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/AssertCallTimes.java index 4d6ff981..dfc4c675 100644 --- a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/AssertCallTimes.java +++ b/oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/AssertCallTimes.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-core + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,13 +23,15 @@ * THE SOFTWARE. * ============================================================================ */ -package com.pragmaticobjects.oo.memoized.core; +package com.pragmaticobjects.oo.memoized.assertions; import com.pragmaticobjects.oo.tests.Assertion; import org.assertj.core.api.Assertions; import java.util.concurrent.atomic.AtomicInteger; +import com.pragmaticobjects.oo.memoized.core.Memory; + public class AssertCallTimes implements Assertion { private final Memory memory; private final int callNums; @@ -44,7 +46,7 @@ public AssertCallTimes(Memory memory, int callNums, int expectedNumCalls) { @Override public final void check() throws Exception { AtomicInteger counter = new AtomicInteger(); - for(int i = 0; i < callNums; i++) { + for (int i = 0; i < callNums; i++) { memory.memoized(new TestCallable(counter)); } Assertions.assertThat(counter).hasValue(expectedNumCalls); diff --git a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/AssertDisposal.java b/oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/AssertDisposal.java similarity index 93% rename from oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/AssertDisposal.java rename to oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/AssertDisposal.java index 697676df..5bddb6b5 100644 --- a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/AssertDisposal.java +++ b/oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/AssertDisposal.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-core + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,8 +23,10 @@ * THE SOFTWARE. * ============================================================================ */ -package com.pragmaticobjects.oo.memoized.core; +package com.pragmaticobjects.oo.memoized.assertions; +import com.pragmaticobjects.oo.memoized.core.MemoizedCallable; +import com.pragmaticobjects.oo.memoized.core.Memory; import com.pragmaticobjects.oo.tests.Assertion; import io.vavr.collection.List; import org.assertj.core.api.Assertions; diff --git a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/TestCallable.java b/oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/TestCallable.java similarity index 93% rename from oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/TestCallable.java rename to oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/TestCallable.java index 071241ac..31d3903e 100644 --- a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/TestCallable.java +++ b/oo-memoized/memoized-tests/src/main/java/com/pragmaticobjects/oo/memoized/assertions/TestCallable.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-core + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,7 +23,9 @@ * THE SOFTWARE. * ============================================================================ */ -package com.pragmaticobjects.oo.memoized.core; +package com.pragmaticobjects.oo.memoized.assertions; + +import com.pragmaticobjects.oo.memoized.core.MemoizedCallable; import java.util.concurrent.atomic.AtomicInteger; diff --git a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/AssertCallTimesTest.java b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/AssertCallTimesTest.java similarity index 93% rename from oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/AssertCallTimesTest.java rename to oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/AssertCallTimesTest.java index 05bf2da8..0b5c9f9d 100644 --- a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/AssertCallTimesTest.java +++ b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/AssertCallTimesTest.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-core + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,7 +23,7 @@ * THE SOFTWARE. * ============================================================================ */ -package com.pragmaticobjects.oo.memoized.core; +package com.pragmaticobjects.oo.memoized.assertions; import com.pragmaticobjects.oo.tests.AssertAssertionPasses; import com.pragmaticobjects.oo.tests.TestCase; @@ -40,8 +40,8 @@ public AssertCallTimesTest() { new AssertAssertionPasses( new AssertCallTimes( new BluntMemory(), - 10, - 10 + 10, + 10 ) ) ) diff --git a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/AssertDisposalTest.java b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/AssertDisposalTest.java similarity index 96% rename from oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/AssertDisposalTest.java rename to oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/AssertDisposalTest.java index 9547cb0e..b5b392ee 100644 --- a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/AssertDisposalTest.java +++ b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/AssertDisposalTest.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-core + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,7 +23,7 @@ * THE SOFTWARE. * ============================================================================ */ -package com.pragmaticobjects.oo.memoized.core; +package com.pragmaticobjects.oo.memoized.assertions; import com.pragmaticobjects.oo.tests.AssertAssertionPasses; import com.pragmaticobjects.oo.tests.TestCase; diff --git a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/BluntMemory.java b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/BluntMemory.java similarity index 90% rename from oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/BluntMemory.java rename to oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/BluntMemory.java index aa72d8fb..b3f6d501 100644 --- a/oo-memoized/memoized-core/src/test/java/com/pragmaticobjects/oo/memoized/core/BluntMemory.java +++ b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/BluntMemory.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-core + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,10 +23,14 @@ * THE SOFTWARE. * ============================================================================ */ -package com.pragmaticobjects.oo.memoized.core; +package com.pragmaticobjects.oo.memoized.assertions; + +import com.pragmaticobjects.oo.memoized.core.MemoizedCallable; +import com.pragmaticobjects.oo.memoized.core.Memory; import java.util.Optional; + /** * Test {@link Memory} implementation that memoises nothing */ diff --git a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/package-info.java b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/package-info.java similarity index 95% rename from oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/package-info.java rename to oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/package-info.java index 1bccf308..d9a4afce 100644 --- a/oo-memoized/memoized-core/src/main/java/com/pragmaticobjects/oo/memoized/core/package-info.java +++ b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/assertions/package-info.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-core + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,4 +23,4 @@ * THE SOFTWARE. * ============================================================================ */ -package com.pragmaticobjects.oo.memoized.core; +package com.pragmaticobjects.oo.memoized.assertions; diff --git a/oo-memoized/memoized-chm/src/test/java/com/pragmaticobjects/oo/memoized/chm/MemoryCHMTest.java b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/chm/MemoryCHMTest.java similarity index 95% rename from oo-memoized/memoized-chm/src/test/java/com/pragmaticobjects/oo/memoized/chm/MemoryCHMTest.java rename to oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/chm/MemoryCHMTest.java index ce55971b..329e433c 100644 --- a/oo-memoized/memoized-chm/src/test/java/com/pragmaticobjects/oo/memoized/chm/MemoryCHMTest.java +++ b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/chm/MemoryCHMTest.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-chm + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -26,8 +26,8 @@ package com.pragmaticobjects.oo.memoized.chm; -import com.pragmaticobjects.oo.memoized.core.AssertCallTimes; -import com.pragmaticobjects.oo.memoized.core.AssertDisposal; +import com.pragmaticobjects.oo.memoized.assertions.AssertCallTimes; +import com.pragmaticobjects.oo.memoized.assertions.AssertDisposal; import com.pragmaticobjects.oo.memoized.core.MemoizedCallable; import com.pragmaticobjects.oo.tests.TestCase; import com.pragmaticobjects.oo.tests.junit5.TestsSuite; diff --git a/oo-memoized/memoized-chm/src/test/java/com/pragmaticobjects/oo/memoized/chm/package-info.java b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/chm/package-info.java similarity index 98% rename from oo-memoized/memoized-chm/src/test/java/com/pragmaticobjects/oo/memoized/chm/package-info.java rename to oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/chm/package-info.java index 9b029162..a24f2206 100644 --- a/oo-memoized/memoized-chm/src/test/java/com/pragmaticobjects/oo/memoized/chm/package-info.java +++ b/oo-memoized/memoized-tests/src/test/java/com/pragmaticobjects/oo/memoized/chm/package-info.java @@ -1,6 +1,6 @@ /*- * =========================================================================== - * memoized-chm + * memoized-assertions * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Copyright (C) 2019 - 2022 Kapralov Sergey * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/oo-memoized/pom.xml b/oo-memoized/pom.xml index eb6bf0b4..5d0d9641 100644 --- a/oo-memoized/pom.xml +++ b/oo-memoized/pom.xml @@ -38,6 +38,7 @@ memoized-core memoized-chm + memoized-tests @@ -47,6 +48,16 @@ memoized-core ${project.version} + + com.pragmaticobjects.oo.memoized + memoized-assertions + ${project.version} + + + com.pragmaticobjects.oo.memoized + memoized-chm + ${project.version} + com.pragmaticobjects.oo.tests tests-junit5