WIP remove powermock

This commit is contained in:
Christoph Sturm 2019-08-13 17:47:53 +02:00
parent 3cfe510ba3
commit 9a587609dd
17 changed files with 9 additions and 100 deletions

View File

@ -40,7 +40,7 @@ configure(subprojects) {
bitcoinjVersion = 'a88d36d'
logbackVersion = '1.1.10'
lombokVersion = '1.18.2'
mockitoVersion = '2.21.0'
mockitoVersion = '3.0.0'
powermockVersion = '2.0.0-beta.5'
protobufVersion = '3.5.1'
slf4jVersion = '1.7.22'
@ -251,7 +251,6 @@ configure(project(':core')) {
testCompile "org.jmockit:jmockit:$jmockitVersion"
testCompile("org.mockito:mockito-core:$mockitoVersion") {
exclude(module: 'objenesis')
}
testCompile "org.powermock:powermock-module-junit4:$powermockVersion"
testCompile "org.powermock:powermock-api-mockito2:$powermockVersion"

View File

@ -32,7 +32,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
@Slf4j
public final class PeriodService {
public class PeriodService {
private final DaoStateService daoStateService;

View File

@ -51,7 +51,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
@EqualsAndHashCode
@Getter
@Slf4j
public final class OfferPayload implements ProtectedStoragePayload, ExpirablePayload, RequiresOwnerIsOnlinePayload {
public class OfferPayload implements ProtectedStoragePayload, ExpirablePayload, RequiresOwnerIsOnlinePayload {
///////////////////////////////////////////////////////////////////////////////////////////
// Enum

View File

@ -76,7 +76,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j
@Singleton
public final class Preferences implements PersistedDataHost, BridgeAddressProvider {
public class Preferences implements PersistedDataHost, BridgeAddressProvider {
private static final ArrayList<BlockChainExplorer> BTC_MAIN_NET_EXPLORERS = new ArrayList<>(Arrays.asList(
new BlockChainExplorer("Blockstream.info", "https://blockstream.info/tx/", "https://blockstream.info/address/"),

View File

@ -21,19 +21,9 @@ import bisq.core.user.User;
import bisq.network.p2p.NodeAddress;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.security.Security;
import java.util.ArrayList;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
@ -42,9 +32,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@RunWith(PowerMockRunner.class)
@PrepareForTest({User.class, ArbitratorService.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class ArbitratorManagerTest {

View File

@ -22,12 +22,7 @@ import bisq.core.user.Preferences;
import java.util.List;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static bisq.core.btc.nodes.BtcNodes.BitcoinNodesOption.CUSTOM;
import static bisq.core.btc.nodes.BtcNodes.BitcoinNodesOption.PUBLIC;
@ -36,9 +31,6 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest(Preferences.class)
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class BtcNodesSetupPreferencesTest {
@Test
public void testSelectPreferredNodesWhenPublicOption() {

View File

@ -11,11 +11,7 @@ import bisq.common.storage.Storage;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
@ -23,8 +19,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({PeriodService.class, ProposalPayload.class, ProposalValidatorProvider.class})
public class BallotListServiceTest {
@Test
@SuppressWarnings("unchecked")

View File

@ -20,22 +20,14 @@ package bisq.core.dao.state;
import bisq.core.dao.governance.period.CycleService;
import bisq.core.dao.monitoring.DaoStateMonitoringService;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.powermock.api.mockito.PowerMockito.mock;
@RunWith(PowerMockRunner.class)
@PrepareForTest({DaoStateService.class, GenesisTxInfo.class, CycleService.class, DaoStateStorageService.class, DaoStateMonitoringService.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class DaoStateSnapshotServiceTest {
private DaoStateSnapshotService daoStateSnapshotService;

View File

@ -17,21 +17,13 @@
package bisq.core.offer;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest(OfferPayload.class)
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class OfferTest {
@Test

View File

@ -9,12 +9,7 @@ import bisq.common.storage.Storage;
import java.util.concurrent.atomic.AtomicBoolean;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static bisq.core.offer.OfferMaker.btcUsdOffer;
import static com.natpryce.makeiteasy.MakeItEasy.make;
@ -22,9 +17,6 @@ import static junit.framework.TestCase.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
@RunWith(PowerMockRunner.class)
@PrepareForTest({P2PService.class, PeerManager.class, OfferBookService.class, Storage.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class OpenOfferManagerTest {
@Test

View File

@ -28,12 +28,7 @@ import java.util.Collections;
import java.util.Set;
import java.util.function.BiFunction;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@ -42,9 +37,6 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({PaymentAccount.class, AccountAgeWitness.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class PaymentAccountsTest {
@Test
public void testGetOldestPaymentAccountForOfferWhenNoValidAccounts() {

View File

@ -23,21 +23,13 @@ import bisq.core.payment.payload.PaymentMethod;
import com.google.common.collect.Lists;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({NationalBankAccount.class, SepaAccount.class, SepaInstantAccount.class, PaymentMethod.class, SameBankAccount.class, SpecificBanksAccount.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class ReceiptPredicatesTest {
private final ReceiptPredicates predicates = new ReceiptPredicates();

View File

@ -20,13 +20,8 @@ package bisq.core.payment;
import bisq.core.offer.Offer;
import bisq.core.payment.payload.PaymentMethod;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -34,10 +29,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({SpecificBanksAccount.class, SameBankAccount.class, NationalBankAccount.class,
MoneyGramAccount.class, WesternUnionAccount.class, CashDepositAccount.class, PaymentMethod.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class ReceiptValidatorTest {
private ReceiptValidator validator;
private PaymentAccount account;

View File

@ -20,17 +20,11 @@ package bisq.core.payment;
import bisq.core.dao.governance.period.PeriodService;
import bisq.core.dao.state.DaoStateService;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
@RunWith(PowerMockRunner.class)
@PrepareForTest({DaoStateService.class, PeriodService.class})
public class TradeLimitsTest {
@Test
public void testGetFirstMonthRiskBasedTradeLimit() {

View File

@ -23,20 +23,19 @@ import bisq.core.offer.OpenOffer;
import bisq.common.storage.Storage;
import mockit.Mocked;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static protobuf.PersistableEnvelope.MessageCase.TRADABLE_LIST;
//TODO cannot be run in IntelliJ IDE as parameter is not supported. OfferPayload is final so it is not so trivial to
// replace that.
public class TradableListTest {
@Test
public void protoTesting(@Mocked OfferPayload offerPayload) {
public void protoTesting() {
OfferPayload offerPayload = mock(OfferPayload.class, RETURNS_DEEP_STUBS);
Storage<TradableList<OpenOffer>> storage = new Storage<>(null, null);
TradableList<OpenOffer> openOfferTradableList = new TradableList<>(storage, "filename");
protobuf.PersistableEnvelope message = (protobuf.PersistableEnvelope) openOfferTradableList.toProtoMessage();

View File

@ -34,13 +34,8 @@ import java.util.Currency;
import java.util.List;
import java.util.Locale;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -49,9 +44,6 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({Storage.class, PreferencesPayload.class, BisqEnvironment.class})
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"})
public class PreferencesTest {
private Preferences preferences;

View File

@ -0,0 +1 @@
mock-maker-inline