use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyUpgrade method testUpgradeJson.
@Test
public void testUpgradeJson() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsJsonType());
ObjectNode json = new ObjectMapper().createObjectNode();
json.put("halo", "asdasd");
this.sqlgGraph.addVertex(T.label, "A.A", "name", "a1", "json", json);
this.sqlgGraph.tx().commit();
// Delete the topology
dropSqlgSchema(this.sqlgGraph);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<Vertex> schemaVertices = sqlgGraph1.topology().V().hasLabel("sqlg_schema.schema").has("name", "A").toList();
Assert.assertEquals(1, schemaVertices.size());
// assert zonedDateTimes
List<Vertex> propertyVertices = sqlgGraph1.topology().V().hasLabel("sqlg_schema.schema").has("name", "A").out("schema_vertex").has("name", "A").out("vertex_property").has("name", "json").toList();
Assert.assertEquals(1, propertyVertices.size());
Assert.assertEquals(PropertyType.JSON, PropertyType.valueOf(propertyVertices.get(0).value("type")));
List<Vertex> vertices = sqlgGraph1.traversal().V().hasLabel("A.A").has("name", "a1").toList();
Assert.assertEquals(1, vertices.size());
Assert.assertEquals(json, vertices.get(0).value("json"));
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyUpgrade method testUpgradeMultipleInOutEdges2.
@Test
public void testUpgradeMultipleInOutEdges2() throws Exception {
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1");
Vertex b1 = this.sqlgGraph.addVertex(T.label, "R_EG.B", "name", "b1");
Vertex c1 = this.sqlgGraph.addVertex(T.label, "P_EG.C", "name", "c1");
Object a1Id = a1.id();
Object b1Id = b1.id();
a1.addEdge("ab", b1, "weight", 5);
a1.addEdge("ab", c1, "weight", 6);
b1.addEdge("ba", a1, "wtf", "wtf1");
b1.addEdge("ba", c1, "wtf", "wtf1");
this.sqlgGraph.tx().commit();
// Delete the topology
dropSqlgSchema(this.sqlgGraph);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
// topology will be recreated
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
Assert.assertEquals(2, sqlgGraph1.traversal().V(a1Id).out().count().next().intValue());
Assert.assertEquals(2, sqlgGraph1.traversal().V(b1Id).out().count().next().intValue());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestTopologyUpgrade method testModernGraph.
@Test
public void testModernGraph() throws Exception {
loadModern();
Traversal<Vertex, Long> traversal = this.sqlgGraph.traversal().V().both().both().count();
Assert.assertEquals(new Long(30), traversal.next());
Assert.assertFalse(traversal.hasNext());
this.sqlgGraph.traversal().V().forEachRemaining(Element::remove);
this.sqlgGraph.tx().commit();
// Delete the topology
dropSqlgSchema(this.sqlgGraph);
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
loadModern(sqlgGraph1);
traversal = sqlgGraph1.traversal().V().both().both().count();
Assert.assertEquals(new Long(30), traversal.next());
Assert.assertFalse(traversal.hasNext());
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testLocalDateArray.
@Test
public void testLocalDateArray() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateArrayValues());
LocalDate[] localDates = new LocalDate[] { LocalDate.now(), LocalDate.now().minusDays(1) };
this.sqlgGraph.addVertex(T.label, "A", "localDates", localDates);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<LocalDate[]>> properties = sqlgGraph1.traversal().V().hasLabel("A").<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 testLocalTimeArray.
@Test
public void testLocalTimeArray() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalTimeArrayValues());
LocalTime[] localTimes = new LocalTime[] { LocalTime.now(), LocalTime.now().minusHours(1) };
this.sqlgGraph.addVertex(T.label, "A", "localTimes", localTimes);
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("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