From 1f825d0a7afa9e92e219135043160adebfba68f9 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 14:53:56 +0300 Subject: [PATCH 01/12] #26 it --- pom.xml | 8 +++ .../eocqrs/cmig/session/InFileTest.java | 15 +++-- .../eocqrs/cmig/session/SimpleTest.java | 52 +++++++++++++++++ src/test/java/it/CassandraIntegration.java | 56 +++++++++++++++++++ src/test/java/it/CassandraRunsIT.java | 46 +++++++++++++++ 5 files changed, 169 insertions(+), 8 deletions(-) create mode 100644 src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java create mode 100644 src/test/java/it/CassandraIntegration.java create mode 100644 src/test/java/it/CassandraRunsIT.java diff --git a/pom.xml b/pom.xml index 3ce5237..26c7f99 100644 --- a/pom.xml +++ b/pom.xml @@ -97,6 +97,7 @@ SOFTWARE. 5.4.0 1.3 19.0 + 1.18.3 @@ -160,6 +161,7 @@ SOFTWARE. org.hamcrest hamcrest-all ${hamcrest-all.version} + test org.assertj @@ -179,6 +181,12 @@ SOFTWARE. ${mockito-junit-jupiter.version} test + + org.testcontainers + cassandra + ${test-cassandra.version} + test + diff --git a/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java b/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java index 3faffdc..3892285 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java +++ b/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java @@ -22,29 +22,28 @@ package io.github.eocqrs.cmig.session; +import it.CassandraIntegration; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** - * Test suite for {@link InFile}. + * Integration test for {@link InFile}. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -final class InFileTest { +final class InFileTest extends CassandraIntegration { @Test - @Disabled - void appliesInRightFormat() throws Exception { + void appliesInRightFormat() { Assertions.assertDoesNotThrow( () -> new InFile( new Simple( - "localhost", - 9042 + CassandraIntegration.host, + CASSANDRA.getMappedPort(9042) ), - "cmig/002-queries-table.cql" + "cmig/001-initial-keyspace.cql" ).apply(), "Applies does not throw exception" ); diff --git a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java new file mode 100644 index 0000000..d1c7578 --- /dev/null +++ b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Aliaksei Bialiauski, EO-CQRS + * + * 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 NON-INFRINGEMENT. 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 io.github.eocqrs.cmig.session; + +import com.datastax.driver.core.Session; +import it.CassandraIntegration; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; + +/** + * Integration test for {@link Simple}. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +final class SimpleTest extends CassandraIntegration { + + @Test + void connectsSession() throws Exception { + final Session session = new Simple( + CassandraIntegration.host, + CASSANDRA.getMappedPort(9042) + ).value(); + MatcherAssert.assertThat( + "Session is not null", + session, + Matchers.notNullValue() + ); + session.close(); + } +} diff --git a/src/test/java/it/CassandraIntegration.java b/src/test/java/it/CassandraIntegration.java new file mode 100644 index 0000000..8db0004 --- /dev/null +++ b/src/test/java/it/CassandraIntegration.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Aliaksei Bialiauski, EO-CQRS + * + * 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 NON-INFRINGEMENT. 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 it; + +import org.junit.AfterClass; +import org.junit.jupiter.api.BeforeAll; +import org.testcontainers.containers.CassandraContainer; +import org.testcontainers.utility.DockerImageName; + +/** + * Cassandra for Integration Testing. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +@SuppressWarnings("JTCOP.RuleCorrectTestName") +public abstract class CassandraIntegration { + + protected static final CassandraContainer CASSANDRA = + new CassandraContainer<>( + DockerImageName.parse("cassandra:3.11.15") + ).withExposedPorts(9042); + protected static String host; + + @BeforeAll + static void beforeAll() { + CassandraIntegration.CASSANDRA.start(); + CassandraIntegration.host = + CassandraIntegration.CASSANDRA.getHost(); + } + + @AfterClass + public static void tearDown() { + CassandraIntegration.CASSANDRA.stop(); + } +} diff --git a/src/test/java/it/CassandraRunsIT.java b/src/test/java/it/CassandraRunsIT.java new file mode 100644 index 0000000..34cd3ad --- /dev/null +++ b/src/test/java/it/CassandraRunsIT.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Aliaksei Bialiauski, EO-CQRS + * + * 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 NON-INFRINGEMENT. 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 it; + +import org.hamcrest.MatcherAssert; +import org.hamcrest.core.IsEqual; +import org.junit.jupiter.api.Test; + +/** + * Cassandra Runs Integration test. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +@SuppressWarnings("JTCOP.RuleCorrectTestName") +final class CassandraRunsIT extends CassandraIntegration { + + @Test + void runs() { + MatcherAssert.assertThat( + "Cassandra runs", + CASSANDRA.isRunning(), + new IsEqual<>(true) + ); + } +} From 825421c96e1ff775295817532f1f3828b2ab6407 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 14:56:56 +0300 Subject: [PATCH 02/12] master puzzles --- src/test/java/io/github/eocqrs/cmig/MasterTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/github/eocqrs/cmig/MasterTest.java b/src/test/java/io/github/eocqrs/cmig/MasterTest.java index 58582cb..1285255 100644 --- a/src/test/java/io/github/eocqrs/cmig/MasterTest.java +++ b/src/test/java/io/github/eocqrs/cmig/MasterTest.java @@ -37,6 +37,9 @@ */ final class MasterTest { + /* + * @todo #36:30m/DEV Tests for master + */ @Test @Disabled void readsShaInRightFormat() throws Exception { @@ -46,7 +49,6 @@ void readsShaInRightFormat() throws Exception { "master.xml", new Simple("localhost", 9042) ).value(), -// @todo #11:90m/DEV generate SHA based on commit result new IsEqual<>( "c8be525311cfd5f5ac7bf1c7d41a61fd82ae5e384b9b7b490358c1cb038c46c9" ) @@ -54,7 +56,7 @@ void readsShaInRightFormat() throws Exception { } /* - * @todo #11:60m/DEV cassandra instance in tests + * @todo #36:60m/DEV Master Cassandra Test */ @Test @Disabled From 88b692245fa92f62f94f59cb5f51420a7c43d758 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:01:08 +0300 Subject: [PATCH 03/12] #26 it-test --- .github/workflows/mvn.yml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mvn.yml b/.github/workflows/mvn.yml index bb61fcd..0d7176f 100644 --- a/.github/workflows/mvn.yml +++ b/.github/workflows/mvn.yml @@ -1,4 +1,4 @@ -name: mvn +name: maven on: push: branches: @@ -8,11 +8,11 @@ on: - master jobs: test: - name: Tests + name: Build strategy: matrix: - os: [ ubuntu-20.04, macos-12 ] - java: [ 17, 20 ] + os: [windows-2022, macos-12] + java: [17] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -26,5 +26,27 @@ jobs: key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-jdk-${{ matrix.java }}-maven- - - run: | - mvn clean install --errors --batch-mode + - run: mvn clean install --errors --batch-mode + + it-test: + name: Build Integrations + strategy: + matrix: + os-integration: [ubuntu-20.04] + java: [17] + runs-on: ${{ matrix.os-integration }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} + - uses: docker-practice/actions-setup-docker@master + timeout-minutes: 12 + - uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-jdk-${{ matrix.java }}-maven- + - run: mvn clean install --errors --batch-mode \ No newline at end of file From 77c8b3ce6a664842c6075ea042c924722713ee1c Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:09:06 +0300 Subject: [PATCH 04/12] #26 skip its --- .github/workflows/mvn.yml | 2 +- pom.xml | 17 +++++++++++++++++ .../session/{InFileTest.java => InFileIT.java} | 3 ++- .../session/{SimpleTest.java => SimpleIT.java} | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) rename src/test/java/io/github/eocqrs/cmig/session/{InFileTest.java => InFileIT.java} (94%) rename src/test/java/io/github/eocqrs/cmig/session/{SimpleTest.java => SimpleIT.java} (94%) diff --git a/.github/workflows/mvn.yml b/.github/workflows/mvn.yml index 0d7176f..54b54eb 100644 --- a/.github/workflows/mvn.yml +++ b/.github/workflows/mvn.yml @@ -26,7 +26,7 @@ jobs: key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-jdk-${{ matrix.java }}-maven- - - run: mvn clean install --errors --batch-mode + - run: mvn clean install -DskipITs --errors --batch-mode it-test: name: Build Integrations diff --git a/pom.xml b/pom.xml index 26c7f99..9fcf5e8 100644 --- a/pom.xml +++ b/pom.xml @@ -98,6 +98,7 @@ SOFTWARE. 1.3 19.0 1.18.3 + 3.1.0 @@ -217,6 +218,22 @@ SOFTWARE. + + org.apache.maven.plugins + maven-failsafe-plugin + ${failsafe.version} + + + + integration-test + verify + + + + + ${project.build.outputDirectory} + + org.jacoco jacoco-maven-plugin diff --git a/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java b/src/test/java/io/github/eocqrs/cmig/session/InFileIT.java similarity index 94% rename from src/test/java/io/github/eocqrs/cmig/session/InFileTest.java rename to src/test/java/io/github/eocqrs/cmig/session/InFileIT.java index 3892285..3000747 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java +++ b/src/test/java/io/github/eocqrs/cmig/session/InFileIT.java @@ -32,7 +32,8 @@ * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -final class InFileTest extends CassandraIntegration { +@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass") +final class InFileIT extends CassandraIntegration { @Test void appliesInRightFormat() { diff --git a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java b/src/test/java/io/github/eocqrs/cmig/session/SimpleIT.java similarity index 94% rename from src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java rename to src/test/java/io/github/eocqrs/cmig/session/SimpleIT.java index d1c7578..bba4df2 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java +++ b/src/test/java/io/github/eocqrs/cmig/session/SimpleIT.java @@ -34,7 +34,8 @@ * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -final class SimpleTest extends CassandraIntegration { +@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass") +final class SimpleIT extends CassandraIntegration { @Test void connectsSession() throws Exception { From 32aab72012a65264e89cad85bd5578886b1ef48e Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:20:02 +0300 Subject: [PATCH 05/12] #43 win off --- .github/workflows/mvn.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mvn.yml b/.github/workflows/mvn.yml index 54b54eb..1ef47f3 100644 --- a/.github/workflows/mvn.yml +++ b/.github/workflows/mvn.yml @@ -11,7 +11,7 @@ jobs: name: Build strategy: matrix: - os: [windows-2022, macos-12] + os: [macos-12] java: [17] runs-on: ${{ matrix.os }} steps: @@ -49,4 +49,4 @@ jobs: key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-jdk-${{ matrix.java }}-maven- - - run: mvn clean install --errors --batch-mode \ No newline at end of file + - run: mvn clean install --errors --batch-mode From ab57b1da9e19bb1973b62647b41f490ffa5659ce Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:27:04 +0300 Subject: [PATCH 06/12] cov with integrations --- .github/workflows/codecov.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 0d63e5a..3021193 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -12,15 +12,16 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: 17 + java-version: ${{ matrix.java }} + - uses: docker-practice/actions-setup-docker@master + timeout-minutes: 12 - uses: actions/cache@v3 with: path: ~/.m2/repository - key: maven-${{ hashFiles('**/pom.xml') }} + key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | - maven- - - run: | - mvn clean install + ${{ runner.os }}-jdk-${{ matrix.java }}-maven- + - run: mvn clean install --errors --batch-mode - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} From 7d0223ffbf3149f9a79abc41fa57a849f138d948 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:28:36 +0300 Subject: [PATCH 07/12] se 17 --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 3021193..e19e2f5 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: ${{ matrix.java }} + java-version: 17 - uses: docker-practice/actions-setup-docker@master timeout-minutes: 12 - uses: actions/cache@v3 From 049ba49008d94bd1b58cb72088452a8a8058988d Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:44:21 +0300 Subject: [PATCH 08/12] skip its in cov --- .github/workflows/codecov.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index e19e2f5..b50dd1a 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -13,15 +13,14 @@ jobs: with: distribution: 'temurin' java-version: 17 - - uses: docker-practice/actions-setup-docker@master - timeout-minutes: 12 - uses: actions/cache@v3 with: path: ~/.m2/repository - key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} + key: maven-${{ hashFiles('**/pom.xml') }} restore-keys: | - ${{ runner.os }}-jdk-${{ matrix.java }}-maven- - - run: mvn clean install --errors --batch-mode + maven- + - run: | + mvn clean install -DskipITs - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} From f57900b2e6044122ca042df002b26af823aae0c6 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:48:31 +0300 Subject: [PATCH 09/12] unit --- .../eocqrs/cmig/session/InFileTest.java | 47 +++++++++++++ .../eocqrs/cmig/session/SimpleTest.java | 70 +++++++++++++++++++ .../eocqrs/cmig/session => it}/InFileIT.java | 6 +- .../eocqrs/cmig/session => it}/SimpleIT.java | 5 +- 4 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 src/test/java/io/github/eocqrs/cmig/session/InFileTest.java create mode 100644 src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java rename src/test/java/{io/github/eocqrs/cmig/session => it}/InFileIT.java (93%) rename src/test/java/{io/github/eocqrs/cmig/session => it}/SimpleIT.java (93%) diff --git a/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java b/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java new file mode 100644 index 0000000..0490d9b --- /dev/null +++ b/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023 Aliaksei Bialiauski, EO-CQRS + * + * 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 NON-INFRINGEMENT. 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 io.github.eocqrs.cmig.session; + +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +/** + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +@ExtendWith(MockitoExtension.class) +final class InFileTest { + + @Test + void createsWithMockCassandra(@Mock final Cassandra mock) { + MatcherAssert.assertThat( + "Creates cql in file", + new InFile(mock, "cmig/001-initial-keyspace.cql"), + Matchers.notNullValue() + ); + } +} diff --git a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java new file mode 100644 index 0000000..e741ee2 --- /dev/null +++ b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2023 Aliaksei Bialiauski, EO-CQRS + * + * 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 NON-INFRINGEMENT. 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 io.github.eocqrs.cmig.session; + +import com.datastax.driver.core.Cluster; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +/** + * Test suite for {@link Simple}. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +@ExtendWith(MockitoExtension.class) +final class SimpleTest { + + @Test + void createsCassandra(@Mock final Cluster mock) { + final Cassandra cassandra = new Simple(mock); + MatcherAssert.assertThat( + "Creates Cassandra", + cassandra, + Matchers.notNullValue() + ); + } + + @Test + void closesWithoutException(@Mock final Cluster mock) { + final Cassandra cassandra = new Simple(mock); + Assertions.assertDoesNotThrow( + cassandra::close, + () -> "Closes without exception" + ); + } + + @Test + void connectsToMockWithoutException(@Mock final Cluster mock) throws Exception { + final Cassandra cassandra = new Simple(mock); + Assertions.assertDoesNotThrow( + cassandra::value, + () -> "Connect to mocked cluster doesnt throw exception" + ); + } +} diff --git a/src/test/java/io/github/eocqrs/cmig/session/InFileIT.java b/src/test/java/it/InFileIT.java similarity index 93% rename from src/test/java/io/github/eocqrs/cmig/session/InFileIT.java rename to src/test/java/it/InFileIT.java index 3000747..96d309b 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/InFileIT.java +++ b/src/test/java/it/InFileIT.java @@ -20,9 +20,10 @@ * SOFTWARE. */ -package io.github.eocqrs.cmig.session; +package it; -import it.CassandraIntegration; +import io.github.eocqrs.cmig.session.InFile; +import io.github.eocqrs.cmig.session.Simple; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -32,7 +33,6 @@ * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass") final class InFileIT extends CassandraIntegration { @Test diff --git a/src/test/java/io/github/eocqrs/cmig/session/SimpleIT.java b/src/test/java/it/SimpleIT.java similarity index 93% rename from src/test/java/io/github/eocqrs/cmig/session/SimpleIT.java rename to src/test/java/it/SimpleIT.java index bba4df2..b6d9974 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/SimpleIT.java +++ b/src/test/java/it/SimpleIT.java @@ -20,10 +20,10 @@ * SOFTWARE. */ -package io.github.eocqrs.cmig.session; +package it; import com.datastax.driver.core.Session; -import it.CassandraIntegration; +import io.github.eocqrs.cmig.session.Simple; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; @@ -34,7 +34,6 @@ * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -@SuppressWarnings("JTCOP.RuleAllTestsHaveProductionClass") final class SimpleIT extends CassandraIntegration { @Test From aa8da1b11f1567f1cfa8a9c1370f4cd24d732575 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:50:17 +0300 Subject: [PATCH 10/12] message --- src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java index e741ee2..53c5067 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java +++ b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java @@ -55,7 +55,7 @@ void closesWithoutException(@Mock final Cluster mock) { final Cassandra cassandra = new Simple(mock); Assertions.assertDoesNotThrow( cassandra::close, - () -> "Closes without exception" + "Closes without exception" ); } @@ -64,7 +64,7 @@ void connectsToMockWithoutException(@Mock final Cluster mock) throws Exception { final Cassandra cassandra = new Simple(mock); Assertions.assertDoesNotThrow( cassandra::value, - () -> "Connect to mocked cluster doesnt throw exception" + "Connect to mocked cluster doesnt throw exception" ); } } From 268d2b6cdf94127550aaa3f6015f9610be55eac5 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 14 Aug 2023 15:50:50 +0300 Subject: [PATCH 11/12] no exception --- src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java index 53c5067..66b1480 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java +++ b/src/test/java/io/github/eocqrs/cmig/session/SimpleTest.java @@ -60,7 +60,7 @@ void closesWithoutException(@Mock final Cluster mock) { } @Test - void connectsToMockWithoutException(@Mock final Cluster mock) throws Exception { + void connectsToMockWithoutException(@Mock final Cluster mock) { final Cassandra cassandra = new Simple(mock); Assertions.assertDoesNotThrow( cassandra::value, From 372d9fd47541d10ecfdb0f6eb06e5d1fda2dd45f Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Tue, 15 Aug 2023 11:03:52 +0300 Subject: [PATCH 12/12] rultor skip --- .rultor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rultor.yml b/.rultor.yml index 39937a8..fa27c43 100644 --- a/.rultor.yml +++ b/.rultor.yml @@ -8,7 +8,7 @@ assets: pubring.gpg: eo-cqrs/eo-cqrs-secrets#assets/pubring.gpg merge: script: - - "mvn clean install --errors --batch-mode" + - "mvn clean install -DskipITs --errors --batch-mode" release: pre: false sensetive: