From e66d4e1618d34e850e3b3efb90fb85583fc5a89b Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 11 Nov 2026 08:38:03 +0300 Subject: [PATCH 1/2] chore: update qulice-maven-plugin to 0.36.1 Fix the violations the newer rules report: remove stale suppressions, move nested classes to their own files, migrate tests to JUnit Jupiter. --- pom.xml | 2 +- src/main/java/io/zold/api/Copies.java | 104 +----------------- src/main/java/io/zold/api/Copy.java | 94 ++++++++++++++++ src/main/java/io/zold/api/CpTransaction.java | 3 +- src/main/java/io/zold/api/Loaded.java | 75 +++++++++++++ src/main/java/io/zold/api/Network.java | 3 + src/main/java/io/zold/api/Remote.java | 7 ++ src/main/java/io/zold/api/RtNetwork.java | 80 +------------- src/main/java/io/zold/api/RtScore.java | 2 + src/main/java/io/zold/api/RtTransaction.java | 27 +---- src/main/java/io/zold/api/Score.java | 7 +- .../java/io/zold/api/TaxBeneficiaries.java | 4 +- src/main/java/io/zold/api/Taxes.java | 2 + src/main/java/io/zold/api/Transaction.java | 12 +- src/main/java/io/zold/api/Wallet.java | 33 +++--- src/main/java/io/zold/api/Wallets.java | 3 + src/main/java/io/zold/api/WalletsIn.java | 5 +- src/main/java/io/zold/api/package-info.java | 1 + src/test/java/io/zold/api/CopiesTest.java | 8 +- .../java/io/zold/api/CpTransactionTest.java | 4 +- src/test/java/io/zold/api/NetworkTest.java | 23 ++-- .../java/io/zold/api/RtTransactionTest.java | 78 +++++++------ src/test/java/io/zold/api/ScoreTest.java | 12 +- .../io/zold/api/TaxBeneficiariesTest.java | 11 +- src/test/java/io/zold/api/TaxesTest.java | 7 +- .../java/io/zold/api/TransactionTest.java | 3 +- src/test/java/io/zold/api/WalletTest.java | 46 ++++---- src/test/java/io/zold/api/WalletsInTest.java | 35 +++--- src/test/java/io/zold/api/package-info.java | 1 + 29 files changed, 340 insertions(+), 352 deletions(-) create mode 100644 src/main/java/io/zold/api/Copy.java create mode 100644 src/main/java/io/zold/api/Loaded.java diff --git a/pom.xml b/pom.xml index 94e7358..20f4319 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ com.qulice qulice-maven-plugin - 0.27.6 + 0.36.1 checkstyle:/src/site/resources/.* diff --git a/src/main/java/io/zold/api/Copies.java b/src/main/java/io/zold/api/Copies.java index f8f2bb7..d5e75d2 100644 --- a/src/main/java/io/zold/api/Copies.java +++ b/src/main/java/io/zold/api/Copies.java @@ -4,24 +4,23 @@ */ package io.zold.api; -import io.zold.api.Copies.Copy; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.cactoos.iterable.IterableEnvelope; import org.cactoos.iterable.IterableOf; -import org.cactoos.iterable.Joined; -import org.cactoos.iterable.Mapped; import org.cactoos.list.ListOf; /** * Multiple copies of a Wallet. + * * @since 1.0 */ public final class Copies extends IterableEnvelope { /** * Ctor. + * * @param id Id of the wallet to pull * @param remotes Remote nodes */ @@ -29,13 +28,6 @@ public final class Copies extends IterableEnvelope { super(new IterableOf<>(() -> copies(id, remotes).iterator())); } - /** - * Builds copies from remotes. - * @param id Wallet's id - * @param remotes List of remotes - * @return Iterable Iterable of Copy - * @throws IOException If fails - */ private static Iterable copies(final long id, final Iterable remotes) throws IOException { final List copies = new ArrayList<>(10); @@ -50,103 +42,19 @@ private static Iterable copies(final long id, } } if (!updated) { - copies.add(new Copies.Copy(wallet, remote)); + copies.add(new Copy(wallet, remote)); } } return new IterableOf<>(copies.iterator()); } - /** - * Checks if content of two wallets is equal. - * @param first First wallet - * @param second Second wallet - * @return Boolean Boolean - * @throws IOException If fails - * @todo #56:30min Compare the entire content of two wallets. In addition - * to id, compare RSA key and all transactions one by one. Entire content - * of each transaction should be compared. - */ + // @todo #56:30min Compare the entire content of two wallets. In addition to + // id, compare RSA key and all transactions one by one. Entire content of + // each transaction should be compared. private static boolean equalWallets(final Wallet first, final Wallet second) throws IOException { return first.id() == second.id() && new ListOf<>( first.ledger() ).size() == new ListOf<>(second.ledger()).size(); } - - /** - * One copy of a {@link Wallet}. - * @since 1.0 - */ - static final class Copy implements Comparable { - - /** - * The wallet. - */ - private final Wallet wlt; - - /** - * The remote nodes where the wallet was found. - */ - private final Iterable remotes; - - /** - * Ctor. - * @param wallet The wallet - * @param remotes The remote nodes where the wallet was found - */ - Copy(final Wallet wallet, final Remote... remotes) { - this(wallet, new IterableOf<>(remotes)); - } - - /** - * Ctor. - * @param wallet The wallet - * @param remotes The remote nodes where the wallet was found - */ - Copy(final Wallet wallet, final Iterable remotes) { - this.wlt = wallet; - this.remotes = remotes; - } - - @Override - public int compareTo(final Copy other) { - return this.score().compareTo(other.score()); - } - - @Override - public boolean equals(final Object obj) { - return obj instanceof Copy - && this.compareTo((Copy) obj) == 0; - } - - @Override - public int hashCode() { - return new ListOf<>(this.score().suffixes()).size(); - } - - /** - * Creates new Copy instance with additional remote. - * @param remote Remote - * @return Copy Copy - */ - Copies.Copy with(final Remote remote) { - return new Copies.Copy(this.wallet(), new Joined<>(remote, this.remotes)); - } - - /** - * The wallet. - * @return The wallet - */ - Wallet wallet() { - return this.wlt; - } - - /** - * The summary of the score of all the remote nodes. - * @return The score - */ - Score score() { - return new Score.Summed(new Mapped<>(Remote::score, this.remotes)); - } - } } diff --git a/src/main/java/io/zold/api/Copy.java b/src/main/java/io/zold/api/Copy.java new file mode 100644 index 0000000..78bdd07 --- /dev/null +++ b/src/main/java/io/zold/api/Copy.java @@ -0,0 +1,94 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2018-2026 Zerocracy + * SPDX-License-Identifier: MIT + */ +package io.zold.api; + +import org.cactoos.iterable.IterableOf; +import org.cactoos.iterable.Joined; +import org.cactoos.iterable.Mapped; +import org.cactoos.list.ListOf; + +/** + * One copy of a {@link Wallet}. + * + * @since 1.0 + */ +final class Copy implements Comparable { + + /** + * The wallet. + */ + private final Wallet wlt; + + /** + * The remote nodes where the wallet was found. + */ + private final Iterable remotes; + + /** + * Ctor. + * + * @param wallet The wallet + * @param remotes The remote nodes where the wallet was found + */ + Copy(final Wallet wallet, final Remote... remotes) { + this(wallet, new IterableOf<>(remotes)); + } + + /** + * Ctor. + * + * @param wallet The wallet + * @param remotes The remote nodes where the wallet was found + */ + Copy(final Wallet wallet, final Iterable remotes) { + this.wlt = wallet; + this.remotes = remotes; + } + + @Override + public int compareTo(final Copy other) { + return this.score().compareTo(other.score()); + } + + @Override + public boolean equals(final Object obj) { + return obj instanceof Copy + && this.compareTo((Copy) obj) == 0; + } + + @Override + public int hashCode() { + return new ListOf<>(this.score().suffixes()).size(); + } + + /** + * Creates new Copy instance with additional remote. + * + * @param remote Remote + * @return Copy Copy + */ + Copy with(final Remote remote) { + return new Copy(this.wallet(), new Joined<>(remote, this.remotes)); + } + + /** + * The wallet. + * + * @return The wallet + */ + Wallet wallet() { + return this.wlt; + } + + /** + * The summary of the score of all the remote nodes. + * + * @return The score + */ + Score score() { + return new Score.Summed(new Mapped<>(Remote::score, this.remotes)); + } +} + diff --git a/src/main/java/io/zold/api/CpTransaction.java b/src/main/java/io/zold/api/CpTransaction.java index b1592eb..e49b133 100644 --- a/src/main/java/io/zold/api/CpTransaction.java +++ b/src/main/java/io/zold/api/CpTransaction.java @@ -10,6 +10,7 @@ /** * Computed Transaction. + * * @since 1.0 * @todo #54:30min Implement the computation of the transaction string * based on the white paper. The unit tests should also be updated to @@ -20,9 +21,9 @@ public final class CpTransaction extends TransactionEnvelope { /** * Ctor. + * * @param amt Amount to pay in zents * @param bnf Wallet ID of beneficiary - * @checkstyle ConstructorsCodeFreeCheck (13 lines) */ CpTransaction(final long amt, final long bnf) { super( diff --git a/src/main/java/io/zold/api/Loaded.java b/src/main/java/io/zold/api/Loaded.java new file mode 100644 index 0000000..0f8c571 --- /dev/null +++ b/src/main/java/io/zold/api/Loaded.java @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2018-2026 Zerocracy + * SPDX-License-Identifier: MIT + */ +package io.zold.api; + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; + +/** + * Loaded remotes. + * + * @since 1.0 + */ +final class Loaded implements Iterable { + + /** + * JSON file. + */ + private final Path file; + + /** + * Descriptor loader. + */ + private final Function loader; + + /** + * New loaded remotes. + * + * @param file JSON file + * @param loader Descriptor loader + * @throws IOException If the file cannot be read + */ + Loaded( + final Path file, + final Function loader + ) throws IOException { + this.file = file; + this.loader = loader; + } + + @Override + public Iterator iterator() { + try { + return this.load().iterator(); + } catch (final IOException err) { + throw new UncheckedIOException(err); + } + } + + private Iterable load() throws IOException { + final List remotes = new ArrayList<>(0); + try ( + JsonReader reader = Json.createReader( + Files.newBufferedReader(this.file, StandardCharsets.UTF_8) + ) + ) { + reader.readArray().stream() + .map(value -> (JsonObject) value) + .map(this.loader) + .forEach(remotes::add); + } + return remotes; + } +} diff --git a/src/main/java/io/zold/api/Network.java b/src/main/java/io/zold/api/Network.java index 53f222c..0fafa78 100644 --- a/src/main/java/io/zold/api/Network.java +++ b/src/main/java/io/zold/api/Network.java @@ -8,18 +8,21 @@ /** * Network of remote nodes. + * * @since 0.1 */ public interface Network extends Iterable { /** * Push the wallet to the network. + * * @param wallet The wallet */ void push(Wallet wallet); /** * Pull a wallet from the network. + * * @param id The wallet's {@link Wallet#id() id} * @return The wallet * @throws IOException If an IO error occurs diff --git a/src/main/java/io/zold/api/Remote.java b/src/main/java/io/zold/api/Remote.java index 20d630b..5cf4d77 100644 --- a/src/main/java/io/zold/api/Remote.java +++ b/src/main/java/io/zold/api/Remote.java @@ -10,24 +10,28 @@ /** * Remote node. + * * @since 0.1 */ public interface Remote { /** * This remote node's score. + * * @return The score */ Score score(); /** * Pushes a {@link Wallet} to this remote. + * * @param wallet Wallet to be pushed to this remote */ void push(Wallet wallet); /** * Pull a wallet from this remote. + * * @param id The wallet's {@link Wallet#id() id} * @return The wallet */ @@ -35,6 +39,7 @@ public interface Remote { /** * A Fake {@link Remote}. + * * @since 1.0 */ final class Fake implements Remote { @@ -46,6 +51,7 @@ final class Fake implements Remote { /** * Ctor. + * * @param val The remote's score value */ public Fake(final int val) { @@ -56,6 +62,7 @@ public Fake(final int val) { /** * Ctor. + * * @param score The remote's score */ public Fake(final Score score) { diff --git a/src/main/java/io/zold/api/RtNetwork.java b/src/main/java/io/zold/api/RtNetwork.java index 6a4e3e6..83781f8 100644 --- a/src/main/java/io/zold/api/RtNetwork.java +++ b/src/main/java/io/zold/api/RtNetwork.java @@ -5,16 +5,10 @@ package io.zold.api; import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Iterator; -import java.util.List; import java.util.function.Function; -import javax.json.Json; import javax.json.JsonObject; -import javax.json.JsonReader; import org.cactoos.iterable.IterableOf; import org.cactoos.iterable.Joined; import org.cactoos.iterable.Mapped; @@ -24,6 +18,7 @@ /** * Network implementation. + * * @since 0.1 */ public final class RtNetwork implements Network { @@ -35,6 +30,7 @@ public final class RtNetwork implements Network { /** * New network loaded from a local JSON file. + * * @param file JSON file with remote descriptors * @param builtins Pre-configured remote nodes * @param loader Converts a JSON descriptor into a remote node @@ -46,9 +42,9 @@ public RtNetwork( final Function loader ) throws IOException { this( - new Joined( - new IterableOf>( - builtins, new RtNetwork.Loaded(file, loader) + new Joined<>( + new IterableOf<>( + builtins, new Loaded(file, loader) ) ) ); @@ -56,6 +52,7 @@ public RtNetwork( /** * Constructor. + * * @param remotes Remotes of the network */ RtNetwork(final Iterable remotes) { @@ -86,69 +83,4 @@ public Wallet pull(final long id) throws IOException { public Iterator iterator() { return this.nodes.iterator(); } - - /** - * Loads remote descriptors from JSON. - * @param file JSON file - * @param loader Descriptor loader - * @return Loaded remotes - * @throws IOException If the file cannot be read - */ - private static Iterable load( - final Path file, - final Function loader - ) throws IOException { - final List remotes = new ArrayList<>(0); - try ( - JsonReader reader = Json.createReader( - Files.newBufferedReader(file, StandardCharsets.UTF_8) - ) - ) { - reader.readArray().stream() - .map(value -> (JsonObject) value) - .map(loader) - .forEach(remotes::add); - } - return remotes; - } - - /** - * Loaded remotes. - * @since 1.0 - */ - private static final class Loaded implements Iterable { - - /** - * JSON file. - */ - private final Path file; - - /** - * Descriptor loader. - */ - private final Function loader; - - /** - * New loaded remotes. - * @param file JSON file - * @param loader Descriptor loader - * @throws IOException If the file cannot be read - */ - Loaded( - final Path file, - final Function loader - ) throws IOException { - this.file = file; - this.loader = loader; - } - - @Override - public Iterator iterator() { - try { - return RtNetwork.load(this.file, this.loader).iterator(); - } catch (final IOException err) { - throw new java.io.UncheckedIOException(err); - } - } - } } diff --git a/src/main/java/io/zold/api/RtScore.java b/src/main/java/io/zold/api/RtScore.java index e73ecd4..26df447 100644 --- a/src/main/java/io/zold/api/RtScore.java +++ b/src/main/java/io/zold/api/RtScore.java @@ -10,6 +10,7 @@ /** * Default implementation for {@link Score}. + * * @since 1.0 */ public final class RtScore implements Score { @@ -21,6 +22,7 @@ public final class RtScore implements Score { /** * Ctor. + * * @param sfxs The suffixes */ RtScore(final Iterable sfxs) { diff --git a/src/main/java/io/zold/api/RtTransaction.java b/src/main/java/io/zold/api/RtTransaction.java index 6ab100f..f651499 100644 --- a/src/main/java/io/zold/api/RtTransaction.java +++ b/src/main/java/io/zold/api/RtTransaction.java @@ -26,17 +26,15 @@ /** * RtTransaction. + * * @since 0.1 - * @checkstyle ClassDataAbstractionCoupling (3 lines) */ -@SuppressWarnings("PMD.TooManyMethods") final class RtTransaction implements Transaction { /** * Pattern for Prefix String. */ private static final Pattern PREFIX = Pattern.compile( - //@checkstyle LineLengthCheck (1 line) "^([A-Za-z0-9+\\/]{4})*([A-Za-z0-9+\\/]{4}|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{2}==)$" ); @@ -68,6 +66,7 @@ final class RtTransaction implements Transaction { /** * Ctor. + * * @param trnsct String representation of transaction * @checkstyle LambdaBodyLengthCheck (28 lines) */ @@ -88,11 +87,9 @@ final class RtTransaction implements Transaction { new ListOf<>( new Split(trnsct, ";") ); - // @checkstyle MagicNumberCheck (1 line) if (new LengthOf(pieces).value().intValue() != 7) { throw new IOException( new FormattedText( - // @checkstyle LineLength (1 line) "Invalid transaction string: expected 7 fields, but found %d", pieces.size() ).asString() @@ -111,14 +108,12 @@ public int id() throws IOException { throw new IOException( new UncheckedText( new FormattedText( - // @checkstyle LineLength (1 line) "Invalid ID '%s' expecting 16-bit unsigned hex string with 4 symbols", ident ) ).asString() ); } - // @checkstyle MagicNumber (1 line) return Integer.parseUnsignedInt(ident, 16); } @@ -137,22 +132,18 @@ public long amount() throws IOException { throw new IOException( new UncheckedText( new FormattedText( - // @checkstyle LineLength (1 line) "Invalid amount '%s' expecting 64-bit signed hex string with 16 symbols", amnt ) ).asString() ); } - // @checkstyle MagicNumber (1 line) return new BigInteger(amnt, 16).longValue(); } @Override public String prefix() throws IOException { - //@checkstyle MagicNumberCheck (1 line) final String prefix = this.field(3); - //@checkstyle MagicNumberCheck (1 line) if (prefix.length() < 8 || prefix.length() > 32) { throw new IOException("Invalid prefix size"); } @@ -164,13 +155,11 @@ public String prefix() throws IOException { @Override public String bnf() throws IOException { - //@checkstyle MagicNumberCheck (1 line) final String bnf = this.field(4); if (!RtTransaction.HEX.matcher(bnf).matches()) { throw new IOException( new UncheckedText( new FormattedText( - // @checkstyle LineLength (1 line) "Invalid bnf string '%s', expecting hex string with 16 symbols", bnf ) @@ -182,13 +171,11 @@ public String bnf() throws IOException { @Override public String details() throws IOException { - //@checkstyle MagicNumberCheck (1 line) final String dtls = this.field(5); if (!RtTransaction.DTLS.matcher(dtls).matches()) { throw new IOException( new UncheckedText( new FormattedText( - // @checkstyle LineLength (1 line) "Invalid details string '%s', does not match pattern '%s'", dtls, RtTransaction.DTLS ) @@ -200,15 +187,12 @@ public String details() throws IOException { @Override public String signature() throws IOException { - //@checkstyle MagicNumberCheck (1 line) final String sign = this.field(6); - // @checkstyle MagicNumber (1 line) if (sign.length() != 684 || !RtTransaction.SIGN.matcher(sign).matches()) { throw new IOException( new UncheckedText( new FormattedText( - // @checkstyle LineLength (1 line) "Invalid signature '%s', expecting base64 string with 684 characters", sign ) @@ -239,13 +223,6 @@ public int hashCode() { return this.transaction.hashCode(); } - /** - * The field at the given position in the semicolon-separated - * transaction string. - * @param index Zero-based position of the field - * @return The raw field value - * @throws IOException If an IO error occurs - */ private String field(final int index) throws IOException { return new UncheckedText( new IoChecked<>( diff --git a/src/main/java/io/zold/api/Score.java b/src/main/java/io/zold/api/Score.java index 5d5120b..bdbfa76 100644 --- a/src/main/java/io/zold/api/Score.java +++ b/src/main/java/io/zold/api/Score.java @@ -12,9 +12,9 @@ /** * A remote node's score, equal to its number of suffixes. * - *

