use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyUpgrade method testUpgradeArrays.
@Test
public void testUpgradeArrays() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsShortArrayValues());
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues());
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsDoubleArrayValues());
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateArrayValues());
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateTimeArrayValues());
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalTimeArrayValues());
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsZonedDateTimeArrayValues());
Byte[] bytes = new Byte[] { 1, 2, 3 };
byte[] bytes2 = new byte[] { 1, 2, 3 };
Short[] shorts = new Short[] { 1, 2, 3 };
short[] shorts2 = new short[] { 1, 2, 3 };
Integer[] integers = new Integer[] { 1, 2, 3 };
int[] integers2 = new int[] { 1, 2, 3 };
Long[] longs = new Long[] { 1L, 2L, 3L };
long[] longs2 = new long[] { 1L, 2L, 3L };
Double[] doubles = new Double[] { 1D, 2D, 3D };
double[] doubles2 = new double[] { 1D, 2D, 3D };
String[] strings = new String[] { "a", "b", "c" };
LocalDate[] localDates = new LocalDate[] { LocalDate.now(), LocalDate.now().minusMonths(2), LocalDate.now().minusMonths(3) };
LocalDateTime[] localDateTimes = new LocalDateTime[] { LocalDateTime.now(), LocalDateTime.now().minusMonths(2), LocalDateTime.now().minusMonths(3) };
LocalTime[] localTimes = new LocalTime[] { LocalTime.now(), LocalTime.now().minusHours(2), LocalTime.now().minusHours(3) };
ZonedDateTime[] zonedDateTimes = new ZonedDateTime[] { ZonedDateTime.now(), ZonedDateTime.now().minusHours(2), ZonedDateTime.now().minusHours(3) };
this.sqlgGraph.addVertex(T.label, "A", "bytes", bytes, "bytes2", bytes2, "shorts", shorts, "shorts2", shorts2, "integers", integers, "integers2", integers2, "longs", longs, "longs2", longs2, "doubles", doubles, "doubles2", doubles2, "strings", strings, "localDates", localDates, "localDateTimes", localDateTimes, "localTimes", localTimes, "zonedDateTimes", zonedDateTimes);
this.sqlgGraph.tx().commit();
// Delete the topology
dropSqlgSchema(this.sqlgGraph);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
Assert.assertArrayEquals(bytes, sqlgGraph1.traversal().V().hasLabel("A").next().value("bytes"));
Assert.assertArrayEquals(bytes, sqlgGraph1.traversal().V().hasLabel("A").next().value("bytes2"));
Assert.assertArrayEquals(shorts, sqlgGraph1.traversal().V().hasLabel("A").next().value("shorts"));
Assert.assertArrayEquals(shorts, sqlgGraph1.traversal().V().hasLabel("A").next().value("shorts2"));
Assert.assertArrayEquals(integers, sqlgGraph1.traversal().V().hasLabel("A").next().value("integers"));
Assert.assertArrayEquals(integers, sqlgGraph1.traversal().V().hasLabel("A").next().value("integers2"));
Assert.assertArrayEquals(longs, sqlgGraph1.traversal().V().hasLabel("A").next().value("longs"));
Assert.assertArrayEquals(longs, sqlgGraph1.traversal().V().hasLabel("A").next().value("longs2"));
Assert.assertArrayEquals(doubles, sqlgGraph1.traversal().V().hasLabel("A").next().value("doubles"));
Assert.assertArrayEquals(doubles, sqlgGraph1.traversal().V().hasLabel("A").next().value("doubles2"));
Assert.assertArrayEquals(strings, sqlgGraph1.traversal().V().hasLabel("A").next().value("strings"));
Assert.assertArrayEquals(localDates, sqlgGraph1.traversal().V().hasLabel("A").next().value("localDates"));
Assert.assertArrayEquals(localDateTimes, sqlgGraph1.traversal().V().hasLabel("A").next().value("localDateTimes"));
LocalTime[] value = sqlgGraph1.traversal().V().hasLabel("A").next().value("localTimes");
List<LocalTime> localTimes1 = new ArrayList<>();
for (LocalTime localTime : value) {
localTimes1.add(localTime.minusNanos(localTime.getNano()));
}
Assert.assertArrayEquals(localTimes1.toArray(), value);
Assert.assertArrayEquals(zonedDateTimes, sqlgGraph1.traversal().V().hasLabel("A").next().value("zonedDateTimes"));
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDate method testDuration.
@Test
public void testDuration() throws Exception {
Duration duration = Duration.ofHours(5);
this.sqlgGraph.addVertex(T.label, "A", "duration", duration);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property> properties = sqlgGraph1.traversal().V().hasLabel("A").properties("duration").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Assert.assertEquals(duration, properties.get(0).value());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDate method testLoadDateTypes.
@Test
public void testLoadDateTypes() throws Exception {
LocalDateTime localDateTime = LocalDateTime.now();
LocalDate localDate = LocalDate.now();
LocalTime localTime = LocalTime.now();
ZonedDateTime zonedDateTime = ZonedDateTime.now();
Period period = Period.of(12, 13, 14);
Duration duration = Duration.ofSeconds(2);
this.sqlgGraph.addVertex(T.label, "Person", "dateTime", localDateTime, "date", localDate, "time", localTime, "zonedDateTime", zonedDateTime, "period", period, "duration", duration);
this.sqlgGraph.tx().commit();
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
Assert.assertTrue(sqlgGraph1.traversal().V().hasLabel("Person").hasNext());
Vertex v = sqlgGraph1.traversal().V().hasLabel("Person").next();
Assert.assertEquals(localDateTime, v.value("dateTime"));
Assert.assertEquals(localDate, v.value("date"));
Assert.assertEquals(localTime.toSecondOfDay(), v.<LocalTime>value("time").toSecondOfDay());
Assert.assertEquals(zonedDateTime, v.value("zonedDateTime"));
Assert.assertEquals(period, v.value("period"));
Assert.assertEquals(duration, v.value("duration"));
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDate method testLocalDate.
@Test
public void testLocalDate() throws Exception {
LocalDate now = LocalDate.now();
this.sqlgGraph.addVertex(T.label, "A", "date", now);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property> properties = sqlgGraph1.traversal().V().hasLabel("A").properties("date").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Assert.assertEquals(now, properties.get(0).value());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestEdgeCache method testMultipleEdgesFromSameVertex.
@Test
public void testMultipleEdgesFromSameVertex() throws Exception {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "mike");
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw");
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Car", "name", "bmw");
Vertex v4 = this.sqlgGraph.addVertex(T.label, "Bike", "name", "ktm");
v1.addEdge("bts_aaaaaa", v2);
v1.addEdge("bts_btsalmtos", v4);
v1.addEdge("bts_btsalm", v3);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) {
v1 = sqlgGraph.traversal().V(v1.id()).next();
assertEquals(1, sqlgGraph.traversal().V(v1.id()).out("bts_btsalm").count().next().intValue());
assertEquals(1, sqlgGraph.traversal().V(v1.id()).out("bts_btsalmtos").count().next().intValue());
}
}
Aggregations