Skip to content

Commit 4ca869e

Browse files
authored
Address change in JSON.GET command without path (#3858)
1 parent 36668bc commit 4ca869e

File tree

3 files changed

+2
-53
lines changed

3 files changed

+2
-53
lines changed

src/main/java/redis/clients/jedis/CommandObjects.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,8 +3621,7 @@ public final CommandObject<String> jsonMerge(String key, Path path, Object pojo)
36213621
}
36223622

36233623
public final CommandObject<Object> jsonGet(String key) {
3624-
return new CommandObject<>(commandArguments(JsonCommand.GET).key(key),
3625-
protocol != RedisProtocol.RESP3 ? JSON_GENERIC_OBJECT : JsonBuilderFactory.JSON_OBJECT);
3624+
return new CommandObject<>(commandArguments(JsonCommand.GET).key(key), JSON_GENERIC_OBJECT);
36263625
}
36273626

36283627
@Deprecated

src/test/java/redis/clients/jedis/commands/commandobjects/CommandObjectsJsonCommandsTest.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ public void testJsonMergeOldPath() {
235235

236236
@Test
237237
@Deprecated
238-
public void testJsonGenericObjectResp2() {
239-
assumeThat(protocol, not(equalTo(RedisProtocol.RESP3)));
240-
238+
public void testJsonGenericObject() {
241239
String key = "user:1000";
242240

243241
Person person = new Person();
@@ -256,29 +254,6 @@ public void testJsonGenericObjectResp2() {
256254
assertThat(resultMap, hasEntry("age", 30.0));
257255
}
258256

259-
@Test
260-
@Deprecated
261-
public void testJsonGenericObjectResp3() {
262-
assumeThat(protocol, equalTo(RedisProtocol.RESP3));
263-
264-
String key = "user:1000";
265-
266-
Person person = new Person("John Doe", 30);
267-
268-
String setResult = exec(commandObjects.jsonSet(key, Path.ROOT_PATH, person));
269-
assertThat(setResult, equalTo("OK"));
270-
271-
Object getRoot = exec(commandObjects.jsonGet(key));
272-
assertThat(getRoot, instanceOf(JSONArray.class));
273-
274-
JSONObject expectedPerson = new JSONObject();
275-
expectedPerson.put("name", "John Doe");
276-
expectedPerson.put("age", 30);
277-
278-
JSONArray expected = new JSONArray().put(expectedPerson);
279-
assertThat(getRoot, jsonEquals(expected));
280-
}
281-
282257
@Test
283258
@Deprecated
284259
public void testJsonGetWithClass() {

src/test/java/redis/clients/jedis/modules/json/RedisJsonV2Test.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public void setUp() {
5050

5151
@Test
5252
public void basicSetGetShouldSucceed() {
53-
Assume.assumeFalse(protocol == RedisProtocol.RESP3);
54-
5553
// naive set with a path
5654
jsonV2.jsonSetWithEscape("null", ROOT_PATH, (Object) null);
5755
assertJsonArrayEquals(jsonArray((Object) null), jsonV2.jsonGet("null", ROOT_PATH));
@@ -72,29 +70,6 @@ public void basicSetGetShouldSucceed() {
7270
assertJsonArrayEquals(jsonArray("strung"), jsonV2.jsonGet("obj", p));
7371
}
7472

75-
@Test
76-
public void basicSetGetShouldSucceedResp3() {
77-
Assume.assumeTrue(protocol == RedisProtocol.RESP3);
78-
79-
// naive set with a path
80-
jsonV2.jsonSetWithEscape("null", ROOT_PATH, (Object) null);
81-
assertJsonArrayEquals(jsonArray((Object) null), jsonV2.jsonGet("null", ROOT_PATH));
82-
83-
// real scalar value and no path
84-
jsonV2.jsonSetWithEscape("str", "strong");
85-
assertJsonArrayEquals(jsonArray("strong"), jsonV2.jsonGet("str"));
86-
87-
// a slightly more complex object
88-
IRLObject obj = new IRLObject();
89-
jsonV2.jsonSetWithEscape("obj", obj);
90-
assertJsonArrayEquals(jsonArray(new JSONObject(gson.toJson(obj))), jsonV2.jsonGet("obj"));
91-
92-
// check an update
93-
Path2 p = Path2.of(".str");
94-
jsonV2.jsonSet("obj", p, gson.toJson("strung"));
95-
assertJsonArrayEquals(jsonArray("strung"), jsonV2.jsonGet("obj", p));
96-
}
97-
9873
@Test
9974
public void setExistingPathOnlyIfExistsShouldSucceed() {
10075
jsonV2.jsonSetWithEscape("obj", new IRLObject());

0 commit comments

Comments
 (0)