Skip to content

Commit

Permalink
chore: Add dedicated tests that all properties are correctly deserial…
Browse files Browse the repository at this point in the history
…ized.

Closes #397.
  • Loading branch information
michael-simons committed Mar 1, 2024
1 parent 62807a6 commit 9d17d62
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.UUID;
Expand All @@ -39,6 +40,7 @@
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.neo4j.jdbc.values.Value;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
Expand Down Expand Up @@ -485,4 +487,24 @@ WITH datetime('2015-06-24T12:50:35.556+0100') AS zonedDateTime
}
}

// GH-397
@SuppressWarnings("deprecation")
@Test
void elementIdAndIdShouldBeSupported() throws SQLException {
try (var connection = getConnection();
var stmt = connection.createStatement();
var result = stmt.executeQuery(
"CREATE (n:Test {name: 'A', _id: 'id1', _labels: ['L1', 'L2']}) -[r:RELATES_TO {name: 'R', _id: 'id2', _startId: 4711, _endId: 23, _type: 'Trololo'}] -> (m:AnotherTest {name: 'B', _id: 'id3'}) RETURN *")) {
assertThat(result.next()).isTrue();
var nodeA = result.getObject("n", Value.class).asNode();
var rel = result.getObject("r", Value.class).asRelationship();
var nodeB = result.getObject("m", Value.class).asNode();
assertThat(nodeA.asMap())
.containsExactlyInAnyOrderEntriesOf(Map.of("name", "A", "_id", "id1", "_labels", List.of("L1", "L2")));
assertThat(rel.asMap()).containsExactlyInAnyOrderEntriesOf(
Map.of("name", "R", "_id", "id2", "_startId", 4711L, "_endId", 23L, "_type", "Trololo"));
assertThat(nodeB.asMap()).containsExactlyInAnyOrderEntriesOf(Map.of("name", "B", "_id", "id3"));
}
}

}

0 comments on commit 9d17d62

Please sign in to comment.