@@ -45,7 +45,8 @@ import org.junit.ClassRule
45
45
import org.junit.Ignore
46
46
import org.junit.Rule
47
47
import org.junit.Test
48
- import org.junit.rules.ExpectedException
48
+ import org.junit.jupiter.api.Assertions.assertTrue
49
+ import org.junit.jupiter.api.assertThrows
49
50
import org.junit.rules.ExternalResource
50
51
import java.time.Duration
51
52
import java.time.Instant
@@ -148,7 +149,7 @@ open class VaultQueryTestRule(private val persistentServices: Boolean) : Externa
148
149
cordappPackages,
149
150
makeTestIdentityService(MEGA_CORP_IDENTITY , MINI_CORP_IDENTITY , dummyCashIssuer.identity, dummyNotary.identity),
150
151
megaCorp,
151
- moreKeys = * arrayOf(DUMMY_NOTARY_KEY )
152
+ moreKeys = arrayOf(DUMMY_NOTARY_KEY )
152
153
)
153
154
}
154
155
database = databaseAndServices.first
@@ -184,10 +185,6 @@ class VaultQueryRollbackRule(private val vaultQueryParties: VaultQueryParties) :
184
185
185
186
abstract class VaultQueryTestsBase : VaultQueryParties {
186
187
187
- @Rule
188
- @JvmField
189
- val expectedEx: ExpectedException = ExpectedException .none()
190
-
191
188
companion object {
192
189
@ClassRule @JvmField
193
190
val testSerialization = SerializationEnvironmentRule ()
@@ -1006,10 +1003,11 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
1006
1003
assertThat(resultsUnlockedAndByLockIds.states).hasSize(5 )
1007
1004
1008
1005
// missing lockId
1009
- expectedEx.expect(VaultQueryException ::class .java)
1010
- expectedEx.expectMessage(" Must specify one or more lockIds" )
1011
- val criteriaMissingLockId = VaultQueryCriteria (softLockingCondition = SoftLockingCondition (SoftLockingType .UNLOCKED_AND_SPECIFIED ))
1012
- vaultService.queryBy<ContractState >(criteriaMissingLockId)
1006
+ val anException = assertThrows<VaultQueryException > {
1007
+ val criteriaMissingLockId = VaultQueryCriteria (softLockingCondition = SoftLockingCondition (SoftLockingType .UNLOCKED_AND_SPECIFIED ))
1008
+ vaultService.queryBy<ContractState >(criteriaMissingLockId)
1009
+ }
1010
+ anException.message?.let { assertTrue(it.contains(" Must specify one or more lockIds" )) }
1013
1011
}
1014
1012
}
1015
1013
@@ -1707,44 +1705,43 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
1707
1705
// pagination: invalid page number
1708
1706
@Test(timeout= 300_000 )
1709
1707
fun `invalid page number` () {
1710
- expectedEx.expect(VaultQueryException ::class .java)
1711
- expectedEx.expectMessage(" Page specification: invalid page number" )
1712
-
1713
- database.transaction {
1714
- vaultFiller.fillWithSomeTestCash(100 .DOLLARS , notaryServices, 100 , DUMMY_CASH_ISSUER )
1715
- val pagingSpec = PageSpecification (0 , 10 )
1716
-
1717
- val criteria = VaultQueryCriteria (status = Vault .StateStatus .ALL )
1718
- vaultService.queryBy<ContractState >(criteria, paging = pagingSpec)
1708
+ val anException = assertThrows<VaultQueryException > {
1709
+ database.transaction {
1710
+ vaultFiller.fillWithSomeTestCash(100 .DOLLARS , notaryServices, 100 , DUMMY_CASH_ISSUER )
1711
+ val pagingSpec = PageSpecification (0 , 10 )
1712
+ val criteria = VaultQueryCriteria (status = Vault .StateStatus .ALL )
1713
+ vaultService.queryBy<ContractState >(criteria, paging = pagingSpec)
1714
+ }
1719
1715
}
1716
+ anException.message?.let { assertTrue(it.contains(" Page specification: invalid page number" )) }
1720
1717
}
1721
1718
1722
1719
// pagination: invalid page size
1723
1720
@Suppress(" INTEGER_OVERFLOW" )
1724
1721
@Test(timeout= 300_000 )
1725
1722
fun `invalid page size` () {
1726
- expectedEx.expect(VaultQueryException ::class .java)
1727
- expectedEx.expectMessage(" Page specification: invalid page size" )
1728
-
1729
- database.transaction {
1730
- vaultFiller.fillWithSomeTestCash(100 .DOLLARS , notaryServices, 100 , DUMMY_CASH_ISSUER )
1731
- val pagingSpec = PageSpecification (DEFAULT_PAGE_NUM , Integer .MAX_VALUE + 1 ) // overflow = -2147483648
1732
- val criteria = VaultQueryCriteria (status = Vault .StateStatus .ALL )
1733
- vaultService.queryBy<ContractState >(criteria, paging = pagingSpec)
1723
+ val anException = assertThrows<VaultQueryException > {
1724
+ database.transaction {
1725
+ vaultFiller.fillWithSomeTestCash(100 .DOLLARS , notaryServices, 100 , DUMMY_CASH_ISSUER )
1726
+ val pagingSpec = PageSpecification (DEFAULT_PAGE_NUM , Integer .MAX_VALUE + 1 ) // overflow = -2147483648
1727
+ val criteria = VaultQueryCriteria (status = Vault .StateStatus .ALL )
1728
+ vaultService.queryBy<ContractState >(criteria, paging = pagingSpec)
1729
+ }
1734
1730
}
1731
+ anException.message?.let { assertTrue(it.contains(" Page specification: invalid page size" )) }
1735
1732
}
1736
1733
1737
1734
// pagination not specified but more than DEFAULT_PAGE_SIZE results available (fail-fast test)
1738
1735
@Test(timeout= 300_000 )
1739
1736
fun `pagination not specified but more than default results available` () {
1740
- expectedEx.expect(VaultQueryException ::class .java)
1741
- expectedEx.expectMessage(" provide a PageSpecification" )
1742
-
1743
- database.transaction {
1744
- vaultFiller.fillWithSomeTestCash(201 .DOLLARS , notaryServices, 201 , DUMMY_CASH_ISSUER )
1745
- val criteria = VaultQueryCriteria (status = Vault .StateStatus .ALL )
1746
- vaultService.queryBy<ContractState >(criteria)
1737
+ val anException = assertThrows<VaultQueryException > {
1738
+ database.transaction {
1739
+ vaultFiller.fillWithSomeTestCash(201 .DOLLARS , notaryServices, 201 , DUMMY_CASH_ISSUER )
1740
+ val criteria = VaultQueryCriteria (status = Vault .StateStatus .ALL )
1741
+ vaultService.queryBy<ContractState >(criteria)
1742
+ }
1747
1743
}
1744
+ anException.message?.let { assertTrue(it.contains(" provide a PageSpecification" )) }
1748
1745
}
1749
1746
1750
1747
// example of querying states with paging using totalStatesAvailable
0 commit comments