mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
[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:
parent
c652528ca1
commit
eb2f8f315e
6 changed files with 37 additions and 2 deletions
|
@ -24,6 +24,12 @@ import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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 {
|
public class AppendOnlyDataStoreServiceFake extends AppendOnlyDataStoreService {
|
||||||
private final Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map;
|
private final Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,11 @@ import java.time.Clock;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
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 {
|
public class ClockFake extends Clock {
|
||||||
private Instant currentInstant;
|
private Instant currentInstant;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,13 @@ import bisq.network.p2p.storage.payload.DateTolerantPayload;
|
||||||
|
|
||||||
import java.time.Clock;
|
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 {
|
public class DateTolerantPayloadStub implements DateTolerantPayload {
|
||||||
private final boolean dateInTolerance;
|
private final boolean dateInTolerance;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,13 @@ package bisq.network.p2p.storage.mocks;
|
||||||
|
|
||||||
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
|
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 {
|
public class PersistableNetworkPayloadStub implements PersistableNetworkPayload {
|
||||||
private final boolean hashSizeValid;
|
private final boolean hashSizeValid;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,12 @@ import bisq.network.p2p.storage.persistence.ProtectedDataStoreService;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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 {
|
public class ProtectedDataStoreServiceFake extends ProtectedDataStoreService {
|
||||||
private final Map<P2PDataStorage.ByteArray, ProtectedStorageEntry> map;
|
private final Map<P2PDataStorage.ByteArray, ProtectedStorageEntry> map;
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,12 @@ import javax.annotation.Nullable;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
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 {
|
public class ProtectedStoragePayloadStub implements ProtectedStoragePayload {
|
||||||
@Getter
|
@Getter
|
||||||
|
|
Loading…
Add table
Reference in a new issue