Skip to content

Commit

Permalink
STORAGE-2798 Updated B2StorageClientWebifierImpl methods to improve e…
Browse files Browse the repository at this point in the history
…xtensibility
  • Loading branch information
jsha-bbz committed Dec 4, 2024
1 parent c197e20 commit 64be757
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public void downloadById(B2AccountAuthorization accountAuth,
B2DownloadByIdRequest request,
B2ContentSink handler) throws B2Exception {
downloadGuts(accountAuth,
makeDownloadByIdUrl(accountAuth, request),
getDownloadByIdUrl(accountAuth, request),
request.getRange(),
request.getServerSideEncryption(),
handler);
Expand All @@ -505,7 +505,7 @@ public void downloadByName(B2AccountAuthorization accountAuth,
B2DownloadByNameRequest request,
B2ContentSink handler) throws B2Exception {
downloadGuts(accountAuth,
makeDownloadByNameUrl(accountAuth, request.getBucketName(), request.getFileName(), request),
getDownloadByNameUrl(accountAuth, request),
request.getRange(),
request.getServerSideEncryption(),
handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

Expand Down Expand Up @@ -1190,7 +1191,9 @@ public void testDownloadById() throws B2Exception {
final B2DownloadByIdRequest request = B2DownloadByIdRequest
.builder(fileId(1))
.build();
webifier.downloadById(ACCOUNT_AUTH, request, noopContentHandler);
final B2StorageClientWebifierImpl webifierSpy = spy(webifier);
webifierSpy.downloadById(ACCOUNT_AUTH, request, noopContentHandler);
verify(webifierSpy).getDownloadByIdUrl(ACCOUNT_AUTH, request);

webApiClient.check("getContent.\n" +
"url:\n" +
Expand All @@ -1201,7 +1204,7 @@ public void testDownloadById() throws B2Exception {
" X-Bz-Test-Mode: force_cap_exceeded\n"
);

assertEquals(expectedUrl, webifier.getDownloadByIdUrl(ACCOUNT_AUTH, request));
assertEquals(expectedUrl, webifierSpy.getDownloadByIdUrl(ACCOUNT_AUTH, request));

checkRequestCategory(OTHER, w -> w.downloadById(ACCOUNT_AUTH, request, noopContentHandler));
}
Expand Down Expand Up @@ -1303,7 +1306,9 @@ public void testDownloadByName() throws B2Exception {
final B2DownloadByNameRequest request = B2DownloadByNameRequest
.builder(bucketName(1), fileName(1))
.build();
webifier.downloadByName(ACCOUNT_AUTH, request, noopContentHandler);
final B2StorageClientWebifierImpl webifierSpy = spy(webifier);
webifierSpy.downloadByName(ACCOUNT_AUTH, request, noopContentHandler);
verify(webifierSpy).getDownloadByNameUrl(ACCOUNT_AUTH, request);

webApiClient.check("getContent.\n" +
"url:\n" +
Expand All @@ -1313,7 +1318,7 @@ public void testDownloadByName() throws B2Exception {
" User-Agent: SecretAgentMan/3.19.28\n" +
" X-Bz-Test-Mode: force_cap_exceeded\n"
);
assertEquals(expectedUrl, webifier.getDownloadByNameUrl(ACCOUNT_AUTH, request));
assertEquals(expectedUrl, webifierSpy.getDownloadByNameUrl(ACCOUNT_AUTH, request));

checkRequestCategory(OTHER, w -> w.downloadByName(ACCOUNT_AUTH, request, noopContentHandler));
}
Expand Down

0 comments on commit 64be757

Please sign in to comment.