From eb2f8f315e968eb7a68bea88b218f2eddd1feef8 Mon Sep 17 00:00:00 2001 From: Julian Knutsen Date: Sat, 9 Nov 2019 08:58:05 -0800 Subject: [PATCH] [TESTS] Add JavaDocs for test objects Add JavaDocs for the various Stub and Fake objects that are used in the P2PDataStore test so future developers can understand why they exist. --- .../p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java | 6 ++++++ .../java/bisq/network/p2p/storage/mocks/ClockFake.java | 5 +++++ .../p2p/storage/mocks/DateTolerantPayloadStub.java | 7 +++++++ .../p2p/storage/mocks/PersistableNetworkPayloadStub.java | 7 +++++++ .../p2p/storage/mocks/ProtectedDataStoreServiceFake.java | 6 ++++++ .../p2p/storage/mocks/ProtectedStoragePayloadStub.java | 8 ++++++-- 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java b/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java index e9e38cc014..4119ff1426 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java @@ -24,6 +24,12 @@ import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService; import java.util.HashMap; import java.util.Map; +/** + * Implementation of an in-memory AppendOnlyDataStoreService that can be used in tests. Removes overhead + * involving files, resources, and services for tests that don't need it. + * + * @see Reference + */ public class AppendOnlyDataStoreServiceFake extends AppendOnlyDataStoreService { private final Map map; diff --git a/p2p/src/test/java/bisq/network/p2p/storage/mocks/ClockFake.java b/p2p/src/test/java/bisq/network/p2p/storage/mocks/ClockFake.java index 6e852615c5..6f5e42245a 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/mocks/ClockFake.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/mocks/ClockFake.java @@ -21,6 +21,11 @@ import java.time.Clock; import java.time.Instant; import java.time.ZoneId; +/** + * Fake implementation of the Clock object that can be used in tests that need finer control over the current time. + * + * @see Reference + */ public class ClockFake extends Clock { private Instant currentInstant; diff --git a/p2p/src/test/java/bisq/network/p2p/storage/mocks/DateTolerantPayloadStub.java b/p2p/src/test/java/bisq/network/p2p/storage/mocks/DateTolerantPayloadStub.java index 327237bffc..ce709c2e2b 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/mocks/DateTolerantPayloadStub.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/mocks/DateTolerantPayloadStub.java @@ -21,6 +21,13 @@ import bisq.network.p2p.storage.payload.DateTolerantPayload; import java.time.Clock; +/** + * Stub implementation of a ProtectedStoragePayload implementing the DateTolerantPayload marker interface + * that can be used in tests to provide canned answers to calls. Useful if the tests don't care about the implementation + * details of the ProtectedStoragePayload. + * + * @see Reference + */ public class DateTolerantPayloadStub implements DateTolerantPayload { private final boolean dateInTolerance; diff --git a/p2p/src/test/java/bisq/network/p2p/storage/mocks/PersistableNetworkPayloadStub.java b/p2p/src/test/java/bisq/network/p2p/storage/mocks/PersistableNetworkPayloadStub.java index 1d2a8e1fbe..6ab7315548 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/mocks/PersistableNetworkPayloadStub.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/mocks/PersistableNetworkPayloadStub.java @@ -19,6 +19,13 @@ package bisq.network.p2p.storage.mocks; import bisq.network.p2p.storage.payload.PersistableNetworkPayload; +/** + * Stub implementation of a PersistableNetworkPayload that can be used in tests + * to provide canned answers to calls. Useful if the tests don't care about the implementation + * * details of the PersistableNetworkPayload. + * + * @see Reference + */ public class PersistableNetworkPayloadStub implements PersistableNetworkPayload { private final boolean hashSizeValid; diff --git a/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedDataStoreServiceFake.java b/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedDataStoreServiceFake.java index 0ad22d8846..717a3b806b 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedDataStoreServiceFake.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedDataStoreServiceFake.java @@ -24,6 +24,12 @@ import bisq.network.p2p.storage.persistence.ProtectedDataStoreService; import java.util.HashMap; import java.util.Map; +/** + * Implementation of an in-memory ProtectedDataStoreService that can be used in tests. Removes overhead + * involving files, resources, and services for tests that don't need it. + * + * @see Reference + */ public class ProtectedDataStoreServiceFake extends ProtectedDataStoreService { private final Map map; diff --git a/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedStoragePayloadStub.java b/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedStoragePayloadStub.java index 5a176fca30..017ec538f1 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedStoragePayloadStub.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/mocks/ProtectedStoragePayloadStub.java @@ -34,8 +34,12 @@ import javax.annotation.Nullable; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -/* - * Stub ProtectedStoragePayload whose hash is equal to the ownerPubKey +/** + * Stub implementation of a ProtectedStoragePayload that can be used in tests + * to provide canned answers to calls. Useful if the tests don't care about the implementation + * details of the ProtectedStoragePayload. + * + * @see Reference */ public class ProtectedStoragePayloadStub implements ProtectedStoragePayload { @Getter