use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testLocalDateArrayOnEdge.
@Test
public void testLocalDateArrayOnEdge() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateArrayValues());
LocalDate[] localDates = new LocalDate[] { LocalDate.now(), LocalDate.now().minusDays(1) };
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "localDates", localDates);
Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "localDates", localDates);
a1.addEdge("aa", a2, "localDates", localDates);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<LocalDate[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<LocalDate[]>properties("localDates").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Assert.assertArrayEquals(localDates, properties.get(0).value());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testZonedDateTimeArrayOnEdge.
@Test
public void testZonedDateTimeArrayOnEdge() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsZonedDateTimeArrayValues());
ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");
ZonedDateTime zonedDateTimeAGT = ZonedDateTime.of(LocalDateTime.now(), zoneIdShanghai);
ZoneId zoneIdHarare = ZoneId.of("Africa/Harare");
ZonedDateTime zonedDateTimeAGTHarare = ZonedDateTime.of(LocalDateTime.now(), zoneIdHarare);
ZonedDateTime[] zonedDateTimes = { zonedDateTimeAGT, zonedDateTimeAGTHarare };
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "zonedDateTimes", zonedDateTimes);
Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "zonedDateTimes", zonedDateTimes);
a1.addEdge("aa", a2, "zonedDateTimes", zonedDateTimes);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<ZonedDateTime[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<ZonedDateTime[]>properties("zonedDateTimes").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
ZonedDateTime[] localDateTimesFromDb = properties.get(0).value();
Assert.assertArrayEquals(zonedDateTimes, localDateTimesFromDb);
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testLocalDateTimeArray.
@Test
public void testLocalDateTimeArray() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateTimeArrayValues());
LocalDateTime[] localDateTimes = new LocalDateTime[] { LocalDateTime.now(), LocalDateTime.now() };
this.sqlgGraph.addVertex(T.label, "A", "localDateTimes", localDateTimes);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<LocalDateTime[]>> properties = sqlgGraph1.traversal().V().hasLabel("A").<LocalDateTime[]>properties("localDateTimes").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
LocalDateTime[] localDateTimesFromDb = properties.get(0).value();
Assert.assertArrayEquals(localDateTimes, localDateTimesFromDb);
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testZonedDateTimeArray.
@Test
public void testZonedDateTimeArray() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsZonedDateTimeArrayValues());
ZoneId zoneIdShanghai = ZoneId.of("Asia/Shanghai");
ZonedDateTime zonedDateTimeAGT = ZonedDateTime.of(LocalDateTime.now(), zoneIdShanghai);
ZoneId zoneIdHarare = ZoneId.of("Africa/Harare");
ZonedDateTime zonedDateTimeAGTHarare = ZonedDateTime.of(LocalDateTime.now(), zoneIdHarare);
ZonedDateTime[] zonedDateTimes = { zonedDateTimeAGT, zonedDateTimeAGTHarare };
this.sqlgGraph.addVertex(T.label, "A", "zonedDateTimes", zonedDateTimes);
this.sqlgGraph.tx().commit();
// noinspection Duplicates
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<ZonedDateTime[]>> properties = sqlgGraph1.traversal().V().hasLabel("A").<ZonedDateTime[]>properties("zonedDateTimes").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
ZonedDateTime[] value = properties.get(0).<ZonedDateTime[]>value();
Assert.assertArrayEquals(zonedDateTimes, value);
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testDurationArray.
@Test
public void testDurationArray() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues());
Duration[] durations = new Duration[] { Duration.ofHours(1), Duration.ofHours(5) };
this.sqlgGraph.addVertex(T.label, "A", "durations", durations);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<Duration[]>> properties = sqlgGraph1.traversal().V().hasLabel("A").<Duration[]>properties("durations").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Duration[] durationsFromDb = properties.get(0).value();
Assert.assertArrayEquals(durations, durationsFromDb);
}
}
Aggregations