Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thehung111 committed Dec 5, 2022
1 parent 589b801 commit 97f596d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ public RetrofitQueryMap getQueryMap() {


String jsonStr = gson.toJson(this);
System.out.println("json: " + jsonStr);

JsonObject jsonObj = gson.fromJson(jsonStr, JsonObject.class);
Set<Map.Entry<String, JsonElement>> entrySet = jsonObj.entrySet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class ProductSearchByImageParams extends BaseProductSearchParams {
@Expose(deserialize = false, serialize = false)
private Image image;

@SerializedName("box")
private int[] box;
// transient is to prevent serialization
private transient int[] box;

@SerializedName("detection")
private String detection;
Expand All @@ -31,6 +31,9 @@ public class ProductSearchByImageParams extends BaseProductSearchParams {
@SerializedName("search_all_object")
private Boolean searchAllObjects;

// internal serialization
@SerializedName("box")
private String boxParam;

public Boolean getSearchAllObjects() {
return searchAllObjects;
Expand Down Expand Up @@ -70,6 +73,7 @@ public int[] getBox() {

public void setBox(int x1, int y1, int x2, int y2) {
this.box = new int[] {x1, y1, x2, y2};
this.boxParam = String.format("%d,%d,%d,%d", x1, y1, x2, y2);
}

public String getDetection() {
Expand All @@ -96,6 +100,10 @@ public void setDetectionSensitivity(String detectionSensitivity) {
this.detectionSensitivity = detectionSensitivity;
}

public String getBoxParam() {
return boxParam;
}

public ProductSearchByImageParams() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public void testBaseSearchParams_parsing() {
customMap.put("debug", "true");
params.setCustomParams(customMap);

params.setBox(10,20,400,500);


RetrofitQueryMap map = params.getQueryMap();

Expand All @@ -61,6 +63,7 @@ public void testBaseSearchParams_parsing() {
assertEquals("testParamVal", map.get("testParam"));
assertEquals("testParamVal2", map.get("testParam2"));
assertEquals("1234555", map.get("im_id"));
assertEquals("10,20,400,500", map.get("box"));
}


Expand Down

0 comments on commit 97f596d

Please sign in to comment.