The natural order of {@link Score} is from highest to lowest. + *

The natural order of {@link Score} is from highest to lowest.

* - *

Note: {@link Score} has a natural ordering that is inconsistent with equals. + *

Note: {@link Score} has a natural ordering that is inconsistent with equals.

* * @since 0.1 */ @@ -24,18 +24,21 @@ public interface Score extends Comparable { /** * The suffixes associated with this score. Each suffix is a text of the * form {@code /[a-zA-Z0-9]+/}. + * * @return Suffixes for this score */ Iterable suffixes(); /** * Summary of multiple {@link Score}. + * * @since 1.0 */ final class Summed extends ScoreEnvelope { /** * Ctor. + * * @param scores Multiple scores to summary */ Summed(final Iterable scores) { diff --git a/src/main/java/io/zold/api/TaxBeneficiaries.java b/src/main/java/io/zold/api/TaxBeneficiaries.java index 72c3b8e..4d2fda0 100644 --- a/src/main/java/io/zold/api/TaxBeneficiaries.java +++ b/src/main/java/io/zold/api/TaxBeneficiaries.java @@ -12,20 +12,20 @@ /** * {@link Remote} nodes that should receive taxes. + * * @since 1.0 */ public final class TaxBeneficiaries extends IterableEnvelope { /** * Ctor. + * * @param nodes Remote nodes to select from - * @checkstyle ConstructorsCodeFreeCheck (10 lines) */ public TaxBeneficiaries(final Iterable nodes) { super(new Sorted<>( Comparator.comparing(Remote::score), new Filtered<>( - // @checkstyle MagicNumberCheck (1 line) n -> new LengthOf(n.score().suffixes()).value().intValue() >= 16, nodes ) diff --git a/src/main/java/io/zold/api/Taxes.java b/src/main/java/io/zold/api/Taxes.java index 4e8b05c..12db6c1 100644 --- a/src/main/java/io/zold/api/Taxes.java +++ b/src/main/java/io/zold/api/Taxes.java @@ -10,6 +10,7 @@ /** * Taxes payment algorithm. + * * @since 1.0 * @todo #61:30min Implement tax payment to remote nodes. * Payment should happen only if the wallet is in debt of more than @@ -29,6 +30,7 @@ public final class Taxes implements Proc { /** * Ctor. + * * @param nodes Remote nodes */ public Taxes(final Iterable nodes) { diff --git a/src/main/java/io/zold/api/Transaction.java b/src/main/java/io/zold/api/Transaction.java index d67bfaf..1f346a8 100644 --- a/src/main/java/io/zold/api/Transaction.java +++ b/src/main/java/io/zold/api/Transaction.java @@ -10,6 +10,7 @@ /** * A payment transaction. + * * @since 0.1 */ @GenerateEnvelope @@ -17,14 +18,15 @@ public interface Transaction { /** * Id of this transaction. + * * @return Id ID * @throws IOException When something goes wrong - * @checkstyle MethodNameCheck (3 lines) */ int id() throws IOException; /** * Timestamp of this transaction. + * * @return Time * @throws IOException When something goes wrong */ @@ -32,6 +34,7 @@ public interface Transaction { /** * Amount involved in this transaction. + * * @return Amount * @throws IOException When something goes wrong */ @@ -39,6 +42,7 @@ public interface Transaction { /** * Prefix. + * * @return Prefix * @throws IOException When something goes wrong */ @@ -46,6 +50,7 @@ public interface Transaction { /** * Beneficiary. + * * @return Beneficiary * @throws IOException When something goes wrong */ @@ -53,6 +58,7 @@ public interface Transaction { /** * Details. + * * @return Details * @throws IOException When something goes wrong */ @@ -60,6 +66,7 @@ public interface Transaction { /** * RSA Signature. + * * @return RSA Signature * @throws IOException When something goes wrong */ @@ -76,14 +83,15 @@ public interface Transaction { /** * Fake implementation of Transaction, read from one ledger line. + * * @since 1.0 */ final class Fake extends TransactionEnvelope { /** * Constructor. + * * @param line Transaction line with seven fields separated by semicolons - * @checkstyle ConstructorsCodeFreeCheck (3 lines) */ public Fake(final String line) { super(new RtTransaction(line)); diff --git a/src/main/java/io/zold/api/Wallet.java b/src/main/java/io/zold/api/Wallet.java index f1a02be..59ead78 100644 --- a/src/main/java/io/zold/api/Wallet.java +++ b/src/main/java/io/zold/api/Wallet.java @@ -28,6 +28,7 @@ /** * Wallet. + * * @since 0.1 * @todo #16:30min Merge method should update transactions * in wallet's file and return concrete implementation not a fake one. @@ -38,15 +39,15 @@ public interface Wallet { /** * This wallet's ID: an unsigned 64-bit integer. + * * @return This wallet's id * @throws IOException If an IO error occurs - * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) - * @checkstyle MethodName (2 lines) */ long id() throws IOException; /** * Make a payment. + * * @param amt Amount to pay in zents * @param bnf Wallet ID of beneficiary * @throws IOException If an IO error occurs @@ -56,6 +57,7 @@ public interface Wallet { /** * Merge both {@code this} and {@code other}. Fails if they are not the * same wallet, as identified by their {@link #id() id}. + * * @param other Other wallet * @return The merged wallet * @throws IOException If an IO error occurs @@ -64,12 +66,14 @@ public interface Wallet { /** * This wallet's ledger. + * * @return This wallet's ledger */ Iterable ledger(); /** * This wallet's RSA key. + * * @return This wallet's RSA key * @throws IOException If an IO error occurs */ @@ -77,6 +81,7 @@ public interface Wallet { /** * A Fake {@link Wallet}. + * * @since 1.0 * @todo #65:30min Complete Wallet implementations with id, public RSA * key and network id. Wallets.create(Long, String, String) must @@ -100,6 +105,7 @@ final class Fake implements Wallet { /** * Constructor. + * * @param id The wallet id */ public Fake(final long id) { @@ -108,6 +114,7 @@ public Fake(final long id) { /** * Ctor. + * * @param id The wallet id * @param transactions Transactions */ @@ -117,10 +124,10 @@ public Fake(final long id, final Transaction... transactions) { /** * Constructor. + * * @param id The wallet id * @param pubkey The public RSA key of the wallet owner * @param network The network the wallet belongs to - * @checkstyle UnusedFormalParameter (2 lines) */ public Fake(final long id, final String pubkey, final String network) { this(id); @@ -128,6 +135,7 @@ public Fake(final long id, final String pubkey, final String network) { /** * Ctor. + * * @param id The wallet id * @param transactions Transactions */ @@ -164,8 +172,8 @@ public String key() { /** * Default File implementation. + * * @since 1.0 - * @checkstyle ClassDataAbstractionCouplingCheck (2 lines) */ final class File implements Wallet { @@ -176,6 +184,7 @@ final class File implements Wallet { /** * Ctor. + * * @param path Path of wallet */ File(final Path path) { @@ -193,7 +202,6 @@ public long id() throws IOException { "\n" ) ).get(2).asString(), - // @checkstyle MagicNumber (1 line) 16 ), e -> new IOException(e) @@ -253,7 +261,6 @@ public Iterable ledger() { return new Mapped<>( txt -> new RtTransaction(txt.asString()), new Skipped<>( - // @checkstyle MagicNumberCheck (1 line) 5, new ListOf<>( new Split( @@ -274,20 +281,11 @@ public String key() throws IOException { new TextOf(this.path), "\n" ) - // @checkstyle MagicNumberCheck (1 line) ).get(3).asString(), e -> new IOException(e) ).value(); } - /** - * Whether an incoming transaction is acceptable. - * @param incoming Incoming transaction - * @param ledger Current ledger - * @param balance Current balance - * @return Whether it is acceptable - * @throws IOException If a transaction cannot be read - */ private static boolean accepts( final Transaction incoming, final Iterable ledger, @@ -318,11 +316,6 @@ private static boolean accepts( ).iterator().hasNext(); } - /** - * Calculate the current balance. - * @param ledger Current ledger - * @return Current balance - */ private static long balance(final Iterable ledger) { return new SumOf( new Mapped<>( diff --git a/src/main/java/io/zold/api/Wallets.java b/src/main/java/io/zold/api/Wallets.java index d6b5d3a..a53fd62 100644 --- a/src/main/java/io/zold/api/Wallets.java +++ b/src/main/java/io/zold/api/Wallets.java @@ -9,12 +9,14 @@ /** * Wallets. + * * @since 0.1 */ public interface Wallets extends Iterable { /** * Create a wallet. + * * @return The new wallet * @throws IOException If an error occurs */ @@ -22,6 +24,7 @@ public interface Wallets extends Iterable { /** * Create a wallet. + * * @param id The wallet id * @param pubkey The wallet public key * @param network The network the wallet belongs diff --git a/src/main/java/io/zold/api/WalletsIn.java b/src/main/java/io/zold/api/WalletsIn.java index b6a3e3b..cc8b625 100644 --- a/src/main/java/io/zold/api/WalletsIn.java +++ b/src/main/java/io/zold/api/WalletsIn.java @@ -25,8 +25,8 @@ /** * Wallets in path. + * * @since 0.1 - * @checkstyle ClassDataAbstractionCoupling (2 lines) */ public final class WalletsIn implements Wallets { @@ -52,6 +52,7 @@ public final class WalletsIn implements Wallets { /** * Ctor. + * * @param pth Path with wallets */ public WalletsIn(final Path pth) { @@ -64,6 +65,7 @@ public WalletsIn(final Path pth) { /** * Ctor. + * * @param pth Path with wallets * @param random Randomizer */ @@ -77,6 +79,7 @@ public WalletsIn(final Path pth, final Random random) { /** * Ctor. + * * @param pth Path with wallets * @param ext Wallets file extension * @param random Randomizer diff --git a/src/main/java/io/zold/api/package-info.java b/src/main/java/io/zold/api/package-info.java index a387269..41e4bd1 100644 --- a/src/main/java/io/zold/api/package-info.java +++ b/src/main/java/io/zold/api/package-info.java @@ -5,6 +5,7 @@ /** * Java API. + * * @since 0.1 */ package io.zold.api; diff --git a/src/test/java/io/zold/api/CopiesTest.java b/src/test/java/io/zold/api/CopiesTest.java index dea0080..3e025e9 100644 --- a/src/test/java/io/zold/api/CopiesTest.java +++ b/src/test/java/io/zold/api/CopiesTest.java @@ -13,13 +13,13 @@ /** * Test case for {@link Copies}. + * * @since 1.0 * @todo #56:30min Add more test scenarios to Copies. * Scenarios: * remotes return empty list * remotes return single element * remotes return wallets with different content - * @checkstyle JavadocMethodCheck (500 lines) */ final class CopiesTest { @@ -57,8 +57,8 @@ void equalCopiesHaveEqualHashCodes() { ); } - private static Copies.Copy copy(final long id) { - return new Copies.Copy( + private static Copy copy(final long id) { + return new Copy( new Wallet.Fake(id), new Remote.Fake( new RtScore(new IterableOf<>(new TextOf("a"))) @@ -66,7 +66,7 @@ private static Copies.Copy copy(final long id) { ); } - private static Iterable copies() { + private static Iterable copies() { return new Copies( 1L, new IterableOf<>( diff --git a/src/test/java/io/zold/api/CpTransactionTest.java b/src/test/java/io/zold/api/CpTransactionTest.java index 99d4e8b..d7983b2 100644 --- a/src/test/java/io/zold/api/CpTransactionTest.java +++ b/src/test/java/io/zold/api/CpTransactionTest.java @@ -13,10 +13,8 @@ /** * Test case for {@link CpTransaction}. + * * @since 1.0 - * @checkstyle LineLengthCheck (500 lines) - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle MagicNumberCheck (500 lines) */ @SuppressWarnings("PMD.UnnecessaryLocalRule") final class CpTransactionTest { diff --git a/src/test/java/io/zold/api/NetworkTest.java b/src/test/java/io/zold/api/NetworkTest.java index 635949b..30fffbf 100644 --- a/src/test/java/io/zold/api/NetworkTest.java +++ b/src/test/java/io/zold/api/NetworkTest.java @@ -9,6 +9,8 @@ import java.nio.file.Files; import java.nio.file.Path; import org.cactoos.iterable.IterableOf; +import org.cactoos.scalar.LengthOf; +import org.cactoos.scalar.Unchecked; import org.cactoos.text.TextOf; import org.hamcrest.MatcherAssert; import org.hamcrest.core.IsEqual; @@ -17,14 +19,12 @@ /** * Test case for {@link Network}. + * * @since 0.1 * @todo #5:30min Implement Remote interface. Remote Interface must be * implemented because Network depends on Remote behavior. Network.pull * needs to search all remotes for some wallet id and merge all found * wallets; Network.push must push a wallet to a remote based in remote. - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle MagicNumberCheck (500 lines) - * @checkstyle ClassDataAbstractionCouplingCheck (2 lines) */ @SuppressWarnings("PMD.UnnecessaryLocalRule") final class NetworkTest { @@ -70,14 +70,15 @@ void loadsRemotesFromJsonFile() throws IOException { "[{\"score\": 2}]".getBytes(StandardCharsets.UTF_8) ); try { - int count = 0; - for (final Remote ignored : new RtNetwork( - file, - new IterableOf<>(new Remote.Fake(1)), - json -> new Remote.Fake(json.getInt("score")) - )) { - count += 1; - } + final int count = new Unchecked<>( + new LengthOf( + new RtNetwork( + file, + new IterableOf<>(new Remote.Fake(1)), + json -> new Remote.Fake(json.getInt("score")) + ) + ) + ).value().intValue(); MatcherAssert.assertThat( count, new IsEqual<>(2) diff --git a/src/test/java/io/zold/api/RtTransactionTest.java b/src/test/java/io/zold/api/RtTransactionTest.java index a9498a7..c925ea2 100644 --- a/src/test/java/io/zold/api/RtTransactionTest.java +++ b/src/test/java/io/zold/api/RtTransactionTest.java @@ -11,28 +11,26 @@ import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.hamcrest.core.IsEqual; -import org.junit.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test case for {@link RtTransaction}. + * * @since 0.1 * @checkstyle LineLengthCheck (500 lines) - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle MagicNumber (500 lines) */ -@SuppressWarnings("PMD.TooManyMethods") -public final class RtTransactionTest { +final class RtTransactionTest { @Test - public void obeysEqualsHashcodeContract() { + void obeysEqualsHashcodeContract() { EqualsVerifier.forClass(RtTransaction.class) .withNonnullFields("transaction") .verify(); } @Test - public void returnsId() throws IOException { + void returnsId() throws IOException { MatcherAssert.assertThat( new RtTransaction( "abcd;2017-07-19T21:25:07Z;0000000000a72366;xksQuJa9;98bb82c81735c4ee;For food;QCuLuVr4..." @@ -42,7 +40,7 @@ public void returnsId() throws IOException { } @Test - public void idFormatViolated() { + void idFormatViolated() { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -55,7 +53,7 @@ public void idFormatViolated() { } @Test - public void idStringTooLong() { + void idStringTooLong() { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -68,7 +66,7 @@ public void idStringTooLong() { } @Test - public void idStringTooShort() { + void idStringTooShort() { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -81,7 +79,7 @@ public void idStringTooShort() { } @Test - public void idNotPresent() { + void idNotPresent() { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -92,7 +90,7 @@ public void idNotPresent() { } @Test - public void parsesAndReturnsIsoFormattedTime() throws IOException { + void parsesAndReturnsIsoFormattedTime() throws IOException { MatcherAssert.assertThat( new RtTransaction( "003b;2018-07-19T21:25:07Z;ffffffffffa72367;xksQuJa9;98bb82c81735c4ee; For food;QCuLuVr4..." @@ -102,7 +100,7 @@ public void parsesAndReturnsIsoFormattedTime() throws IOException { } @Test - public void invalidTimeFormat() throws IOException { + void invalidTimeFormat() throws IOException { Assertions.assertThrows( DateTimeParseException.class, () -> new RtTransaction( @@ -112,7 +110,7 @@ public void invalidTimeFormat() throws IOException { } @Test - public void timeNotPresent() throws IOException { + void timeNotPresent() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -123,7 +121,7 @@ public void timeNotPresent() throws IOException { } @Test - public void returnsPositiveAmount() throws IOException { + void returnsPositiveAmount() throws IOException { MatcherAssert.assertThat( new RtTransaction( "003b;2017-07-19T21:25:07Z;0000000000a72366;xksQuJa9;98bb82c81735c4ee;For food;QCuLuVr4..." @@ -133,7 +131,7 @@ public void returnsPositiveAmount() throws IOException { } @Test - public void returnsNegativeAmount() throws IOException { + void returnsNegativeAmount() throws IOException { MatcherAssert.assertThat( new RtTransaction( "003b;2017-07-19T21:25:07Z;ffffffffffa72366;xksQuJa9;98bb82c81735c4ee;For food;QCuLuVr4..." @@ -143,7 +141,7 @@ public void returnsNegativeAmount() throws IOException { } @Test - public void amountFormatViolated() throws IOException { + void amountFormatViolated() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -156,7 +154,7 @@ public void amountFormatViolated() throws IOException { } @Test - public void amountStringTooLong() throws IOException { + void amountStringTooLong() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -169,7 +167,7 @@ public void amountStringTooLong() throws IOException { } @Test - public void amountStringTooShort() throws IOException { + void amountStringTooShort() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -182,7 +180,7 @@ public void amountStringTooShort() throws IOException { } @Test - public void amountNotPresent() throws IOException { + void amountNotPresent() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -195,7 +193,7 @@ public void amountNotPresent() throws IOException { } @Test - public void returnsPrefix() throws IOException { + void returnsPrefix() throws IOException { MatcherAssert.assertThat( "Returned wrong prefix", new RtTransaction( @@ -206,7 +204,7 @@ public void returnsPrefix() throws IOException { } @Test - public void prefixFormatViolated() { + void prefixFormatViolated() { Assertions.assertThrows( IOException.class, () -> new RtTransaction( @@ -216,7 +214,7 @@ public void prefixFormatViolated() { } @Test - public void prefixSizeViolatedLess() { + void prefixSizeViolatedLess() { Assertions.assertThrows( IOException.class, () -> new RtTransaction( @@ -226,7 +224,7 @@ public void prefixSizeViolatedLess() { } @Test - public void prefixSizeViolatedMore() { + void prefixSizeViolatedMore() { Assertions.assertThrows( IOException.class, () -> new RtTransaction( @@ -236,7 +234,7 @@ public void prefixSizeViolatedMore() { } @Test - public void prefixNotPresent() throws IOException { + void prefixNotPresent() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -249,7 +247,7 @@ public void prefixNotPresent() throws IOException { } @Test - public void invalidTransactionString() { + void invalidTransactionString() { Assertions.assertThrows( IOException.class, () -> new RtTransaction( @@ -259,7 +257,7 @@ public void invalidTransactionString() { } @Test - public void returnsBnf() throws IOException { + void returnsBnf() throws IOException { MatcherAssert.assertThat( new RtTransaction( "003b;2017-07-19T21:25:07Z;0000000000a72366;xksQuJa9;000000C81735c4ee;For food;QCuLuVr4..." @@ -269,7 +267,7 @@ public void returnsBnf() throws IOException { } @Test - public void bnfSizeTooLong() throws IOException { + void bnfSizeTooLong() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -282,7 +280,7 @@ public void bnfSizeTooLong() throws IOException { } @Test - public void bnfSizeTooShort() throws IOException { + void bnfSizeTooShort() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -295,7 +293,7 @@ public void bnfSizeTooShort() throws IOException { } @Test - public void invalidBnfCharacter() throws IOException { + void invalidBnfCharacter() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -308,7 +306,7 @@ public void invalidBnfCharacter() throws IOException { } @Test - public void bnfNotPresent() throws IOException { + void bnfNotPresent() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -323,7 +321,7 @@ public void bnfNotPresent() throws IOException { } @Test - public void returnsDetails() throws IOException { + void returnsDetails() throws IOException { MatcherAssert.assertThat( "Returned wrong details", new RtTransaction( @@ -334,7 +332,7 @@ public void returnsDetails() throws IOException { } @Test - public void detailsFormatViolated() throws IOException { + void detailsFormatViolated() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -347,7 +345,7 @@ public void detailsFormatViolated() throws IOException { } @Test - public void detailsSizeTooShort() throws IOException { + void detailsSizeTooShort() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -360,7 +358,7 @@ public void detailsSizeTooShort() throws IOException { } @Test - public void detailsSizeTooLong() throws IOException { + void detailsSizeTooLong() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -375,7 +373,7 @@ public void detailsSizeTooLong() throws IOException { } @Test - public void detailsAbsentTransactionString() throws IOException { + void detailsAbsentTransactionString() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -388,7 +386,7 @@ public void detailsAbsentTransactionString() throws IOException { } @Test - public void returnsSignature() throws IOException { + void returnsSignature() throws IOException { MatcherAssert.assertThat( new RtTransaction( "003b;2018-07-19T21:25:07Z;ffffffffffa72367;xksQuJa9;98bb82c81735c4ee;For food;WKF3Emi4R2OCbPqUuFSykGD4JtAeWc8WThSYUnmLH2w1RiNSa8KNBGUw56mh0jYjmA1AXRyP/Iktqatmczp+isvh2iBN9hpZgavJ1fFjOgoFmNFe8PT8vg4ZC/vOVgMc807icX7O5i36fi0MEvEv242+2z/Gju3vcb42cZMupDoOEF/CDcEy1Ng7iAFdyLoMja74cMo6H7U0z97e2c2Sa1Eidmkdn+mXNbFsx5RizLtLUfhMtghf697Qu9i1N9lY/Qwk8SvgSviPPWs1cjjK/Fsg1ezfHSWbbHmK8/4qkvgkHqAwVwfD7bWm+1McxzNkU4X5pqE/vW5Tm/K9o7wq4N8u355U+xpgTShPEDN9u6QfdE2O4b/Q6rTzVHMX4j66cLrB8am6K9OQ7LYGShRcqR5L078RyjqHm/wDSzfZWbq8NsjmVm7Dr8NVxJ+0jS2U/r+Fo2+uyjDBn5n/UcqxUGgt0qHaGPoi7kezFHcqeVXp8RLetfXa/TBTj39Gc7aBNBFxkfaM7I/TSpI+xjtjr1cfquut/NiVLMSEVipOIEZ+Sjgf9jLjmpNfRDavz3kGi20TkL4szEvgz8bD1dT6Kf7FKPu7YBMYFoyY12RK7NZcdVr+4yNLFbRtaZYwdhrRLYwKaHli4oUN2CjAOHivVw3Ig8x/JySGxsiy3aJD8L3=" @@ -398,7 +396,7 @@ public void returnsSignature() throws IOException { } @Test - public void invalidSignatureCharacters() throws IOException { + void invalidSignatureCharacters() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -411,7 +409,7 @@ public void invalidSignatureCharacters() throws IOException { } @Test - public void invalidSignatureLength() throws IOException { + void invalidSignatureLength() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, @@ -426,7 +424,7 @@ public void invalidSignatureLength() throws IOException { } @Test - public void signatureNotPresent() throws IOException { + void signatureNotPresent() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( IOException.class, diff --git a/src/test/java/io/zold/api/ScoreTest.java b/src/test/java/io/zold/api/ScoreTest.java index ae1fbdb..688a128 100644 --- a/src/test/java/io/zold/api/ScoreTest.java +++ b/src/test/java/io/zold/api/ScoreTest.java @@ -11,20 +11,18 @@ import org.hamcrest.MatcherAssert; import org.hamcrest.collection.IsIterableContainingInOrder; import org.hamcrest.core.IsEqual; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test case for {@link Score}. + * * @since 1.0 - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) */ -@SuppressWarnings("PMD.UnnecessaryLocalRule") -public final class ScoreTest { +final class ScoreTest { @Test @SuppressWarnings("unchecked") - public void fewerSuffixesComeAfter() { + void fewerSuffixesComeAfter() { final Score lowest = new RtScore( new IterableOf<>(new TextOf("a")) ); @@ -41,7 +39,7 @@ public void fewerSuffixesComeAfter() { @Test @SuppressWarnings("unchecked") - public void sumWithFewerSuffixesComesAfter() { + void sumWithFewerSuffixesComesAfter() { final Score lowest = new RtScore( new IterableOf<>(new TextOf("a")) ); diff --git a/src/test/java/io/zold/api/TaxBeneficiariesTest.java b/src/test/java/io/zold/api/TaxBeneficiariesTest.java index 1f2fb59..930f6b7 100644 --- a/src/test/java/io/zold/api/TaxBeneficiariesTest.java +++ b/src/test/java/io/zold/api/TaxBeneficiariesTest.java @@ -9,20 +9,19 @@ import org.hamcrest.MatcherAssert; import org.hamcrest.collection.IsIterableContainingInOrder; import org.hamcrest.core.IsEqual; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Test case for {@link TaxBeneficiaries}. + * * @since 1.0 - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle MagicNumberCheck (500 lines) */ @SuppressWarnings("PMD.UnnecessaryLocalRule") -public final class TaxBeneficiariesTest { +final class TaxBeneficiariesTest { @Test @SuppressWarnings("unchecked") - public void sorts() { + void sorts() { final Remote highremote = new Remote.Fake(20); final Remote lowremote = new Remote.Fake(18); MatcherAssert.assertThat( @@ -41,7 +40,7 @@ public void sorts() { @Test @SuppressWarnings("unchecked") - public void filters() { + void filters() { final Remote highremote = new Remote.Fake(20); final Remote vrylowremote = new Remote.Fake(14); MatcherAssert.assertThat( diff --git a/src/test/java/io/zold/api/TaxesTest.java b/src/test/java/io/zold/api/TaxesTest.java index 6cf47be..3219bc0 100644 --- a/src/test/java/io/zold/api/TaxesTest.java +++ b/src/test/java/io/zold/api/TaxesTest.java @@ -12,21 +12,16 @@ /** * Test case for {@link Taxes}. + * * @since 1.0 - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) - * @checkstyle MagicNumberCheck (500 lines) * @checkstyle MethodBodyCommentsCheck (500 lines) * @checkstyle AbbreviationAsWordInNameCheck (500 lines) - * @checkstyle LineLengthCheck (500 lines) */ -@SuppressWarnings("PMD.UnnecessaryLocalRule") final class TaxesTest { @Test void pay() throws Exception { final List ledger = new ArrayList<>(5); - // @checkstyle AvoidInstantiatingObjectsInLoops (9 lines) for (int index = 0; index < 5; ++index) { ledger.add( new Transaction.Fake( diff --git a/src/test/java/io/zold/api/TransactionTest.java b/src/test/java/io/zold/api/TransactionTest.java index 7773a97..a928ffe 100644 --- a/src/test/java/io/zold/api/TransactionTest.java +++ b/src/test/java/io/zold/api/TransactionTest.java @@ -10,9 +10,8 @@ /** * Test case for {@link Transaction}. + * * @since 1.0 - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle LineLengthCheck (500 lines) */ final class TransactionTest { diff --git a/src/test/java/io/zold/api/WalletTest.java b/src/test/java/io/zold/api/WalletTest.java index b4c2ab4..795cab0 100644 --- a/src/test/java/io/zold/api/WalletTest.java +++ b/src/test/java/io/zold/api/WalletTest.java @@ -13,35 +13,28 @@ import org.hamcrest.Matchers; import org.hamcrest.collection.IsIterableWithSize; import org.hamcrest.core.IsEqual; -import org.junit.Rule; -import org.junit.Test; import org.junit.jupiter.api.Assertions; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.llorllale.cactoos.matchers.IsApplicable; /** * Test case for {@link Wallet}. + * * @since 0.1 - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle JavadocVariableCheck (500 lines) - * @checkstyle MagicNumberCheck (500 lines) - * @checkstyle ClassDataAbstractionCouplingCheck (3 lines) */ -@SuppressWarnings({"PMD.TooManyMethods", "PMD.UnnecessaryLocalRule"}) -public final class WalletTest { - - @Rule - public final TemporaryFolder folder = new TemporaryFolder(); +@SuppressWarnings("PMD.UnnecessaryLocalRule") +final class WalletTest { @Test - public void readsWalletId() throws IOException { + void readsWalletId() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); MatcherAssert.assertThat(wallet.id(), Matchers.is(id)); } @Test - public void throwRuntimeExceptionIfReadingIdFails() throws IOException { + void throwRuntimeExceptionIfReadingIdFails() throws IOException { Assertions.assertThrows( RuntimeException.class, () -> new Wallet.File(this.wallet("")).id() @@ -49,7 +42,7 @@ public void throwRuntimeExceptionIfReadingIdFails() throws IOException { } @Test - public void throwNumberFormatExceptionIfIdIsInvalid() throws IOException { + void throwNumberFormatExceptionIfIdIsInvalid() throws IOException { MatcherAssert.assertThat( Assertions.assertThrows( NumberFormatException.class, @@ -60,8 +53,8 @@ public void throwNumberFormatExceptionIfIdIsInvalid() throws IOException { } @Test - public void pay() throws IOException { - final Path path = this.folder.newFile().toPath(); + void pay(@TempDir final Path folder) throws IOException { + final Path path = Files.createTempFile(folder, "wlt", ".tmp"); path.toFile().delete(); Files.copy(this.wallet(5_124_095_577_148_911L), path); final Wallet wallet = new Wallet.File(path); @@ -80,7 +73,7 @@ public void pay() throws IOException { } @Test - public void doesNotMergePositiveTransactionWithoutPayingWallet() + void doesNotMergePositiveTransactionWithoutPayingWallet() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); @@ -98,7 +91,7 @@ public void doesNotMergePositiveTransactionWithoutPayingWallet() } @Test - public void doesNotMergeWalletsWithDifferentId() throws IOException { + void doesNotMergeWalletsWithDifferentId() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); MatcherAssert.assertThat( @@ -113,7 +106,7 @@ public void doesNotMergeWalletsWithDifferentId() throws IOException { } @Test - public void doesNotMergeExistingTransactions() throws IOException { + void doesNotMergeExistingTransactions() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); final Wallet merged = wallet.merge( @@ -130,7 +123,7 @@ public void doesNotMergeExistingTransactions() throws IOException { } @Test - public void doesNotMergeTransactionsWithSameIdAndBnf() throws IOException { + void doesNotMergeTransactionsWithSameIdAndBnf() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); final Wallet merged = wallet.merge( @@ -147,7 +140,7 @@ public void doesNotMergeTransactionsWithSameIdAndBnf() throws IOException { } @Test - public void doesNotMergeTransactionsWithSameIdAndNegativeAmount() + void doesNotMergeTransactionsWithSameIdAndNegativeAmount() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); @@ -165,7 +158,7 @@ public void doesNotMergeTransactionsWithSameIdAndNegativeAmount() } @Test - public void doesNotMergeTransactionsWithSamePrefix() throws IOException { + void doesNotMergeTransactionsWithSamePrefix() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); final Wallet merged = wallet.merge( @@ -182,7 +175,7 @@ public void doesNotMergeTransactionsWithSamePrefix() throws IOException { } @Test - public void doesNotMergeInvalidTransactions() throws IOException { + void doesNotMergeInvalidTransactions() throws IOException { final long id = 5_124_095_577_148_911L; final Wallet wallet = new Wallet.File(this.wallet(id)); final int size = new ListOf<>(wallet.ledger()).size(); @@ -207,7 +200,7 @@ public void doesNotMergeInvalidTransactions() throws IOException { } @Test - public void walletShouldBeAbleToReturnLedger() throws Exception { + void walletShouldBeAbleToReturnLedger() throws Exception { MatcherAssert.assertThat( new Wallet.File(this.wallet(5_124_095_577_148_911L)).ledger(), Matchers.iterableWithSize(2) @@ -215,11 +208,10 @@ public void walletShouldBeAbleToReturnLedger() throws Exception { } @Test - public void readsPublicKey() throws IOException { + void readsPublicKey() throws IOException { MatcherAssert.assertThat( new Wallet.File(this.wallet(5_124_095_577_148_911L)).key(), Matchers.is( - // @checkstyle LineLengthCheck (1 line) "MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgGZCr/9hBChqsChd4sRAIpKNRinjhSW+J+S7PU5malVMiRHVoKjeooLDpWpij0A6vkzOvjrMldAZT0Fzgp0cJ15TOVwiQanQ5WuQDgRkLoxrdh/qyBApoDvk4OUEozOQPNwfpZOFfaUALPsPnv9995TlY9WcdSKW5dj041p1tJmlAgMBAAE=" ) ); diff --git a/src/test/java/io/zold/api/WalletsInTest.java b/src/test/java/io/zold/api/WalletsInTest.java index 9888a9e..1489539 100644 --- a/src/test/java/io/zold/api/WalletsInTest.java +++ b/src/test/java/io/zold/api/WalletsInTest.java @@ -14,35 +14,28 @@ import org.hamcrest.Matchers; import org.hamcrest.collection.IsIterableWithSize; import org.hamcrest.core.IsEqual; -import org.junit.Rule; -import org.junit.Test; import org.junit.jupiter.api.Assertions; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** * Test case for {@link WalletsIn}. + * * @since 0.1 - * @checkstyle JavadocMethodCheck (500 lines) - * @checkstyle JavadocVariableCheck (500 lines) */ -@SuppressWarnings("PMD.UnnecessaryLocalRule") -public final class WalletsInTest { - - @Rule - public final TemporaryFolder folder = new TemporaryFolder(); +final class WalletsInTest { @Test - public void iteratesWallets() { + void iteratesWallets() { MatcherAssert.assertThat( new WalletsIn(Paths.get("src/test/resources/walletsIn")), - // @checkstyle MagicNumber (1 line) new IsIterableWithSize<>(new IsEqual<>(5)) ); } @Test - public void createsWalletInWallets() throws IOException { - final Wallets wallets = new WalletsIn(this.folder.newFolder().toPath()); + void createsWalletInWallets(@TempDir final Path folder) throws IOException { + final Wallets wallets = new WalletsIn(Files.createTempDirectory(folder, "wlt")); wallets.create(); MatcherAssert.assertThat( "Can't create wallet in wallets", @@ -52,8 +45,8 @@ public void createsWalletInWallets() throws IOException { } @Test - public void createsWalletInFolder() throws IOException { - final Path path = this.folder.newFolder().toPath(); + void createsWalletInFolder(@TempDir final Path folder) throws IOException { + final Path path = Files.createTempDirectory(folder, "wlt"); new WalletsIn(path).create(); MatcherAssert.assertThat( "Can't create wallet in folder", @@ -64,8 +57,8 @@ public void createsWalletInFolder() throws IOException { @Test @SuppressWarnings("PMD.UnitTestContainsTooManyAsserts") - public void createsRightWallet() throws IOException { - final Path path = this.folder.newFolder().toPath(); + void createsRightWallet(@TempDir final Path folder) throws IOException { + final Path path = Files.createTempDirectory(folder, "wlt"); final Wallet wallet = new WalletsIn(path).create( 1L, "AAAAB3NzaC1yc2EAAAADAQABAAABAQC", "zold" ); @@ -81,8 +74,8 @@ public void createsRightWallet() throws IOException { } @Test - public void doesNotOverwriteExistingWallet() throws Exception { - final Path path = this.folder.newFolder().toPath(); + void doesNotOverwriteExistingWallet(@TempDir final Path folder) throws Exception { + final Path path = Files.createTempDirectory(folder, "wlt"); final Random random = new WalletsInTest.FkRandom(16_725L); new WalletsIn(path, random).create(); MatcherAssert.assertThat( @@ -96,6 +89,7 @@ public void doesNotOverwriteExistingWallet() throws Exception { /** * Fake randomizer that returns the same value each time. + * * @since 1.0 */ private static final class FkRandom extends Random { @@ -112,6 +106,7 @@ private static final class FkRandom extends Random { /** * Ctor. + * * @param val Value that represents a random number */ FkRandom(final long val) { diff --git a/src/test/java/io/zold/api/package-info.java b/src/test/java/io/zold/api/package-info.java index 1ba2a41..ada927f 100644 --- a/src/test/java/io/zold/api/package-info.java +++ b/src/test/java/io/zold/api/package-info.java @@ -5,6 +5,7 @@ /** * Java API, tests. + * * @since 0.1 */ package io.zold.api; From 54191c35c9da2d15226d8bd0b8a0e9c798b60dcd Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Wed, 11 Nov 2026 08:38:26 +0300 Subject: [PATCH 2/2] chore: restore renovate config and fix file ending --- src/main/java/io/zold/api/Copy.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/io/zold/api/Copy.java b/src/main/java/io/zold/api/Copy.java index 78bdd07..3567b00 100644 --- a/src/main/java/io/zold/api/Copy.java +++ b/src/main/java/io/zold/api/Copy.java @@ -91,4 +91,3 @@ Score score() { return new Score.Summed(new Mapped<>(Remote::score, this.remotes)); } } -