Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some method #571

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/com/qiniu/http/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ private Response patch(String url, RequestBody body, StringMap headers) throws Q
return send(requestBuilder, headers);
}

public Response head(String url, StringMap headers) throws QiniuException {
Request.Builder requestBuilder = new Request.Builder().url(url).head();
return send(requestBuilder, headers);
}

public Response send(final Request.Builder requestBuilder, StringMap headers) throws QiniuException {
if (headers != null) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/qiniu/storage/BucketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,10 @@ private void setExecBucket(String bucket) {
public String execBucket() {
return execBucket;
}

public int size() {
return ops.size();
}
}

/**
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/test/com/qiniu/storage/BucketManagerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package test.com.qiniu.storage;

import com.qiniu.storage.BucketManager;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

public class BucketManagerTest {
@Test
@Tag("UnitTest")
public void testBatchOperationsSize() {
BucketManager.BatchOperations batchOperations = new BucketManager.BatchOperations();
Assertions.assertEquals(0, batchOperations.size());

batchOperations.addDeleteOp("bucket1", "1", "2");
Assertions.assertEquals(2, batchOperations.size());

batchOperations.addCopyOp(
"fromBucket", "fromFileKey",
"toBucket", "toFileKey"
);
Assertions.assertEquals(3, batchOperations.size());

batchOperations.addRenameOp("fromBucket", "fromFileKey", "toFileKey");
Assertions.assertEquals(4, batchOperations.size());
}
}