From 550a34b3920c00d9b4f442edacd3c75a7e5d7962 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Fri, 11 Aug 2023 12:10:31 +0300 Subject: [PATCH 1/5] #32 sha draft --- README.md | 17 +++- .../java/io/github/eocqrs/cmig/Master.java | 13 ++- .../eocqrs/cmig/{meta/Ids.java => State.java} | 49 ++--------- .../io/github/eocqrs/cmig/meta/Authors.java | 31 +++++-- .../io/github/eocqrs/cmig/meta/Names.java | 24 +++-- .../io/github/eocqrs/cmig/sha/Contents.java | 80 +++++++++++++++++ .../java/io/github/eocqrs/cmig/sha/Sha.java | 87 +++++++++++++++++++ .../github/eocqrs/cmig/sha/package-info.java | 29 +++++++ .../github/eocqrs/cmig/meta/AuthorsTest.java | 11 ++- .../io/github/eocqrs/cmig/meta/NamesTest.java | 3 +- .../eocqrs/cmig/session/InFileTest.java | 1 - .../github/eocqrs/cmig/sha/ContentsTest.java | 69 +++++++++++++++ .../{meta/IdsTest.java => sha/ShaTest.java} | 22 ++--- src/test/resources/cmig/002-queries-table.cql | 2 +- src/test/resources/cmig/master.xml | 17 +++- 15 files changed, 369 insertions(+), 86 deletions(-) rename src/main/java/io/github/eocqrs/cmig/{meta/Ids.java => State.java} (63%) create mode 100644 src/main/java/io/github/eocqrs/cmig/sha/Contents.java create mode 100644 src/main/java/io/github/eocqrs/cmig/sha/Sha.java create mode 100644 src/main/java/io/github/eocqrs/cmig/sha/package-info.java create mode 100644 src/test/java/io/github/eocqrs/cmig/sha/ContentsTest.java rename src/test/java/io/github/eocqrs/cmig/{meta/IdsTest.java => sha/ShaTest.java} (80%) diff --git a/README.md b/README.md index 1842824..7f3e223 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,19 @@ Maven: In your resources directory you should create a `cmig` directory, and inside it new XML file, for instance `master.xml`: ```xml - - 001-initial.cql - 002-clicks-keyspace.cql - + + + + + + + + + + + + + ``` **Inside all the files you must have only one operation**. diff --git a/src/main/java/io/github/eocqrs/cmig/Master.java b/src/main/java/io/github/eocqrs/cmig/Master.java index b530c55..a08f9bf 100644 --- a/src/main/java/io/github/eocqrs/cmig/Master.java +++ b/src/main/java/io/github/eocqrs/cmig/Master.java @@ -29,9 +29,13 @@ import io.github.eocqrs.cmig.session.InFile; import org.cactoos.Scalar; import org.cactoos.io.ResourceOf; +/* + * @todo #32:45m/DEV Master is set of states inside XML document. + */ + /** - * Master files. + * Set of States. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 @@ -53,7 +57,10 @@ public final class Master implements Scalar { * @param doc XML * @param cs Cassandra */ - public Master(final XML doc, final Cassandra cs) { + public Master( + final XML doc, + final Cassandra cs + ) { this.xml = doc; this.cassandra = cs; } @@ -82,7 +89,7 @@ public Master( @Override public String value() throws Exception { - new Names(this.xml).value() + new Names(this.xml, "").value() .forEach(file -> { try { new InFile( diff --git a/src/main/java/io/github/eocqrs/cmig/meta/Ids.java b/src/main/java/io/github/eocqrs/cmig/State.java similarity index 63% rename from src/main/java/io/github/eocqrs/cmig/meta/Ids.java rename to src/main/java/io/github/eocqrs/cmig/State.java index 1a3700c..35abb90 100644 --- a/src/main/java/io/github/eocqrs/cmig/meta/Ids.java +++ b/src/main/java/io/github/eocqrs/cmig/State.java @@ -20,54 +20,21 @@ * SOFTWARE. */ -package io.github.eocqrs.cmig.meta; +package io.github.eocqrs.cmig; -import com.jcabi.xml.XML; -import com.jcabi.xml.XMLDocument; -import org.cactoos.io.ResourceOf; - -import java.util.List; +import org.cactoos.Scalar; +/* + * @todo #32:30m/DEV design State interface + */ /** - * File IDs. + * State. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -public final class Ids implements XpathList { - - /** - * XML. - */ - private final XML xml; - - /** - * Ctor. - * - * @param doc XML - */ - public Ids(final XML doc) { - this.xml = doc; - } - - /** - * Ctor. - * - * @param name File name - * @throws Exception if something went wrong - */ - public Ids(final String name) throws Exception { - this( - new XMLDocument( - new ResourceOf( - name - ).stream() - ) - ); - } +public interface State extends Scalar { @Override - public List value() throws Exception { - return this.xml.xpath("/files/file/@id"); - } + String value() throws Exception; } diff --git a/src/main/java/io/github/eocqrs/cmig/meta/Authors.java b/src/main/java/io/github/eocqrs/cmig/meta/Authors.java index 16a2dc8..77d76a0 100644 --- a/src/main/java/io/github/eocqrs/cmig/meta/Authors.java +++ b/src/main/java/io/github/eocqrs/cmig/meta/Authors.java @@ -24,50 +24,63 @@ import com.jcabi.xml.XML; import com.jcabi.xml.XMLDocument; +import org.cactoos.Scalar; import org.cactoos.io.ResourceOf; -import java.util.List; - /** - * File authors. + * Authors of State. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -public final class Authors implements XpathList { +public final class Authors implements Scalar { /** * XML. */ private final XML xml; + /** + * State ID. + */ + private final String id; /** * Ctor. * * @param doc XML + * @param id State ID */ - public Authors(final XML doc) { + public Authors(final XML doc, final String id) { this.xml = doc; + this.id = id; } /** * Ctor. * * @param name File name + * @param id State ID * @throws Exception if something went wrong */ - public Authors(final String name) throws Exception { + public Authors(final String name, final String id) + throws Exception { this( new XMLDocument( new ResourceOf( name ).stream() - ) + ), + id ); } @Override - public List value() throws Exception { - return this.xml.xpath("/files/file/@author"); + public String value() throws Exception { + return this.xml.xpath( + "/states/changeState[@id='%s']/@author" + .formatted( + this.id + ) + ).get(0); } } diff --git a/src/main/java/io/github/eocqrs/cmig/meta/Names.java b/src/main/java/io/github/eocqrs/cmig/meta/Names.java index 650cbe9..346dc24 100644 --- a/src/main/java/io/github/eocqrs/cmig/meta/Names.java +++ b/src/main/java/io/github/eocqrs/cmig/meta/Names.java @@ -29,7 +29,7 @@ import java.util.List; /** - * File names. + * File names of State. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 @@ -40,34 +40,48 @@ public final class Names implements XpathList { * XML. */ private final XML xml; + /** + * State ID. + */ + private final String id; /** * Ctor. * * @param doc XML + * @param id State ID */ - public Names(final XML doc) { + public Names(final XML doc, final String id) { this.xml = doc; + this.id = id; } /** * Ctor. * * @param name File name + * @param id State ID * @throws Exception if something went wrong */ - public Names(final String name) throws Exception { + public Names(final String name, final String id) + throws Exception { this( new XMLDocument( new ResourceOf( name ).stream() - ) + ), + id ); } @Override public List value() throws Exception { - return this.xml.xpath("/files/file/text()"); + return this.xml.xpath( + "/states/changeState[@id='%s']/files/file/@path" + .formatted( + this.id + ) + ); } } diff --git a/src/main/java/io/github/eocqrs/cmig/sha/Contents.java b/src/main/java/io/github/eocqrs/cmig/sha/Contents.java new file mode 100644 index 0000000..812f9cc --- /dev/null +++ b/src/main/java/io/github/eocqrs/cmig/sha/Contents.java @@ -0,0 +1,80 @@ +/* + * 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.sha; + +import io.github.eocqrs.cmig.meta.XpathList; +import org.cactoos.Scalar; +import org.cactoos.io.ResourceOf; +import org.cactoos.list.ListOf; +import org.cactoos.text.TextOf; + +import java.util.List; + +/** + * Contents in State. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +public final class Contents implements Scalar> { + + /** + * XPATH lists. + */ + private final XpathList list; + /** + * CMIG directory. + */ + private final String cmig; + + /** + * Ctor. + * + * @param lst XPATH list + * @param cmg CMIG directory + */ + public Contents(final XpathList lst, final String cmg) { + this.list = lst; + this.cmig = cmg; + } + + @Override + public List value() throws Exception { + final List contents = new ListOf<>(); + final List files = this.list.value(); + for (final String file : files) { + final String content = + new TextOf( + new ResourceOf( + "%s/%s" + .formatted( + this.cmig, + file + ) + ) + ).asString(); + contents.add(content); + } + return contents; + } +} diff --git a/src/main/java/io/github/eocqrs/cmig/sha/Sha.java b/src/main/java/io/github/eocqrs/cmig/sha/Sha.java new file mode 100644 index 0000000..d13788a --- /dev/null +++ b/src/main/java/io/github/eocqrs/cmig/sha/Sha.java @@ -0,0 +1,87 @@ +/* + * 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.sha; + +import io.github.eocqrs.cmig.meta.Names; +import org.cactoos.Scalar; +import org.cactoos.bytes.Sha256DigestOf; +import org.cactoos.io.InputOf; +import org.cactoos.text.HexOf; + +import java.util.List; + +/** + * SHA256 for State. + * + * @author Aliaksei Bialiauski (0.0.0) + * @since 0.0.0 + */ +public final class Sha implements Scalar { + + /** + * State ID. + */ + private final String id; + /** + * Master file. + */ + private final String master; + /** + * CMIG directory. + */ + private final String cmig; + + /** + * Ctor. + * @param id State ID + * @param mst Master file + * @param cmg CMIG directory + */ + public Sha( + final String id, + final String mst, + final String cmg + ) { + this.id = id; + this.master = mst; + this.cmig = cmg; + } + + @Override + public String value() throws Exception { + final List contents = new Contents( + new Names( + this.master, + this.id + ), + this.cmig + ).value(); + return new HexOf( + new Sha256DigestOf( + new InputOf( + contents.toString() + ) + ) + ).asString(); + } +} diff --git a/src/main/java/io/github/eocqrs/cmig/sha/package-info.java b/src/main/java/io/github/eocqrs/cmig/sha/package-info.java new file mode 100644 index 0000000..1103dc8 --- /dev/null +++ b/src/main/java/io/github/eocqrs/cmig/sha/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. + */ + +/** + * SHA. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +package io.github.eocqrs.cmig.sha; diff --git a/src/test/java/io/github/eocqrs/cmig/meta/AuthorsTest.java b/src/test/java/io/github/eocqrs/cmig/meta/AuthorsTest.java index dd32c03..adcfe41 100644 --- a/src/test/java/io/github/eocqrs/cmig/meta/AuthorsTest.java +++ b/src/test/java/io/github/eocqrs/cmig/meta/AuthorsTest.java @@ -22,7 +22,6 @@ package io.github.eocqrs.cmig.meta; -import org.cactoos.list.ListOf; import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsEqual; import org.junit.jupiter.api.Test; @@ -39,12 +38,12 @@ final class AuthorsTest { void readsAuthorInfoInRightFormat() throws Exception { MatcherAssert.assertThat( "Authors in right format", - new Authors("cmig/master.xml").value(), + new Authors( + "cmig/master.xml", + "1" + ).value(), new IsEqual<>( - new ListOf<>( - "h1alexbel", - "test" - ) + "test" ) ); } diff --git a/src/test/java/io/github/eocqrs/cmig/meta/NamesTest.java b/src/test/java/io/github/eocqrs/cmig/meta/NamesTest.java index 29157e2..89f9f81 100644 --- a/src/test/java/io/github/eocqrs/cmig/meta/NamesTest.java +++ b/src/test/java/io/github/eocqrs/cmig/meta/NamesTest.java @@ -45,7 +45,8 @@ void readsNamesInRightFormat() throws Exception { new XMLDocument( new ResourceOf("cmig/master.xml") .stream() - ) + ), + "1" ).value(), new IsEqual<>( new ListOf<>( 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 ce15581..3faffdc 100644 --- a/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java +++ b/src/test/java/io/github/eocqrs/cmig/session/InFileTest.java @@ -22,7 +22,6 @@ package io.github.eocqrs.cmig.session; -import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/github/eocqrs/cmig/sha/ContentsTest.java b/src/test/java/io/github/eocqrs/cmig/sha/ContentsTest.java new file mode 100644 index 0000000..8a09ed9 --- /dev/null +++ b/src/test/java/io/github/eocqrs/cmig/sha/ContentsTest.java @@ -0,0 +1,69 @@ +/* + * 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.sha; + +import io.github.eocqrs.cmig.meta.Names; +import org.cactoos.list.ListOf; +import org.hamcrest.MatcherAssert; +import org.hamcrest.core.IsEqual; +import org.junit.jupiter.api.Test; + +import java.util.List; + +/** + * Test suite for {@link Contents}. + * + * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) + * @since 0.0.0 + */ +final class ContentsTest { + + @Test + void readsContentsInRightFormat() throws Exception { + final List value = new Contents( + new Names( + "cmig/master.xml", "1" + ), + "cmig" + ).value(); + MatcherAssert.assertThat( + "Contents in right format", + value, + new IsEqual<>( + new ListOf<>( + "CREATE KEYSPACE queryDatasets\n" + + " WITH REPLICATION = {\n" + + " 'class' : 'NetworkTopologyStrategy',\n" + + " 'datacenter1' : 1\n" + + " };", + "CREATE TABLE querydatasets.queries\n" + + "(\n" + + " id UUID PRIMARY KEY,\n" + + " query TEXT,\n" + + " seen TIMESTAMP\n" + + ");" + ) + ) + ); + } +} diff --git a/src/test/java/io/github/eocqrs/cmig/meta/IdsTest.java b/src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java similarity index 80% rename from src/test/java/io/github/eocqrs/cmig/meta/IdsTest.java rename to src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java index 4d2e9c6..952a3bd 100644 --- a/src/test/java/io/github/eocqrs/cmig/meta/IdsTest.java +++ b/src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java @@ -20,31 +20,31 @@ * SOFTWARE. */ -package io.github.eocqrs.cmig.meta; +package io.github.eocqrs.cmig.sha; -import org.cactoos.list.ListOf; import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsEqual; import org.junit.jupiter.api.Test; /** - * Test suite for {@link Ids}. + * Test suite for {@link Sha}. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -final class IdsTest { +final class ShaTest { @Test - void readsIdsInRightFormat() throws Exception { + void readsShaInRightFormat() throws Exception { MatcherAssert.assertThat( - "IDs in right format", - new Ids("cmig/master.xml").value(), + "SHA 256 in right format", + new Sha( + "1", + "cmig/master.xml", + "cmig" + ).value(), new IsEqual<>( - new ListOf<>( - "1", - "2" - ) + "bb2e7331978b0457bcb9f64843e6d4f70ec6a517bffc1366832faed0bdc3bb87" ) ); } diff --git a/src/test/resources/cmig/002-queries-table.cql b/src/test/resources/cmig/002-queries-table.cql index 9620221..c95356e 100644 --- a/src/test/resources/cmig/002-queries-table.cql +++ b/src/test/resources/cmig/002-queries-table.cql @@ -3,4 +3,4 @@ CREATE TABLE querydatasets.queries id UUID PRIMARY KEY, query TEXT, seen TIMESTAMP -); +); \ No newline at end of file diff --git a/src/test/resources/cmig/master.xml b/src/test/resources/cmig/master.xml index da1aa4d..8f02384 100644 --- a/src/test/resources/cmig/master.xml +++ b/src/test/resources/cmig/master.xml @@ -22,7 +22,16 @@ 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. --> - - 001-initial-keyspace.cql - 002-queries-table.cql - + + + + + + + + + + + + + From 89ca6d797a2dfd597a68e7df5a2b6dd0357ec1df Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Fri, 11 Aug 2023 12:44:24 +0300 Subject: [PATCH 2/5] single --- .../github/eocqrs/cmig/meta/{Authors.java => Author.java} | 8 ++++---- .../cmig/meta/{AuthorsTest.java => AuthorTest.java} | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/io/github/eocqrs/cmig/meta/{Authors.java => Author.java} (91%) rename src/test/java/io/github/eocqrs/cmig/meta/{AuthorsTest.java => AuthorTest.java} (95%) diff --git a/src/main/java/io/github/eocqrs/cmig/meta/Authors.java b/src/main/java/io/github/eocqrs/cmig/meta/Author.java similarity index 91% rename from src/main/java/io/github/eocqrs/cmig/meta/Authors.java rename to src/main/java/io/github/eocqrs/cmig/meta/Author.java index 77d76a0..f270e99 100644 --- a/src/main/java/io/github/eocqrs/cmig/meta/Authors.java +++ b/src/main/java/io/github/eocqrs/cmig/meta/Author.java @@ -28,12 +28,12 @@ import org.cactoos.io.ResourceOf; /** - * Authors of State. + * Author of State. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -public final class Authors implements Scalar { +public final class Author implements Scalar { /** * XML. @@ -50,7 +50,7 @@ public final class Authors implements Scalar { * @param doc XML * @param id State ID */ - public Authors(final XML doc, final String id) { + public Author(final XML doc, final String id) { this.xml = doc; this.id = id; } @@ -62,7 +62,7 @@ public Authors(final XML doc, final String id) { * @param id State ID * @throws Exception if something went wrong */ - public Authors(final String name, final String id) + public Author(final String name, final String id) throws Exception { this( new XMLDocument( diff --git a/src/test/java/io/github/eocqrs/cmig/meta/AuthorsTest.java b/src/test/java/io/github/eocqrs/cmig/meta/AuthorTest.java similarity index 95% rename from src/test/java/io/github/eocqrs/cmig/meta/AuthorsTest.java rename to src/test/java/io/github/eocqrs/cmig/meta/AuthorTest.java index adcfe41..a4ff89b 100644 --- a/src/test/java/io/github/eocqrs/cmig/meta/AuthorsTest.java +++ b/src/test/java/io/github/eocqrs/cmig/meta/AuthorTest.java @@ -27,18 +27,18 @@ import org.junit.jupiter.api.Test; /** - * Test suite for {@link Authors}. + * Test suite for {@link Author}. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -final class AuthorsTest { +final class AuthorTest { @Test void readsAuthorInfoInRightFormat() throws Exception { MatcherAssert.assertThat( "Authors in right format", - new Authors( + new Author( "cmig/master.xml", "1" ).value(), From 9ae6775ec59145efba38f7ba2c8407150c0241f4 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Fri, 11 Aug 2023 12:44:34 +0300 Subject: [PATCH 3/5] text --- src/main/java/io/github/eocqrs/cmig/sha/Sha.java | 6 +++--- src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/eocqrs/cmig/sha/Sha.java b/src/main/java/io/github/eocqrs/cmig/sha/Sha.java index d13788a..105e179 100644 --- a/src/main/java/io/github/eocqrs/cmig/sha/Sha.java +++ b/src/main/java/io/github/eocqrs/cmig/sha/Sha.java @@ -23,7 +23,7 @@ package io.github.eocqrs.cmig.sha; import io.github.eocqrs.cmig.meta.Names; -import org.cactoos.Scalar; +import org.cactoos.Text; import org.cactoos.bytes.Sha256DigestOf; import org.cactoos.io.InputOf; import org.cactoos.text.HexOf; @@ -36,7 +36,7 @@ * @author Aliaksei Bialiauski (0.0.0) * @since 0.0.0 */ -public final class Sha implements Scalar { +public final class Sha implements Text { /** * State ID. @@ -68,7 +68,7 @@ public Sha( } @Override - public String value() throws Exception { + public String asString() throws Exception { final List contents = new Contents( new Names( this.master, diff --git a/src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java b/src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java index 952a3bd..b0bfef7 100644 --- a/src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java +++ b/src/test/java/io/github/eocqrs/cmig/sha/ShaTest.java @@ -42,7 +42,7 @@ void readsShaInRightFormat() throws Exception { "1", "cmig/master.xml", "cmig" - ).value(), + ).asString(), new IsEqual<>( "bb2e7331978b0457bcb9f64843e6d4f70ec6a517bffc1366832faed0bdc3bb87" ) From 20ce06e297f8c7f29446e15b464d916bd1c2883d Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Fri, 11 Aug 2023 12:45:42 +0300 Subject: [PATCH 4/5] text --- src/main/java/io/github/eocqrs/cmig/sha/Sha.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/eocqrs/cmig/sha/Sha.java b/src/main/java/io/github/eocqrs/cmig/sha/Sha.java index 105e179..d10ecb3 100644 --- a/src/main/java/io/github/eocqrs/cmig/sha/Sha.java +++ b/src/main/java/io/github/eocqrs/cmig/sha/Sha.java @@ -69,7 +69,7 @@ public Sha( @Override public String asString() throws Exception { - final List contents = new Contents( + final List contents = new StateChanges( new Names( this.master, this.id From d516b0351048a000ca2f066b5bc23529f543ccff Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Fri, 11 Aug 2023 12:45:51 +0300 Subject: [PATCH 5/5] state changes --- .../eocqrs/cmig/sha/{Contents.java => StateChanges.java} | 6 +++--- .../cmig/sha/{ContentsTest.java => StateChangesTest.java} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename src/main/java/io/github/eocqrs/cmig/sha/{Contents.java => StateChanges.java} (93%) rename src/test/java/io/github/eocqrs/cmig/sha/{ContentsTest.java => StateChangesTest.java} (94%) diff --git a/src/main/java/io/github/eocqrs/cmig/sha/Contents.java b/src/main/java/io/github/eocqrs/cmig/sha/StateChanges.java similarity index 93% rename from src/main/java/io/github/eocqrs/cmig/sha/Contents.java rename to src/main/java/io/github/eocqrs/cmig/sha/StateChanges.java index 812f9cc..36ac253 100644 --- a/src/main/java/io/github/eocqrs/cmig/sha/Contents.java +++ b/src/main/java/io/github/eocqrs/cmig/sha/StateChanges.java @@ -31,12 +31,12 @@ import java.util.List; /** - * Contents in State. + * Changes inside State. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -public final class Contents implements Scalar> { +public final class StateChanges implements Scalar> { /** * XPATH lists. @@ -53,7 +53,7 @@ public final class Contents implements Scalar> { * @param lst XPATH list * @param cmg CMIG directory */ - public Contents(final XpathList lst, final String cmg) { + public StateChanges(final XpathList lst, final String cmg) { this.list = lst; this.cmig = cmg; } diff --git a/src/test/java/io/github/eocqrs/cmig/sha/ContentsTest.java b/src/test/java/io/github/eocqrs/cmig/sha/StateChangesTest.java similarity index 94% rename from src/test/java/io/github/eocqrs/cmig/sha/ContentsTest.java rename to src/test/java/io/github/eocqrs/cmig/sha/StateChangesTest.java index 8a09ed9..46bff58 100644 --- a/src/test/java/io/github/eocqrs/cmig/sha/ContentsTest.java +++ b/src/test/java/io/github/eocqrs/cmig/sha/StateChangesTest.java @@ -31,16 +31,16 @@ import java.util.List; /** - * Test suite for {@link Contents}. + * Test suite for {@link StateChanges}. * * @author Aliaksei Bialiauski (abialiauski.dev@gmail.com) * @since 0.0.0 */ -final class ContentsTest { +final class StateChangesTest { @Test void readsContentsInRightFormat() throws Exception { - final List value = new Contents( + final List value = new StateChanges( new Names( "cmig/master.xml", "1" ),