diff --git a/.0pdd.yml b/.0pdd.yml index 8d23fe2..761b1cd 100644 --- a/.0pdd.yml +++ b/.0pdd.yml @@ -1,5 +1,5 @@ errors: - - # your email + - abialiauski.dev@gmail.com tags: - pdd - bug diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yml similarity index 74% rename from .github/workflows/codecov.yaml rename to .github/workflows/codecov.yml index 4c70bc2..df6a405 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yml @@ -1,15 +1,16 @@ ---- name: codecov on: push: - branches: [ "master" ] + branches: + - master pull_request: - branches: [ "master" ] + branches: + - master jobs: codecov: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: distribution: 'temurin' @@ -20,8 +21,10 @@ jobs: key: maven-${{ hashFiles('**/pom.xml') }} restore-keys: | maven- - - run: mvn clean install + - run: | + mvn clean install - uses: codecov/codecov-action@v3 with: + token: ${{ secrets.CODECOV_TOKEN }} files: ./target/site/jacoco/jacoco.xml fail_ci_if_error: true diff --git a/.github/workflows/mvn.yaml b/.github/workflows/mvn.yaml index 145b232..98ab35e 100644 --- a/.github/workflows/mvn.yaml +++ b/.github/workflows/mvn.yaml @@ -1,4 +1,3 @@ ---- name: mvn on: push: @@ -9,11 +8,11 @@ on: - master jobs: test: - name: Tests + name: Build strategy: matrix: - os: [ubuntu-20.04, macos-12] - java: [11, 17] + os: [ubuntu-20.04, windows-2022, macos-12] + java: [17] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/pdd.yaml b/.github/workflows/pdd.yaml deleted file mode 100644 index cc8c149..0000000 --- a/.github/workflows/pdd.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: pdd -on: - push: - pull_request: -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: g4s8/pdd-action@master diff --git a/.github/workflows/pdd.yml b/.github/workflows/pdd.yml new file mode 100644 index 0000000..cead8c6 --- /dev/null +++ b/.github/workflows/pdd.yml @@ -0,0 +1,14 @@ +name: pdd +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + pdd: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: g4s8/pdd-action@master diff --git a/.github/workflows/xcop.yaml b/.github/workflows/xcop.yml similarity index 79% rename from .github/workflows/xcop.yaml rename to .github/workflows/xcop.yml index 5682297..9691243 100644 --- a/.github/workflows/xcop.yaml +++ b/.github/workflows/xcop.yml @@ -1,4 +1,3 @@ ---- name: xcop on: push: @@ -8,8 +7,8 @@ on: branches: - master jobs: - xcop: + build: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - uses: g4s8/xcop-action@master diff --git a/.pdd b/.pdd deleted file mode 100644 index 31683a6..0000000 --- a/.pdd +++ /dev/null @@ -1,4 +0,0 @@ ---source=. ---verbose ---exclude target/** ---rule min-words:10 diff --git a/.rultor.yml b/.rultor.yml index 9f071ac..39937a8 100644 --- a/.rultor.yml +++ b/.rultor.yml @@ -1,11 +1,20 @@ architect: - - # your GitHub nickname + - h1alexbel +docker: + image: l3r8y/rultor-image:1.0.3 +assets: + settings.xml: eo-cqrs/eo-cqrs-secrets#assets/settings.xml + secring.gpg: eo-cqrs/eo-cqrs-secrets#assets/secring.gpg + pubring.gpg: eo-cqrs/eo-cqrs-secrets#assets/pubring.gpg merge: script: - "mvn clean install --errors --batch-mode" release: pre: false + sensetive: + - settings.xml script: |- [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1 + mvn versions:set "-DnewVersion=${tag}" git commit -am "${tag}" - # add your release pipeline + mvn clean deploy -Prelease --errors --settings ../settings.xml diff --git a/LICENSE b/LICENSE.txt similarity index 88% rename from LICENSE rename to LICENSE.txt index 4821d65..4e7da55 100644 --- a/LICENSE +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Ivan Ivanchuk +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 @@ -14,7 +14,7 @@ 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 +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 diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml new file mode 100644 index 0000000..50e6a36 --- /dev/null +++ b/checkstyle-suppressions.xml @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..3630587 --- /dev/null +++ b/pom.xml @@ -0,0 +1,354 @@ + + + + 4.0.0 + io.github.eo-cqrs + json-matchers + 1.0-SNAPSHOT + json-matchers + + Hamcrest JSON Matchers + + https://github.com/eo-cqrs/json-matchers + 2023 + + + 1 + Aliaksei Bialiauski + abialiauski.dev@gmail.com + https://h1alexbel.github.io + https://www.solvd.com + + Architect + Developer + + + + + GitHub + https://github.com/eo-cqrs/json-matchers/issues + + + GitHub Actions + https://github.com/eo-cqrs/json-matchers/actions + + + + MIT + https://github.com/eo-cqrs/json-matchers/blob/master/LICENSE.txt + site + + + + scm:git:git://github.com/eo-cqrs/json-matchers.git + scm:git:ssh://github.com:eo-cqrs/json-matchers.git + https://github.com/eo-cqrs/json-matchers/tree/master + + + 17 + 17 + 17 + UTF-8 + UTF-8 + 1.3 + 5.3.1 + 5.3.1 + 3.1.2 + 1.1 + 0.1.14 + 1.6.13 + 10.12.0 + 3.3.0 + 0.1.5 + 3.3.0 + 3.1.0 + + + + io.github.eo-cqrs + eokson + 0.0.1 + + + org.hamcrest + hamcrest-all + ${hamcrest-all.version} + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter-api.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter-engine.version} + test + + + + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*Spec.* + **/*Test.* + + + + + org.apache.maven.plugins + maven-verifier-plugin + ${maven-verifier-plugin.version} + + + main + package + + verify + + + src/verifier/verifications.xml + + + + + + org.jacoco + jacoco-maven-plugin + + + jacoco-initialize + + prepare-agent + + + + jacoco-check + test + + check + report + + + + + BUNDLE + + + INSTRUCTION + COVEREDRATIO + 0.55 + + + LINE + COVEREDRATIO + 0.61 + + + BRANCH + COVEREDRATIO + 0.61 + + + COMPLEXITY + COVEREDRATIO + 0.55 + + + METHOD + COVEREDRATIO + 0.55 + + + CLASS + MISSEDCOUNT + 20 + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + javadoc-generate + test + + javadoc + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + com.github.volodya-lombrozo + jtcop-maven-plugin + ${jtcop.version} + + + + check + + + + + + ru.l3r8y + sa-tan + ${sa-tan.version} + + + + search + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + + verify-style + process-classes + + check + + + checkstyle.suppressions.file + checkstyle-suppressions.xml + + + + + + + + + release + + false + + gpg.keyname + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + --pinentry-mode + loopback + + + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${nexus-staging-maven-plugin.version} + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + + + + diff --git a/src/main/java/io/github/eocqrs/json/matchers/JsonEqualTo.java b/src/main/java/io/github/eocqrs/json/matchers/JsonEqualTo.java new file mode 100644 index 0000000..def836a --- /dev/null +++ b/src/main/java/io/github/eocqrs/json/matchers/JsonEqualTo.java @@ -0,0 +1,83 @@ +/* + * 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.json.matchers; + +import io.github.eocqrs.eokson.Json; +import io.github.eocqrs.eokson.SmartJson; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; + +import java.io.InputStream; + +/** + * JSON Equality Expression Matcher. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +public final class JsonEqualTo extends BaseMatcher { + + /** + * JSON to compare. + */ + private final Json compare; + + /** + * Ctor. + * + * @param jsn JSON to compare + */ + public JsonEqualTo(final Json jsn) { + this.compare = jsn; + } + + /** + * Ctor. + * + * @param jsn JSON to compare + */ + public JsonEqualTo(final String jsn) { + this(new Json.Of(jsn)); + } + + /** + * Ctor. + * + * @param bytes Bytes + */ + public JsonEqualTo(final InputStream bytes) { + this(new Json.Of(bytes)); + } + + @Override + public boolean matches(final Object json) { + return new SmartJson(this.compare).pretty() + .equals(json); + } + + @Override + public void describeTo(final Description description) { + description.appendText(" JSON to compare: ") + .appendValue(this.compare); + } +} diff --git a/src/main/java/io/github/eocqrs/json/matchers/package-info.java b/src/main/java/io/github/eocqrs/json/matchers/package-info.java new file mode 100644 index 0000000..39ad350 --- /dev/null +++ b/src/main/java/io/github/eocqrs/json/matchers/package-info.java @@ -0,0 +1,29 @@ +/* + * 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. + */ + +/** + * JSON Matchers. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +package io.github.eocqrs.json.matchers; diff --git a/src/test/java/io/github/eocqrs/json/matchers/JsonEqualToTest.java b/src/test/java/io/github/eocqrs/json/matchers/JsonEqualToTest.java new file mode 100644 index 0000000..19e4acc --- /dev/null +++ b/src/test/java/io/github/eocqrs/json/matchers/JsonEqualToTest.java @@ -0,0 +1,72 @@ +/* + * 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.json.matchers; + +import io.github.eocqrs.eokson.Json; +import io.github.eocqrs.eokson.SmartJson; +import org.hamcrest.Matcher; +import org.hamcrest.StringDescription; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Test case for {@link JsonEqualTo}. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +final class JsonEqualToTest { + + @Test + void createsMatcher() { + final Matcher matcher = new JsonEqualTo("{}"); + Assertions.assertNotNull(matcher); + } + + @Test + void matchesEqualJsons() { + Assertions.assertTrue( + new JsonEqualTo( + new SmartJson( + new Json.Of("{}") + ) + ).matches("{ }") + ); + } + + @Test + void matchesNotEqualJsons() { + Assertions.assertFalse( + new JsonEqualTo("{}") + .matches("{\"test\": \"123\"}") + ); + } + + @Test + void describesDoesNotThrowsException() { + Assertions.assertDoesNotThrow(() -> + new JsonEqualTo("{}") + .describeTo(new StringDescription()) + ); + } +} diff --git a/src/verifier/verifications.xml b/src/verifier/verifications.xml new file mode 100644 index 0000000..6704167 --- /dev/null +++ b/src/verifier/verifications.xml @@ -0,0 +1,33 @@ + + + + + + true + LICENSE.txt + 2023 + + +