From b55c3848c2ccc13c94990b0cd32b7fc88d780a67 Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Wed, 8 Aug 2018 09:32:34 +0300 Subject: [PATCH] Remove deleteGraph and added flashDB directly in the test --- .../com/redislabs/redisgraph/RedisGraphAPI.java | 7 ------- .../redislabs/redisgraph/RedisGraphAPITest.java | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/redislabs/redisgraph/RedisGraphAPI.java b/src/main/java/com/redislabs/redisgraph/RedisGraphAPI.java index 3cc68e7..ccac748 100644 --- a/src/main/java/com/redislabs/redisgraph/RedisGraphAPI.java +++ b/src/main/java/com/redislabs/redisgraph/RedisGraphAPI.java @@ -48,13 +48,6 @@ public ResultSet query(String query) { } } - /** - * Delete the Graph (Current implementation flush the all DB) - */ - public void deleteGraph() { - _conn().flushDB(); - } - private BinaryClient sendCommand(Jedis conn, ProtocolCommand provider, String ...args) { BinaryClient client = conn.getClient(); client.sendCommand(provider, args); diff --git a/src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java b/src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java index b48d902..f039852 100644 --- a/src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java +++ b/src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java @@ -1,11 +1,15 @@ package com.redislabs.redisgraph; +import java.lang.reflect.Method; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.redislabs.redisgraph.Statistics.Label; +import redis.clients.jedis.Jedis; + public class RedisGraphAPITest { RedisGraphAPI api; @@ -14,15 +18,18 @@ public RedisGraphAPITest() { } @Before - public void flushDB() { - api.deleteGraph(); + public void flushDB() throws Exception{ + // api.deleteGraph(); - TODO add this back once we implement this API + + Method method = RedisGraphAPI.class.getDeclaredMethod("_conn"); + method.setAccessible(true); + ((Jedis)method.invoke(api)).flushDB(); } - @Test public void testCreateNode() throws Exception { // Create a node - ResultSet result = api.query("CREATE ({name:\"roi\",age:32})"); + ResultSet result = api.query("CREATE ({name:'roi',age:32})"); Assert.assertFalse(result.hasNext()); Assert.assertEquals(1, result.getStatistics().nodesCreated()); @@ -36,7 +43,7 @@ public void testCreateNode() throws Exception { @Test public void testCreateLabeledNode() throws Exception { // Create a node with a label - ResultSet result = api.query("CREATE (:human{name:\"danny\",age:12})"); + ResultSet result = api.query("CREATE (:human{name:'danny',age:12})"); Assert.assertFalse(result.hasNext()); Assert.assertEquals("1", result.getStatistics().getStringValue(Label.NODES_CREATED));