com.r3corda.core.testing / JavaTestHelpers

# JavaTestHelpers

`object JavaTestHelpers`

JAVA INTEROP. Please keep the following points in mind when extending the Kotlin DSL

- Annotate functions with Kotlin defaults with @JvmOverloads. This produces the relevant overloads for Java.

- Void closures in arguments are inconvenient in Java, use overloading to define non-closure variants as well.

- Top-level funs should be defined in a JavaTestHelpers object and annotated with @JvmStatic first and should be referred to from the global fun. This allows static importing of JavaTestHelpers in Java tests, which mimicks top-level funs.

- Top-level vals are trickier. DO NOT USE@JvmField INSIDEJavaTestHelpers. Its surprisingly easy to introduce a static init cycle because of the way Kotlin compiles top-level things, which can cause non-deterministic behaviour, including your field not being initialized at all Instead opt for a proper Kotlin val either with a custom @JvmStatic get() or a lazy delegate if the initialiser has side-effects See examples below.

- Infix functions work as regular ones from Java, but symbols with spaces in them dont Define a camelCase variant as well.

- varargs are exposed as array types in Java. Define overloads for common cases.

- The Int.DOLLARS syntax doesnt work from Java. To remedy add a @JvmStatic DOLLARS(Int) function to JavaTestHelpers

### Properties

ALICE | `val ALICE: Party`
ALICE_KEY | `val ALICE_KEY: KeyPair`
ALICE_PUBKEY | `val ALICE_PUBKEY: PublicKey`
ALL_TEST_KEYS | `val ALL_TEST_KEYS: List<KeyPair>`
BOB | `val BOB: Party`
BOB_KEY | `val BOB_KEY: KeyPair`
BOB_PUBKEY | `val BOB_PUBKEY: PublicKey`
DUMMY_NOTARY | `val DUMMY_NOTARY: Party`
DUMMY_NOTARY_KEY | `val DUMMY_NOTARY_KEY: KeyPair`
DUMMY_PUBKEY_1 | `val DUMMY_PUBKEY_1: PublicKey`
DUMMY_PUBKEY_2 | `val DUMMY_PUBKEY_2: PublicKey`
MEGA_CORP | `val MEGA_CORP: Party`
MEGA_CORP_KEY | `val MEGA_CORP_KEY: KeyPair`
MEGA_CORP_PUBKEY | `val MEGA_CORP_PUBKEY: PublicKey`
MINI_CORP | `val MINI_CORP: Party`
MINI_CORP_KEY | `val MINI_CORP_KEY: KeyPair`
MINI_CORP_PUBKEY | `val MINI_CORP_PUBKEY: PublicKey`
MOCK_IDENTITY_SERVICE | `val MOCK_IDENTITY_SERVICE: MockIdentityService`
ORACLE_KEY | `val ORACLE_KEY: KeyPair`
ORACLE_PUBKEY | `val ORACLE_PUBKEY: PublicKey`
TEST_TX_TIME | `val TEST_TX_TIME: Instant`

### Functions

generateStateRef | `fun generateStateRef(): StateRef`
transaction | `fun transaction(body: TransactionForTest.() -> LastLineShouldTestForAcceptOrFailure): LastLineShouldTestForAcceptOrFailure`