Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Change-Id: Ib8179d878b4311f72268f80e39f4aea48bba68b7
  • Loading branch information
javeme committed Dec 9, 2021
1 parent 8209102 commit bdc59e1
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8729,9 +8729,6 @@ public void testQueryByHasIdEmptyListInPage() {
public void testAddVertexWithSpecialSymbolInPrimaryValues() {
HugeGraph graph = graph();

Vertex vertex0 = graph.addVertex(T.label, "person", "name",
"xyz\u0000abc", "city", "Hongkong",
"age", 10);
Vertex vertex1 = graph.addVertex(T.label, "person", "name",
"xyz\u0001abc", "city", "Hongkong",
"age", 11);
Expand All @@ -8744,15 +8741,22 @@ public void testAddVertexWithSpecialSymbolInPrimaryValues() {
graph.tx().commit();

GraphTraversalSource g = graph.traversal();
Assert.assertEquals(vertex0, g.V().hasLabel("person")
.has("name", "xyz\u0000abc").next());

Assert.assertEquals(vertex1, g.V().hasLabel("person")
.has("name", "xyz\u0001abc").next());
Assert.assertEquals(vertex2, g.V().hasLabel("person")
.has("name", "xyz\u0002abc").next());
Assert.assertEquals(vertex3, g.V().hasLabel("person")
.has("name", "xyz\u0003abc").next());

if (!graph.backend().equals("postgresql")) {
Vertex vertex0 = graph.addVertex(T.label, "person", "name",
"xyz\u0000abc", "city", "Hongkong",
"age", 10);
Assert.assertEquals(vertex0, g.V().hasLabel("person")
.has("name", "xyz\u0000abc").next());
}

Assert.assertThrows(IllegalArgumentException.class, () -> {
graph.addVertex(T.label, "person", "name",
"\u0000", "city", "Hongkong",
Expand Down Expand Up @@ -8867,10 +8871,20 @@ public void testQueryBySearchIndexWithSpecialSymbol() {
vertices = g.V().has("city", Text.contains("\u0001")).toList();
Assert.assertEquals(0, vertices.size());

if (graph.backend().equals("postgresql")) {
String backend = graph.backend();
if (ImmutableSet.of("rocksdb", "hbase").contains(backend)) {
Assert.assertThrows(Exception.class, () -> {
graph.addVertex(T.label, "person", "name", "0",
"city", "xyz\u0000efg", "age", 0);
graph.tx().commit();
}, e -> {
Assert.assertContains("can't contains byte '0x00'",
e.getMessage());
});
} else if (backend.equals("postgresql")) {
Assert.assertThrows(BackendException.class, () -> {
graph.addVertex(T.label, "person", "name", "7",
"city", "\u0000",
"city", "xyz\u0000efg",
"age", 15);
graph.tx().commit();
}, e -> {
Expand Down

0 comments on commit bdc59e1

Please sign in to comment.