Skip to content

Commit

Permalink
Remove public reference to user defined tags
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnmaten committed Sep 3, 2017
1 parent 985880d commit 6567405
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
17 changes: 10 additions & 7 deletions src/main/java/com/filestack/FileLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.filestack.errors.PolicySignatureException;
import com.filestack.errors.ResourceNotFoundException;
import com.filestack.errors.ValidationException;
import com.filestack.responses.ImageTagResponse;
import com.filestack.transforms.ImageTransform;
import com.filestack.transforms.ImageTransformTask;
import com.filestack.util.FsService;
Expand All @@ -18,6 +19,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URLConnection;
import java.util.Map;
import java.util.concurrent.Callable;
import okhttp3.MediaType;
import okhttp3.RequestBody;
Expand Down Expand Up @@ -262,7 +264,7 @@ public ImageTransform imageTransform() {
*
* @see <a href="https://www.filestack.com/docs/tagging"></a>
*/
public ImageTags imageTag()
public Map<String, Integer> imageTags()
throws ValidationException, IOException, PolicySignatureException,
ResourceNotFoundException, InvalidParameterException, InternalException {

Expand All @@ -274,7 +276,8 @@ public ImageTags imageTag()
transform.addTask(new ImageTransformTask("tags"));
JsonObject json = transform.getContentJson();
Gson gson = new Gson();
return gson.fromJson(json, ImageTags.class);
ImageTagResponse response = gson.fromJson(json, ImageTagResponse.class);
return response.getAuto();
}

/**
Expand Down Expand Up @@ -383,13 +386,13 @@ public void run() throws Exception {
/**
* Asynchronously returns tags from Google Vision API for image FileLinks.
*
* @see #imageTag()
* @see #imageTags()
*/
public Single<ImageTags> imageTagAsync() {
return Single.fromCallable(new Callable<ImageTags>() {
public Single<Map<String, Integer>> imageTagsAsync() {
return Single.fromCallable(new Callable<Map<String, Integer>>() {
@Override
public ImageTags call() throws Exception {
return imageTag();
public Map<String, Integer> call() throws Exception {
return imageTags();
}
})
.subscribeOn(Schedulers.io())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.filestack;
package com.filestack.responses;

import java.util.Map;

Expand All @@ -7,7 +7,7 @@
*
* @see <a href="https://www.filestack.com/docs/tagging"></a>
*/
public class ImageTags {
public class ImageTagResponse {
Tags tags;

class Tags {
Expand Down
7 changes: 4 additions & 3 deletions src/test/java/com/filestack/TestFileLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.filestack.util.FsService;
import com.google.common.io.Files;
import java.io.File;
import java.util.Map;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
Expand Down Expand Up @@ -191,7 +192,7 @@ public void testDeleteWithoutSecurity() throws Exception {
@Test(expected = ValidationException.class)
public void testImageTagNoSecurity() throws Exception {
FileLink fileLink = new FileLink("apiKey", "handle");
fileLink.imageTag();
fileLink.imageTags();
}

@Test
Expand Down Expand Up @@ -229,9 +230,9 @@ public void testImageTag() throws Exception {
.service(mockFsService)
.build();

ImageTags imageTags = fileLink.imageTag();
Map<String, Integer> tags = fileLink.imageTags();

Assert.assertEquals((Integer) 100, imageTags.getAuto().get("giraffe"));
Assert.assertEquals((Integer) 100, tags.get("giraffe"));
}

@Test(expected = ValidationException.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.filestack;
package com.filestack.responses;

import com.google.gson.Gson;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;

public class TestImageTags {
public class TestImageTagResponse {

@Test
public void test() {
Expand All @@ -29,7 +29,7 @@ public void test() {
+ "}"
+ "}";

ImageTags imageTags = gson.fromJson(jsonString, ImageTags.class);
ImageTagResponse imageTags = gson.fromJson(jsonString, ImageTagResponse.class);

Assert.assertNotNull(imageTags.getAuto());
Assert.assertNull(imageTags.getUser());
Expand Down

0 comments on commit 6567405

Please sign in to comment.