Skip to content

Commit

Permalink
[GIE/tests] Add pattern matching test cases for GIE (#2831)
Browse files Browse the repository at this point in the history
Committed-by: 有理 from Dev container

<!--
Thanks for your contribution! please review
https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before
opening an issue.
-->

## What do these changes do?

As title.

## Related issue number

issue #2822
  • Loading branch information
lixueclaire authored Jun 8, 2023
1 parent 30e45e0 commit 653823b
Showing 1 changed file with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public abstract class IrGremlinQueryTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Map<String, Vertex>>
get_g_V_matchXa_in_b__b_out_c__not_c_out_aX();

public abstract Traversal<Vertex, Object>
get_g_V_matchXa_knows_b__b_created_cX_select_c_values();

public abstract Traversal<Vertex, Object>
get_g_V_matchXa_out_b__b_in_cX_select_c_out_dedup_values();

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_V_group_by_by_dedup_count_test() {
Expand Down Expand Up @@ -167,6 +173,44 @@ public void g_V_matchXa_in_b__b_out_c__not_c_out_aX() {
traversal);
}

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_V_matchXa_knows_b__b_created_cX_select_c_values() {
final Traversal<Vertex, Object> traversal =
get_g_V_matchXa_knows_b__b_created_cX_select_c_values();
printTraversalForm(traversal);
int counter = 0;

List<String> expected = Arrays.asList("lop", "ripple");

while (traversal.hasNext()) {
Object result = traversal.next();
Assert.assertTrue(expected.contains(result.toString()));
++counter;
}

Assert.assertEquals(2, counter);
}

@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@Test
public void g_V_matchXa_out_b__b_in_cX_select_c_out_dedup_values() {
final Traversal<Vertex, Object> traversal =
get_g_V_matchXa_out_b__b_in_cX_select_c_out_dedup_values();
printTraversalForm(traversal);
int counter = 0;

List<String> expected = Arrays.asList("josh", "vadas");

while (traversal.hasNext()) {
Object result = traversal.next();
Assert.assertTrue(expected.contains(result.toString()));
++counter;
}

Assert.assertEquals(2, counter);
}

public static class Traversals extends IrGremlinQueryTest {

@Override
Expand Down Expand Up @@ -208,5 +252,24 @@ public Traversal<Vertex, Object> get_g_V_out_as_a_in_select_a_as_b_select_b_by_v
as("b").out("knows").as("c"),
not(as("c").out("knows").as("a")));
}

@Override
public Traversal<Vertex, Object> get_g_V_matchXa_knows_b__b_created_cX_select_c_values() {
return g.V().match(as("a").out("knows").as("b"), as("b").out("created").as("c"))
.select("c")
.values("name");
}

@Override
public Traversal<Vertex, Object>
get_g_V_matchXa_out_b__b_in_cX_select_c_out_dedup_values() {
return g.V().match(
as("a").out("created").has("name", "lop").as("b"),
as("b").in("created").has("age", 29).as("c"))
.select("c")
.out("knows")
.dedup()
.values("name");
}
}
}

0 comments on commit 653823b

Please sign in to comment.