Skip to content

Commit 205e27b

Browse files
committed
test: update builder neo4j
Signed-off-by: Otavio Santana <[email protected]>
1 parent 814e0e1 commit 205e27b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

jnosql-neo4j/src/test/java/org/eclipse/jnosql/databases/neo4j/communication/Neo4JQueryBuilderTest.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
class Neo4JQueryBuilderTest {
3434

35-
3635
@Test
3736
void shouldBuildDeleteQueryForNode() {
3837
DeleteQuery query = mock(DeleteQuery.class);
@@ -63,6 +62,7 @@ void shouldBuildDeleteQueryForSpecificColumns() {
6362
void shouldBuildSelectQueryWithCondition() {
6463
SelectQuery query = mock(SelectQuery.class);
6564
when(query.name()).thenReturn("Person");
65+
6666
CriteriaCondition condition = mock(CriteriaCondition.class);
6767
Element element = mock(Element.class);
6868
when(condition.element()).thenReturn(element);
@@ -91,4 +91,26 @@ void shouldBuildSelectQueryWithoutCondition() {
9191

9292
assertThat(cypher).isEqualTo("MATCH (e:Person) RETURN e.name, e.age");
9393
}
94+
95+
@Test
96+
void shouldTranslateIdToElementId() {
97+
SelectQuery query = mock(SelectQuery.class);
98+
when(query.name()).thenReturn("Person");
99+
100+
CriteriaCondition condition = mock(CriteriaCondition.class);
101+
Element element = mock(Element.class);
102+
when(condition.element()).thenReturn(element);
103+
when(element.name()).thenReturn("_id");
104+
when(element.get()).thenReturn("12345");
105+
when(condition.condition()).thenReturn(org.eclipse.jnosql.communication.Condition.EQUALS);
106+
when(query.condition()).thenReturn(java.util.Optional.of(condition));
107+
when(query.columns()).thenReturn(List.of("name", "_id"));
108+
109+
Map<String, Object> parameters = new HashMap<>();
110+
String cypher = Neo4JQueryBuilder.INSTANCE.buildQuery(query, parameters);
111+
112+
assertThat(cypher).isEqualTo("MATCH (e:Person) WHERE elementId(e) = $id RETURN e.name, elementId(e)");
113+
assertThat(parameters).containsEntry("id", "12345");
114+
}
115+
94116
}

0 commit comments

Comments
 (0)