use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDate method testLocalTime.
@Test
public void testLocalTime() throws Exception {
LocalTime now = LocalTime.now();
this.sqlgGraph.addVertex(T.label, "A", "time", now);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<LocalTime>> properties = sqlgGraph1.traversal().V().hasLabel("A").<LocalTime>properties("time").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
LocalTime value = properties.get(0).<LocalTime>value();
Assert.assertEquals(now.toSecondOfDay(), value.toSecondOfDay());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDate method testLocalDateTimeUpdate.
@Test
public void testLocalDateTimeUpdate() throws Exception {
LocalDateTime now = LocalDateTime.now();
Vertex v = this.sqlgGraph.addVertex(T.label, "A", "dateTime", now);
this.sqlgGraph.tx().commit();
v.property("dateTime", now.plusHours(1));
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property> properties = sqlgGraph1.traversal().V().hasLabel("A").properties("dateTime").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Assert.assertEquals(now.plusHours(1), properties.get(0).value());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDate method testPeriod.
@Test
public void testPeriod() throws Exception {
Period period = Period.of(2016, 5, 5);
this.sqlgGraph.addVertex(T.label, "A", "period", period);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property> properties = sqlgGraph1.traversal().V().hasLabel("A").properties("period").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Assert.assertEquals(period, properties.get(0).value());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDate method testLocalDateTime.
@Test
public void testLocalDateTime() throws Exception {
LocalDateTime now = LocalDateTime.now();
this.sqlgGraph.addVertex(T.label, "A", "dateTime", 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("dateTime").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 TestLocalDateArray method testLocalTimeArrayOnEdge.
@Test
public void testLocalTimeArrayOnEdge() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalTimeArrayValues());
LocalTime[] localTimes = new LocalTime[] { LocalTime.now(), LocalTime.now().minusHours(1) };
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "localTimes", localTimes);
Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "localTimes", localTimes);
a1.addEdge("aa", a2, "localTimes", localTimes);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<LocalTime[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<LocalTime[]>properties("localTimes").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
LocalTime[] value = properties.get(0).<LocalTime[]>value();
List<LocalTime> localTimes1 = new ArrayList<>();
for (LocalTime localTime : value) {
localTimes1.add(localTime.minusNanos(localTime.getNano()));
}
Assert.assertArrayEquals(localTimes1.toArray(), value);
}
}
Aggregations