@Test public void testTransferThread() throws Exception { byte[] data = "test-date".getBytes(); Digest globalDigest = new Digest(DigestType.SHA512); globalDigest.update(data); InputStream is = mock(InputStream.class); Driver driver = mock(Driver.class); StorageOffer storageOffer = mock(StorageOffer.class); Connection connection = mock(Connection.class); doReturn(OFFER_ID).when(storageOffer).getId(); doReturn(connection).when(driver).connect(OFFER_ID); StoragePutResult result = new StoragePutResult(2, DataCategory.UNIT.getFolder(), "ob1", "ob1", globalDigest.digestHex(), data.length); doReturn(result).when(connection).putObject(any(StoragePutRequest.class)); OfferReference offerReference = new OfferReference(OFFER_ID); StorageOfferProvider offerProvider = mock(StorageOfferProvider.class); doReturn(storageOffer).when(offerProvider).getStorageOffer(OFFER_ID); StoragePutRequest storagePutRequest = new StoragePutRequest( 2, DataCategory.UNIT.getFolder(), "ob1", DigestType.SHA512.getName(), is); TransferThread transferThread = new TransferThread(driver, offerReference, storagePutRequest, globalDigest, data.length, offerProvider); ThreadResponseData call = transferThread.call(); assertThat(call.getStatus()).isEqualTo(Response.Status.CREATED); assertThat(call.getObjectGuid()).isEqualTo("ob1"); assertThat(call.getResponse().getGuid()).isEqualTo("ob1"); verify(connection).close(); verify(is).close(); }
public TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest, long size) { this(driver, offerReference, request, globalDigest, size, OFFER_PROVIDER); }
TransferThread implements Callable<ThreadResponseData> { public TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest, long size) { this(driver, offerReference, request, globalDigest, size, OFFER_PROVIDER); } }
TransferThread implements Callable<ThreadResponseData> { public TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest, long size) { this(driver, offerReference, request, globalDigest, size, OFFER_PROVIDER); } TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest,
        long size); @VisibleForTesting  TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest,
        long size, StorageOfferProvider offerProvider); }
TransferThread implements Callable<ThreadResponseData> { public TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest, long size) { this(driver, offerReference, request, globalDigest, size, OFFER_PROVIDER); } TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest,
        long size); @VisibleForTesting  TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest,
        long size, StorageOfferProvider offerProvider); static void setJunitMode(boolean mode); @Override ThreadResponseData call(); }
TransferThread implements Callable<ThreadResponseData> { public TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest, long size) { this(driver, offerReference, request, globalDigest, size, OFFER_PROVIDER); } TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest,
        long size); @VisibleForTesting  TransferThread(Driver driver, OfferReference offerReference, StoragePutRequest request, Digest globalDigest,
        long size, StorageOfferProvider offerProvider); static void setJunitMode(boolean mode); @Override ThreadResponseData call(); static final String TIMEOUT_TEST; }