-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround if an object is named "Tag", make it a "TagObject" to avoi…
…d compile errors. Fixes https://jira.dropboxer.net/browse/WEBSERVDB-18031 (#396) Updating Target SDK API Versions. Added integration test for Tags. Make sure we do a cleanup after tests. Updated checks/javadoc and improved naming of variables. Reverting some of my aggressive test changes.
- Loading branch information
1 parent
57af1e4
commit 032148f
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule stone
updated
24 files
+1 −1 | .github/workflows/dispatch_spec_update.yml | |
+2 −2 | README.md | |
+3 −1 | auth.stone | |
+4 −2 | check_api_v2_service.stone | |
+1 −0 | check_api_v2_types.stone | |
+4 −3 | common.stone | |
+1 −2 | file_properties.stone | |
+115 −0 | file_tagging.stone | |
+411 −38 | files.stone | |
+187 −0 | release_note_generator.py | |
+1 −1 | shared_content_links.stone | |
+168 −12 | shared_links.stone | |
+7 −17 | sharing_files.stone | |
+10 −3 | sharing_folders.stone | |
+6 −2 | team.stone | |
+1 −0 | team_devices.stone | |
+15 −12 | team_folders.stone | |
+10 −8 | team_legal_holds.stone | |
+38 −1 | team_linked_apps.stone | |
+1,176 −89 | team_log_generated.stone | |
+346 −18 | team_members.stone | |
+11 −0 | team_policies.stone | |
+9 −4 | team_reports.stone | |
+6 −6 | team_secondary_mails.stone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.dropbox.core.v2.files; | ||
|
||
import com.dropbox.core.DbxException; | ||
import com.dropbox.core.ITUtil; | ||
import com.dropbox.core.v2.DbxClientV2; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.util.List; | ||
import java.util.Random; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
/** | ||
* Tests to ensure that the "Tag" related APIs are working. This is important because we have a name conflict | ||
* resolution of changing Tag -> TagObject, and we want to ensure it's working as expected. | ||
*/ | ||
public class TagObjectIT { | ||
|
||
private List<TagObject> getTagsForPath(DbxClientV2 client, String dropboxPath) throws DbxException { | ||
List<PathToTags> pathToTags = client.files().tagsGet(List.of(dropboxPath)).getPathsToTags(); | ||
assertEquals(1, pathToTags.size()); // There is only one path (the one we asked for) | ||
PathToTags pathToTag = pathToTags.get(0); | ||
assertEquals(dropboxPath, pathToTag.getPath()); // This is the path we are looking for | ||
System.out.println("Path to Tags: " + pathToTag.getTags()); | ||
return pathToTag.getTags(); | ||
} | ||
|
||
@Test | ||
public void testTagging() throws Exception { | ||
DbxClientV2 client = ITUtil.newClientV2(); | ||
|
||
int randomInt = new Random().nextInt(); | ||
|
||
|
||
byte[] contents = ("Tagging Test " + randomInt).getBytes(); | ||
String dropboxPath = ITUtil.path(getClass(), "/tagging-test-" + randomInt + ".txt"); | ||
|
||
// Upload File | ||
client.files().uploadBuilder(dropboxPath) | ||
.withMode(WriteMode.OVERWRITE) | ||
.uploadAndFinish(new ByteArrayInputStream(contents)); | ||
|
||
// Add Tag "a" to file | ||
client.files().tagsAdd(dropboxPath, "a"); | ||
assertEquals("a", getTagsForPath(client, dropboxPath).get(0).getUserGeneratedTagValue().getTagText()); | ||
|
||
// Add Tag "b" to file | ||
client.files().tagsAdd(dropboxPath, "b"); | ||
List<TagObject> tagsAandB = getTagsForPath(client, dropboxPath); | ||
assertEquals(2, tagsAandB.size()); | ||
assertEquals("a", tagsAandB.get(0).getUserGeneratedTagValue().getTagText()); | ||
assertEquals("b", tagsAandB.get(1).getUserGeneratedTagValue().getTagText()); | ||
|
||
// Remove Tag "a" from file | ||
client.files().tagsRemove(dropboxPath, "a"); | ||
List<TagObject> tagsJustB = getTagsForPath(client, dropboxPath); | ||
assertEquals(1, tagsJustB.size()); | ||
assertEquals("b", tagsJustB.get(0).getUserGeneratedTagValue().getTagText()); | ||
|
||
// Remove Tag "b" from file | ||
client.files().tagsRemove(dropboxPath, "b"); | ||
List<TagObject> tagsNone = getTagsForPath(client, dropboxPath); | ||
assertEquals(0, tagsNone.size()); | ||
|
||
// Cleanup, delete our test directory. | ||
client.files().deleteV2(dropboxPath); | ||
} | ||
} |