[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.
This commit is contained in:
Julian Knutsen 2019-11-09 08:58:05 -08:00
parent c652528ca1
commit eb2f8f315e
No known key found for this signature in database
GPG key ID: D85F536DB3615B2D
6 changed files with 37 additions and 2 deletions

View file

@ -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 <a href="https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs">Reference</a>
*/
public class AppendOnlyDataStoreServiceFake extends AppendOnlyDataStoreService {
private final Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map;

View file

@ -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 <a href="https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs">Reference</a>
*/
public class ClockFake extends Clock {
private Instant currentInstant;

View file

@ -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 <a href="https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs">Reference</a>
*/
public class DateTolerantPayloadStub implements DateTolerantPayload {
private final boolean dateInTolerance;

View file

@ -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 <a href="https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs">Reference</a>
*/
public class PersistableNetworkPayloadStub implements PersistableNetworkPayload {
private final boolean hashSizeValid;

View file

@ -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 <a href="https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs">Reference</a>
*/
public class ProtectedDataStoreServiceFake extends ProtectedDataStoreService {
private final Map<P2PDataStorage.ByteArray, ProtectedStorageEntry> map;

View file

@ -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 <a href="https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs">Reference</a>
*/
public class ProtectedStoragePayloadStub implements ProtectedStoragePayload {
@Getter