diff --git a/core/src/test/java/bisq/core/dao/burningman/BurningManServiceTest.java b/core/src/test/java/bisq/core/dao/burningman/BurningManServiceTest.java index 840ff9d37b..97f3fb03d0 100644 --- a/core/src/test/java/bisq/core/dao/burningman/BurningManServiceTest.java +++ b/core/src/test/java/bisq/core/dao/burningman/BurningManServiceTest.java @@ -52,13 +52,13 @@ import java.util.stream.IntStream; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.MockitoSession; +import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.Answer; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -91,8 +91,8 @@ public class BurningManServiceTest { } @Nested + @ExtendWith(MockitoExtension.class) public class BurnShareTest { - private MockitoSession mockitoSession; @Mock private DaoStateService daoStateService; @Mock @@ -104,18 +104,12 @@ public class BurningManServiceTest { @BeforeEach public void setUp() { - mockitoSession = Mockito.mockitoSession().initMocks(this).startMocking(); when(cyclesInDaoStateService.getChainHeightOfPastCycle(800000, BurningManService.NUM_CYCLES_BURN_AMOUNT_DECAY)) .thenReturn(750000); when(cyclesInDaoStateService.getChainHeightOfPastCycle(800000, BurningManService.NUM_CYCLES_COMP_REQUEST_DECAY)) .thenReturn(700000); } - @AfterEach - public void tearDown() { - mockitoSession.finishMocking(); - } - private void addProofOfBurnTxs(Tx... txs) { var txsById = Arrays.stream(txs) .collect(Collectors.toMap(Tx::getId, tx -> tx)); diff --git a/core/src/test/java/bisq/core/dao/governance/proposal/ProposalServiceP2PDataStorageListenerTest.java b/core/src/test/java/bisq/core/dao/governance/proposal/ProposalServiceP2PDataStorageListenerTest.java index e459d6b1fa..476819fedc 100644 --- a/core/src/test/java/bisq/core/dao/governance/proposal/ProposalServiceP2PDataStorageListenerTest.java +++ b/core/src/test/java/bisq/core/dao/governance/proposal/ProposalServiceP2PDataStorageListenerTest.java @@ -36,23 +36,22 @@ import java.util.Arrays; import java.util.Collections; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoSession; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.mockito.Mockito.*; - /** * Tests of the P2PDataStorage::onRemoved callback behavior to ensure that the proper number of signal events occur. */ +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) // the two stubs in setUp() are not used in every test public class ProposalServiceP2PDataStorageListenerTest { - private MockitoSession mockitoSession; - private ProposalService proposalService; @Mock private PeriodService periodService; @@ -63,11 +62,6 @@ public class ProposalServiceP2PDataStorageListenerTest { @BeforeEach public void setUp() { - mockitoSession = Mockito.mockitoSession() - .initMocks(this) - .strictness(Strictness.LENIENT) // the two stubs below are not used in every test - .startMocking(); - this.proposalService = new ProposalService( mock(P2PService.class), this.periodService, @@ -83,11 +77,6 @@ public class ProposalServiceP2PDataStorageListenerTest { when(this.daoStateService.isParseBlockChainComplete()).thenReturn(false); } - @AfterEach - public void tearDown() { - mockitoSession.finishMocking(); - } - private static ProtectedStorageEntry buildProtectedStorageEntry() { ProtectedStorageEntry protectedStorageEntry = mock(ProtectedStorageEntry.class); TempProposalPayload tempProposalPayload = mock(TempProposalPayload.class); diff --git a/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageBuildGetDataResponseTest.java b/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageBuildGetDataResponseTest.java index 1df313a4ea..c50d363cfd 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageBuildGetDataResponseTest.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageBuildGetDataResponseTest.java @@ -45,13 +45,13 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoSession; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -62,8 +62,9 @@ import static org.mockito.Mockito.when; import static org.mockito.Mockito.withSettings; public class P2PDataStorageBuildGetDataResponseTest { + @ExtendWith(MockitoExtension.class) + @MockitoSettings(strictness = Strictness.LENIENT) // there are unused stubs in TestState & elsewhere abstract static class P2PDataStorageBuildGetDataResponseTestBase { - private MockitoSession mockitoSession; // GIVEN null & non-null supportedCapabilities private TestState testState; @@ -76,10 +77,6 @@ public class P2PDataStorageBuildGetDataResponseTest { @BeforeEach public void setUp() { - mockitoSession = Mockito.mockitoSession() - .initMocks(this) - .strictness(Strictness.LENIENT) // there are unused stubs in TestState & elsewhere - .startMocking(); this.testState = new TestState(); this.localNodeAddress = new NodeAddress("localhost", 8080); @@ -89,11 +86,6 @@ public class P2PDataStorageBuildGetDataResponseTest { Capabilities.app.addAll(Capability.MEDIATION); } - @AfterEach - public void tearDown() { - mockitoSession.finishMocking(); - } - static class RequiredCapabilitiesPNPStub extends PersistableNetworkPayloadStub implements CapabilityRequiringPayload { Capabilities capabilities;