corda / net.corda.testing.services / MockAttachmentStorage

MockAttachmentStorage

class MockAttachmentStorage : AttachmentStorage, SingletonSerializeAsToken

A mock implementation of AttachmentStorage for use within tests

Constructors

<init>

MockAttachmentStorage()

A mock implementation of AttachmentStorage for use within tests

Properties

files

val files: Map<SecureHash, Pair<Attachment, ByteArray>>

A map of the currently stored files by their SecureHash

Functions

getAttachmentIdAndBytes

fun getAttachmentIdAndBytes(jar: InputStream): Pair<AttachmentId, ByteArray>

hasAttachment

fun hasAttachment(attachmentId: AttachmentId): Boolean

Searches for an attachment already in the store

importAttachment

fun importAttachment(jar: InputStream): AttachmentId

Inserts the given attachment into the store, does not close the input stream. This can be an intensive operation due to the need to copy the bytes to disk and hash them along the way.

fun importAttachment(jar: InputStream, uploader: String, filename: String?): AttachmentId

Inserts the given attachment with additional metadata, see importAttachment for input stream handling Extra parameters:

importContractAttachment

fun importContractAttachment(contractClassNames: List<ContractClassName>, uploader: String, jar: InputStream): AttachmentId

importOrGetAttachment

fun importOrGetAttachment(jar: InputStream): AttachmentId

Inserts or returns Attachment Id of attachment. Does not throw an exception if already uploaded.

openAttachment

fun openAttachment(id: SecureHash): Attachment?

Returns a handle to a locally stored attachment, or null if it's not known. The handle can be used to open a stream for the data, which will be a zip/jar file.

queryAttachments

fun queryAttachments(criteria: AttachmentQueryCriteria, sorting: AttachmentSort?): List<AttachmentId>

Searches attachment using given criteria and optional sort rules

Inherited Functions

toToken

open fun toToken(context: SerializeAsTokenContext): SingletonSerializationToken

Extension Functions

contextLogger

fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.