mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Make test constants Java-visible fields. (#2258)
This commit is contained in:
parent
409cefd467
commit
21e1118ea0
@ -28,7 +28,7 @@ import static net.corda.finance.Currencies.DOLLARS;
|
||||
import static net.corda.finance.contracts.GetBalances.getCashBalance;
|
||||
import static net.corda.node.services.Permissions.invokeRpc;
|
||||
import static net.corda.node.services.Permissions.startFlow;
|
||||
import static net.corda.testing.TestConstants.getALICE_NAME;
|
||||
import static net.corda.testing.TestConstants.ALICE_NAME;
|
||||
|
||||
public class CordaRPCJavaClientTest extends NodeBasedTest {
|
||||
public CordaRPCJavaClientTest() {
|
||||
@ -56,7 +56,7 @@ public class CordaRPCJavaClientTest extends NodeBasedTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws ExecutionException, InterruptedException {
|
||||
node = startNode(getALICE_NAME(), 1, singletonList(rpcUser));
|
||||
node = startNode(ALICE_NAME, 1, singletonList(rpcUser));
|
||||
client = new CordaRPCClient(requireNonNull(node.getInternals().getConfiguration().getRpcAddress()));
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ public class FlowsInJavaTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
aliceNode = mockNet.createPartyNode(TestConstants.getALICE_NAME());
|
||||
bobNode = mockNet.createPartyNode(TestConstants.getBOB_NAME());
|
||||
aliceNode = mockNet.createPartyNode(TestConstants.ALICE_NAME);
|
||||
bobNode = mockNet.createPartyNode(TestConstants.BOB_NAME);
|
||||
bob = singleIdentity(bobNode.getInfo());
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@ import static net.corda.testing.TestConstants.*;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
||||
public class CommercialPaperTest {
|
||||
private static final TestIdentity ALICE = new TestIdentity(getALICE_NAME(), 70L);
|
||||
private static final TestIdentity ALICE = new TestIdentity(ALICE_NAME, 70L);
|
||||
private static final PublicKey BIG_CORP_PUBKEY = generateKeyPair().getPublic();
|
||||
private static final TestIdentity BOB = new TestIdentity(getBOB_NAME(), 80L);
|
||||
private static final TestIdentity BOB = new TestIdentity(BOB_NAME, 80L);
|
||||
private static final TestIdentity MEGA_CORP = new TestIdentity(new CordaX500Name("MegaCorp", "London", "GB"));
|
||||
private static final Party DUMMY_NOTARY = new TestIdentity(getDUMMY_NOTARY_NAME(), 20L).getParty();
|
||||
private static final Party DUMMY_NOTARY = new TestIdentity(DUMMY_NOTARY_NAME, 20L).getParty();
|
||||
@Rule
|
||||
public final SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
private final byte[] defaultRef = {123};
|
||||
@ -52,7 +52,7 @@ public class CommercialPaperTest {
|
||||
MEGA_CORP.ref(defaultRef),
|
||||
MEGA_CORP.getParty(),
|
||||
issuedBy(DOLLARS(1000), MEGA_CORP.ref(defaultRef)),
|
||||
getTEST_TX_TIME().plus(7, ChronoUnit.DAYS)
|
||||
TEST_TX_TIME.plus(7, ChronoUnit.DAYS)
|
||||
);
|
||||
}
|
||||
// DOCEND 1
|
||||
@ -131,11 +131,11 @@ public class CommercialPaperTest {
|
||||
tx.attachments(JCP_PROGRAM_ID);
|
||||
tx.tweak(tw -> {
|
||||
tw.command(BIG_CORP_PUBKEY, new JavaCommercialPaper.Commands.Issue());
|
||||
tw.timeWindow(getTEST_TX_TIME());
|
||||
tw.timeWindow(TEST_TX_TIME);
|
||||
return tw.failsWith("output states are issued by a command signer");
|
||||
});
|
||||
tx.command(MEGA_CORP.getPublicKey(), new JavaCommercialPaper.Commands.Issue());
|
||||
tx.timeWindow(getTEST_TX_TIME());
|
||||
tx.timeWindow(TEST_TX_TIME);
|
||||
return tx.verifies();
|
||||
});
|
||||
return Unit.INSTANCE;
|
||||
@ -151,11 +151,11 @@ public class CommercialPaperTest {
|
||||
tx.attachments(JCP_PROGRAM_ID);
|
||||
tx.tweak(tw -> {
|
||||
tw.command(BIG_CORP_PUBKEY, new JavaCommercialPaper.Commands.Issue());
|
||||
tw.timeWindow(getTEST_TX_TIME());
|
||||
tw.timeWindow(TEST_TX_TIME);
|
||||
return tw.failsWith("output states are issued by a command signer");
|
||||
});
|
||||
tx.command(MEGA_CORP.getPublicKey(), new JavaCommercialPaper.Commands.Issue());
|
||||
tx.timeWindow(getTEST_TX_TIME());
|
||||
tx.timeWindow(TEST_TX_TIME);
|
||||
return tx.verifies();
|
||||
});
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class CommercialPaperTest {
|
||||
tx.output(JCP_PROGRAM_ID, "paper", getPaper());
|
||||
tx.command(MEGA_CORP.getPublicKey(), new JavaCommercialPaper.Commands.Issue());
|
||||
tx.attachments(JCP_PROGRAM_ID);
|
||||
tx.timeWindow(getTEST_TX_TIME());
|
||||
tx.timeWindow(TEST_TX_TIME);
|
||||
return tx.verifies();
|
||||
});
|
||||
|
||||
@ -214,7 +214,7 @@ public class CommercialPaperTest {
|
||||
tx.output(Cash.PROGRAM_ID, "paper", getPaper());
|
||||
tx.command(MEGA_CORP.getPublicKey(), new JavaCommercialPaper.Commands.Issue());
|
||||
tx.attachments(JCP_PROGRAM_ID);
|
||||
tx.timeWindow(getTEST_TX_TIME());
|
||||
tx.timeWindow(TEST_TX_TIME);
|
||||
return tx.verifies();
|
||||
});
|
||||
|
||||
@ -260,7 +260,7 @@ public class CommercialPaperTest {
|
||||
tx.output(Cash.PROGRAM_ID, "paper", getPaper());
|
||||
tx.command(MEGA_CORP.getPublicKey(), new JavaCommercialPaper.Commands.Issue());
|
||||
tx.attachments(JCP_PROGRAM_ID);
|
||||
tx.timeWindow(getTEST_TX_TIME());
|
||||
tx.timeWindow(TEST_TX_TIME);
|
||||
return tx.verifies();
|
||||
});
|
||||
|
||||
|
@ -16,14 +16,14 @@ import static net.corda.finance.Currencies.DOLLARS;
|
||||
import static net.corda.finance.Currencies.issuedBy;
|
||||
import static net.corda.testing.node.NodeTestUtils.transaction;
|
||||
import static net.corda.testing.CoreTestUtils.rigorousMock;
|
||||
import static net.corda.testing.TestConstants.getDUMMY_NOTARY_NAME;
|
||||
import static net.corda.testing.TestConstants.DUMMY_NOTARY_NAME;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
||||
/**
|
||||
* This is an incomplete Java replica of CashTests.kt to show how to use the Java test DSL
|
||||
*/
|
||||
public class CashTestsJava {
|
||||
private static final Party DUMMY_NOTARY = new TestIdentity(getDUMMY_NOTARY_NAME(), 20L).getParty();
|
||||
private static final Party DUMMY_NOTARY = new TestIdentity(DUMMY_NOTARY_NAME, 20L).getParty();
|
||||
private static final TestIdentity MEGA_CORP = new TestIdentity(new CordaX500Name("MegaCorp", "London", "GB"));
|
||||
private static final TestIdentity MINI_CORP = new TestIdentity(new CordaX500Name("MiniCorp", "London", "GB"));
|
||||
private final PartyAndReference defaultIssuer = MEGA_CORP.ref((byte) 1);
|
||||
|
@ -46,19 +46,19 @@ import static net.corda.core.node.services.vault.QueryCriteriaUtils.DEFAULT_PAGE
|
||||
import static net.corda.core.node.services.vault.QueryCriteriaUtils.MAX_PAGE_SIZE;
|
||||
import static net.corda.core.utilities.ByteArrays.toHexString;
|
||||
import static net.corda.testing.CoreTestUtils.rigorousMock;
|
||||
import static net.corda.testing.TestConstants.getBOC_NAME;
|
||||
import static net.corda.testing.TestConstants.getCHARLIE_NAME;
|
||||
import static net.corda.testing.TestConstants.getDUMMY_NOTARY_NAME;
|
||||
import static net.corda.testing.TestConstants.BOC_NAME;
|
||||
import static net.corda.testing.TestConstants.CHARLIE_NAME;
|
||||
import static net.corda.testing.TestConstants.DUMMY_NOTARY_NAME;
|
||||
import static net.corda.testing.node.MockServices.makeTestDatabaseAndMockServices;
|
||||
import static net.corda.testing.node.MockServicesKt.makeTestIdentityService;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class VaultQueryJavaTests {
|
||||
private static final TestIdentity BOC = new TestIdentity(getBOC_NAME());
|
||||
private static final Party CHARLIE = new TestIdentity(getCHARLIE_NAME(), 90L).getParty();
|
||||
private static final TestIdentity BOC = new TestIdentity(BOC_NAME);
|
||||
private static final Party CHARLIE = new TestIdentity(CHARLIE_NAME, 90L).getParty();
|
||||
private static final TestIdentity DUMMY_CASH_ISSUER_INFO = new TestIdentity(new CordaX500Name("Snake Oil Issuer", "London", "GB"), 10L);
|
||||
private static final PartyAndReference DUMMY_CASH_ISSUER = DUMMY_CASH_ISSUER_INFO.ref((byte) 1);
|
||||
private static final TestIdentity DUMMY_NOTARY = new TestIdentity(getDUMMY_NOTARY_NAME(), 20L);
|
||||
private static final TestIdentity DUMMY_NOTARY = new TestIdentity(DUMMY_NOTARY_NAME, 20L);
|
||||
private static final TestIdentity MEGA_CORP = new TestIdentity(new CordaX500Name("MegaCorp", "London", "GB"));
|
||||
@Rule
|
||||
public final SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
|
@ -13,14 +13,23 @@ import java.security.PublicKey
|
||||
import java.time.Instant
|
||||
|
||||
// A dummy time at which we will be pretending test transactions are created.
|
||||
val TEST_TX_TIME: Instant get() = Instant.parse("2015-04-17T12:00:00.00Z")
|
||||
@JvmField
|
||||
val TEST_TX_TIME = Instant.parse("2015-04-17T12:00:00.00Z")
|
||||
@JvmField
|
||||
val DUMMY_NOTARY_NAME = CordaX500Name("Notary Service", "Zurich", "CH")
|
||||
@JvmField
|
||||
val DUMMY_BANK_A_NAME = CordaX500Name("Bank A", "London", "GB")
|
||||
@JvmField
|
||||
val DUMMY_BANK_B_NAME = CordaX500Name("Bank B", "New York", "US")
|
||||
@JvmField
|
||||
val DUMMY_BANK_C_NAME = CordaX500Name("Bank C", "Tokyo", "JP")
|
||||
@JvmField
|
||||
val BOC_NAME = CordaX500Name("BankOfCorda", "London", "GB")
|
||||
@JvmField
|
||||
val ALICE_NAME = CordaX500Name("Alice Corp", "Madrid", "ES")
|
||||
@JvmField
|
||||
val BOB_NAME = CordaX500Name("Bob Plc", "Rome", "IT")
|
||||
@JvmField
|
||||
val CHARLIE_NAME = CordaX500Name("Charlie Ltd", "Athens", "GR")
|
||||
val DEV_CA: CertificateAndKeyPair by lazy {
|
||||
// TODO: Should be identity scheme
|
||||
|
Loading…
Reference in New Issue
Block a user