RandomSource r = new DummyRandomSource(12123);
LockableRandomAccessBuffer data = generateData(r, size, smallRAFFactory);
Bucket dataBucket = new RAFBucket(data);
HashResult[] hashes = getHashes(data);
MyCallback cb = new MyCallback();
InsertContext context = baseContext.clone();
context.earlyEncode = true;
KeysFetchingLocally keysFetching = new MyKeysFetchingLocally();
SplitFileInserterStorage storage = new SplitFileInserterStorage(data, size, cb, null,
new ClientMetadata(), false, null, smallRAFFactory, false, context,
cryptoAlgorithm, cryptoKey, null, hashes, smallBucketFactory, checker,
r, memoryLimitedJobRunner, jobRunner, ticker, keysFetching, false, 0, 0, 0, 0);
storage.start();
cb.waitForFinishedEncode();
// Encoded. Now try to decode it ...
cb.waitForHasKeys();
Metadata metadata = storage.encodeMetadata();
assertTrue(storage.getStatus() == Status.ENCODED);
// Ugly hack because Metadata behaves oddly.
// FIXME make Metadata behave consistently and get rid.
Bucket metaBucket = metadata.toBucket(smallBucketFactory);
Metadata m1 = Metadata.construct(metaBucket);
Bucket copyBucket = m1.toBucket(smallBucketFactory);
assertTrue(BucketTools.equalBuckets(metaBucket, copyBucket));
MyFetchCallback fcb = new MyFetchCallback();
FetchContext fctx = HighLevelSimpleClientImpl.makeDefaultFetchContext(size*2, size*2, smallBucketFactory, new SimpleEventProducer());
short cmode = (short) context.getCompatibilityMode().ordinal();
SplitFileFetcherStorage fetcherStorage = new SplitFileFetcherStorage(m1, fcb, new ArrayList<COMPRESSOR_TYPE>(),
new ClientMetadata(), false, cmode, fctx, false, salt, URI, URI, true, new byte[0],
r, smallBucketFactory, smallRAFFactory, jobRunner, ticker, memoryLimitedJobRunner,
checker, false, null, null, keysFetching);