Skip to content

Commit

Permalink
Fix incompatibilities with the latest RedisStack (#3855)
Browse files Browse the repository at this point in the history
* Fix tests

- Skip Graph tests
- Fix JSON RESP3 test

* JSON.GET behaves identically on RESP2 and RESP3
  • Loading branch information
uglide authored Jun 6, 2024
1 parent 11ce88e commit 6b9d338
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 38 deletions.
3 changes: 1 addition & 2 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -3495,8 +3495,7 @@ public final CommandObject<String> jsonMerge(String key, Path path, Object pojo)
}

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

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,13 @@ public void testJsonGenericObjectResp3() {
assertThat(setResult, equalTo("OK"));

Object getRoot = exec(commandObjects.jsonGet(key));
assertThat(getRoot, instanceOf(JSONArray.class));
assertThat(getRoot, instanceOf(JSONObject.class));

JSONObject expectedPerson = new JSONObject();
expectedPerson.put("name", "John Doe");
expectedPerson.put("age", 30);

JSONArray expected = new JSONArray().put(expectedPerson);
assertThat(getRoot, jsonEquals(expected));
assertThat(expectedPerson, jsonEquals(getRoot));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import java.util.List;
import java.util.Map;

import org.junit.Ignore;
import org.junit.Test;
import redis.clients.jedis.Response;
import redis.clients.jedis.graph.ResultSet;

@Ignore
public class PipeliningBaseGraphCommandsTest extends PipeliningBaseMockedTestBase {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

import java.util.*;

import org.junit.After;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

Expand All @@ -25,6 +22,7 @@

import redis.clients.jedis.modules.RedisModuleCommandsTestBase;

@Ignore
@RunWith(Parameterized.class)
public class GraphAPITest extends RedisModuleCommandsTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import java.util.Iterator;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

Expand All @@ -26,6 +23,7 @@
import redis.clients.jedis.graph.entities.Property;
import redis.clients.jedis.modules.RedisModuleCommandsTestBase;

@Ignore
@RunWith(Parameterized.class)
public class GraphPipelineTest extends RedisModuleCommandsTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -23,6 +24,7 @@
import redis.clients.jedis.graph.entities.Property;
import redis.clients.jedis.modules.RedisModuleCommandsTestBase;

@Ignore
@RunWith(Parameterized.class)
public class GraphTransactionTest extends RedisModuleCommandsTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.Assert.assertEquals;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand All @@ -12,6 +13,7 @@
import redis.clients.jedis.graph.ResultSet;
import redis.clients.jedis.modules.RedisModuleCommandsTestBase;

@Ignore
@RunWith(Parameterized.class)
public class GraphValuesTest extends RedisModuleCommandsTestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import org.junit.Ignore;
import org.junit.Test;
import redis.clients.jedis.graph.entities.Edge;

@Ignore
public class PathBuilderTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public void setUp() {

@Test
public void basicSetGetShouldSucceed() {
Assume.assumeFalse(protocol == RedisProtocol.RESP3);

// naive set with a path
jsonV2.jsonSetWithEscape("null", ROOT_PATH, (Object) null);
assertJsonArrayEquals(jsonArray((Object) null), jsonV2.jsonGet("null", ROOT_PATH));
Expand All @@ -72,29 +70,6 @@ public void basicSetGetShouldSucceed() {
assertJsonArrayEquals(jsonArray("strung"), jsonV2.jsonGet("obj", p));
}

@Test
public void basicSetGetShouldSucceedResp3() {
Assume.assumeTrue(protocol == RedisProtocol.RESP3);

// naive set with a path
jsonV2.jsonSetWithEscape("null", ROOT_PATH, (Object) null);
assertJsonArrayEquals(jsonArray((Object) null), jsonV2.jsonGet("null", ROOT_PATH));

// real scalar value and no path
jsonV2.jsonSetWithEscape("str", "strong");
assertJsonArrayEquals(jsonArray("strong"), jsonV2.jsonGet("str"));

// a slightly more complex object
IRLObject obj = new IRLObject();
jsonV2.jsonSetWithEscape("obj", obj);
assertJsonArrayEquals(jsonArray(new JSONObject(gson.toJson(obj))), jsonV2.jsonGet("obj"));

// check an update
Path2 p = Path2.of(".str");
jsonV2.jsonSet("obj", p, gson.toJson("strung"));
assertJsonArrayEquals(jsonArray("strung"), jsonV2.jsonGet("obj", p));
}

@Test
public void setExistingPathOnlyIfExistsShouldSucceed() {
jsonV2.jsonSetWithEscape("obj", new IRLObject());
Expand Down

0 comments on commit 6b9d338

Please sign in to comment.