}
protected ORID addTestAsset(ODatabaseDocumentTx db, ORID componentDocumentRid, EntityId componentId, int n) {
// create the blob
String assetId = "asset" + n;
Blob blob = blobStore.create(toStream(testContent(n)), ImmutableMap.of(
BlobStore.BLOB_NAME_HEADER, assetId,
BlobStore.CREATED_BY_HEADER, "Test"));
// create the asset document
ODocument assetDocument = db.newInstance("testasset");
assetDocument.field(P_ID, assetId);
assetDocument.field(P_COMPONENT, componentDocumentRid);
assetDocument.field(P_DOWNLOAD_COUNT, n);
assetDocument.field(P_FIRST_CREATED, blob.getMetrics().getCreationTime().toDate());
assetDocument.field(P_CONTENT_TYPE, "text/plain");
if (n % 2 == 1) {
assetDocument.field(P_PATH, "" + n); // for variance, only set path if n is odd
}
Map<String, String> blobRefs = ImmutableMap.of("someBlobStoreId", blob.getId().asUniqueString());
assetDocument.field(P_BLOB_REFS, blobRefs);
assetDocument.save();
// return the id of the saved asset document
return assetDocument.getIdentity();