use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testLocalDateTimeArrayOnEdge.
@Test
public void testLocalDateTimeArrayOnEdge() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsLocalDateTimeArrayValues());
LocalDateTime[] localDateTimes = new LocalDateTime[] { LocalDateTime.now(), LocalDateTime.now() };
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "localDateTimes", localDateTimes);
Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "localDateTimes", localDateTimes);
a1.addEdge("aa", a2, "localDateTimes", localDateTimes);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<LocalDateTime[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<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 testDurationArrayOnEdge.
@Test
public void testDurationArrayOnEdge() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues());
Duration[] durations = new Duration[] { Duration.ofHours(1), Duration.ofHours(5) };
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "duration", durations);
Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "duration", durations);
a1.addEdge("aa", a2, "duration", durations);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<Duration[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<Duration[]>properties("duration").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Duration[] durationsFromDb = properties.get(0).value();
Assert.assertArrayEquals(durations, durationsFromDb);
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLocalDateArray method testPeriodArrayOnEdge.
@Test
public void testPeriodArrayOnEdge() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues());
Period[] periods = new Period[] { Period.of(2016, 5, 5), Period.of(2015, 4, 4) };
Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "periods", periods);
Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "periods", periods);
a1.addEdge("aa", a2, "periods", periods);
this.sqlgGraph.tx().commit();
// Create a new sqlgGraph
try (SqlgGraph sqlgGraph1 = SqlgGraph.open(configuration)) {
List<? extends Property<Period[]>> properties = sqlgGraph1.traversal().E().hasLabel("aa").<Period[]>properties("periods").toList();
Assert.assertEquals(1, properties.size());
Assert.assertTrue(properties.get(0).isPresent());
Period[] periodsFromDb = properties.get(0).value();
Assert.assertArrayEquals(periods, periodsFromDb);
}
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestJNDIInitialization method testLoadingDatasourceFromJndi.
@Test
public void testLoadingDatasourceFromJndi() throws Exception {
SqlgGraph g = SqlgGraph.open(configuration);
assertNotNull(g.getSqlDialect());
assertEquals(configuration.getString("jdbc.url"), g.getJdbcUrl());
assertNotNull(g.getConnection());
}
use of org.umlg.sqlg.structure.SqlgGraph in project sqlg by pietermartin.
the class TestLoadArrayProperties method testLoadSchemaWithArrays.
@Test
public void testLoadSchemaWithArrays() throws Exception {
Assume.assumeTrue(this.sqlgGraph.getSqlDialect().supportsBooleanArrayValues() && this.sqlgGraph.getSqlDialect().supportsFloatArrayValues() && this.sqlgGraph.getSqlDialect().supportsLongArrayValues() && this.sqlgGraph.getSqlDialect().supportsIntegerArrayValues() && this.sqlgGraph.getSqlDialect().supportsDoubleArrayValues() && this.sqlgGraph.getSqlDialect().supportsStringArrayValues());
this.sqlgGraph.addVertex(T.label, "Person", "aBoolean", new boolean[] { true }, "aShort", new short[] { (short) 1 }, "aInteger", new int[] { 1 }, "aLong", new long[] { 1L }, "aFloat", new float[] { 1F }, "aDouble", new double[] { 1D }, "aString", new String[] { "aaaaaaaaaaaaa" });
this.sqlgGraph.tx().commit();
this.sqlgGraph.close();
try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) {
Iterator<Vertex> iter = sqlgGraph.traversal().V().has(T.label, "Person");
Assert.assertTrue(iter.hasNext());
Vertex v = iter.next();
Assert.assertTrue(Arrays.equals(new boolean[] { true }, (boolean[]) v.property("aBoolean").value()));
Assert.assertTrue(Arrays.equals(new short[] { (short) 1 }, (short[]) v.property("aShort").value()));
Assert.assertTrue(Arrays.equals(new int[] { 1 }, (int[]) v.property("aInteger").value()));
Assert.assertTrue(Arrays.equals(new long[] { 1L }, (long[]) v.property("aLong").value()));
Assert.assertTrue(Arrays.equals(new float[] { 1f }, (float[]) v.property("aFloat").value()));
Assert.assertTrue(Arrays.equals(new double[] { 1d }, (double[]) v.property("aDouble").value()));
Assert.assertTrue(Arrays.equals(new String[] { "aaaaaaaaaaaaa" }, (String[]) v.property("aString").value()));
}
try (SqlgGraph sqlgGraph = SqlgGraph.open(configuration)) {
Iterator<Vertex> iter = sqlgGraph.traversal().V().has(T.label, "Person");
Assert.assertTrue(iter.hasNext());
Vertex v = iter.next();
Assert.assertTrue(Arrays.equals(new boolean[] { true }, (boolean[]) v.property("aBoolean").value()));
Assert.assertTrue(Arrays.equals(new short[] { (short) 1 }, (short[]) v.property("aShort").value()));
Assert.assertTrue(Arrays.equals(new int[] { 1 }, (int[]) v.property("aInteger").value()));
Assert.assertTrue(Arrays.equals(new long[] { 1L }, (long[]) v.property("aLong").value()));
Assert.assertTrue(Arrays.equals(new float[] { 1f }, (float[]) v.property("aFloat").value()));
Assert.assertTrue(Arrays.equals(new double[] { 1d }, (double[]) v.property("aDouble").value()));
Assert.assertTrue(Arrays.equals(new String[] { "aaaaaaaaaaaaa" }, (String[]) v.property("aString").value()));
}
}
Aggregations