Skip to content

Commit

Permalink
Apply changes to test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
chimp1984 committed Oct 1, 2020
1 parent 65de106 commit 8ea6da0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -53,11 +56,6 @@
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.withSettings;



import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

public class P2PDataStorageBuildGetDataResponseTest {
abstract static class P2PDataStorageBuildGetDataResponseTestBase {
// GIVEN null & non-null supportedCapabilities
Expand Down Expand Up @@ -240,7 +238,10 @@ public void buildGetDataResponse_unknownPNPSendBackTruncation() {
Assert.assertEquals(getDataRequest instanceof GetUpdatedDataRequest, getDataResponse.isGetUpdatedDataResponse());
Assert.assertEquals(getDataResponse.getSupportedCapabilities(), Capabilities.app);
Assert.assertEquals(1, getDataResponse.getPersistableNetworkPayloadSet().size());
Assert.assertTrue(getDataResponse.getPersistableNetworkPayloadSet().contains(onlyLocal1));
Set<PersistableNetworkPayload> persistableNetworkPayloadSet = getDataResponse.getPersistableNetworkPayloadSet();

// We use a set at the filter so it is not deterministic which item get truncated
Assert.assertEquals(1, persistableNetworkPayloadSet.size());
Assert.assertTrue(getDataResponse.getDataSet().isEmpty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@

import java.util.Set;

import org.mockito.MockitoAnnotations;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import org.mockito.MockitoAnnotations;

import static org.mockito.Mockito.*;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class P2PDataStorageRequestDataTest {
private TestState testState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService;

import java.util.HashMap;
import java.util.Map;

/**
Expand All @@ -31,17 +30,16 @@
* @see <a href="https://martinfowler.com/articles/mocksArentStubs.html#TheDifferenceBetweenMocksAndStubs">Reference</a>
*/
public class AppendOnlyDataStoreServiceFake extends AppendOnlyDataStoreService {
private final Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map;

public AppendOnlyDataStoreServiceFake() {
map = new HashMap<>();
addService(new MapStoreServiceFake());
}

public Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> getMap() {
return map;
return super.getMap();
}

public void put(P2PDataStorage.ByteArray hashAsByteArray, PersistableNetworkPayload payload) {
map.put(hashAsByteArray, payload);
super.put(hashAsByteArray, payload);
}
}

0 comments on commit 8ea6da0

Please sign in to comment.