Skip to content

Commit 023c61d

Browse files
author
DvirDukhan
committed
removed closable exception
1 parent 9cb17d8 commit 023c61d

File tree

2 files changed

+19
-45
lines changed

2 files changed

+19
-45
lines changed

src/main/java/com/redislabs/redisgraph/RedisGraph.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.redislabs.redisgraph;
22

33
import java.io.Closeable;
4+
import java.io.IOException;
45
import java.util.List;
56
import java.util.Map;
67

@@ -49,4 +50,6 @@ public interface RedisGraph extends Closeable {
4950
*/
5051
String deleteGraph(String graphId);
5152

53+
@Override
54+
void close();
5255
}

src/test/java/com/redislabs/redisgraph/RedisGraphAPITest.java

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ public void createApi(){
3636
public void deleteGraph() {
3737

3838
api.deleteGraph("social");
39-
try {
40-
api.close();
41-
} catch (IOException e) {
42-
e.printStackTrace();
43-
}
39+
api.close();
4440
}
4541

4642

@@ -606,24 +602,21 @@ record = resultSet.next();
606602
Assert.assertFalse(resultSet.hasNext());
607603
Assert.assertEquals(Arrays.asList("label"), record.keys());
608604
Assert.assertEquals("Person", record.getValue("label"));
609-
} catch (IOException e) {
610-
e.printStackTrace();
611605
}
612606
}
613607

614608
@Test
615-
public void testContextedAPI(){
609+
public void testContextedAPI() {
616610

617611
String name = "roi";
618612
int age = 32;
619613
double doubleValue = 3.14;
620-
boolean boolValue = true;
614+
boolean boolValue = true;
621615

622616
String place = "TLV";
623617
int since = 2000;
624618

625619

626-
627620
Property nameProperty = new Property("name", ResultSet.ResultSetScalarTypes.PROPERTY_STRING, name);
628621
Property ageProperty = new Property("age", ResultSet.ResultSetScalarTypes.PROPERTY_INTEGER, age);
629622
Property doubleProperty = new Property("doubleValue", ResultSet.ResultSetScalarTypes.PROPERTY_DOUBLE, doubleValue);
@@ -654,7 +647,7 @@ public void testContextedAPI(){
654647
expectedEdge.addProperty(falseBooleanProperty);
655648
expectedEdge.addProperty(nullProperty);
656649

657-
try(RedisGraphContext c = api.getContext()) {
650+
try (RedisGraphContext c = api.getContext()) {
658651
Assert.assertNotNull(c.query("social", "CREATE (:person{name:%s',age:%d, doubleValue:%f, boolValue:%b, nullValue:null})", name, age, doubleValue, boolValue));
659652
Assert.assertNotNull(c.query("social", "CREATE (:person{name:'amit',age:30})"));
660653
Assert.assertNotNull(c.query("social", "MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') " +
@@ -704,18 +697,16 @@ public void testContextedAPI(){
704697
record.values());
705698

706699
Node a = record.getValue("a");
707-
for (String propertyName : expectedNode.getEntityPropertyNames()){
708-
Assert.assertEquals(expectedNode.getProperty(propertyName) ,a.getProperty(propertyName));
700+
for (String propertyName : expectedNode.getEntityPropertyNames()) {
701+
Assert.assertEquals(expectedNode.getProperty(propertyName), a.getProperty(propertyName));
709702
}
710703

711-
Assert.assertEquals( "roi", record.getString(2));
712-
Assert.assertEquals( "32", record.getString(3));
713-
Assert.assertEquals( 32L, ((Integer)(record.getValue(3))).longValue());
714-
Assert.assertEquals( 32L, ((Integer)record.getValue("a.age")).longValue());
715-
Assert.assertEquals( "roi", record.getString("a.name"));
716-
Assert.assertEquals( "32", record.getString("a.age"));
717-
} catch (IOException e) {
718-
e.printStackTrace();
704+
Assert.assertEquals("roi", record.getString(2));
705+
Assert.assertEquals("32", record.getString(3));
706+
Assert.assertEquals(32L, ((Integer) (record.getValue(3))).longValue());
707+
Assert.assertEquals(32L, ((Integer) record.getValue("a.age")).longValue());
708+
Assert.assertEquals("roi", record.getString("a.name"));
709+
Assert.assertEquals("32", record.getString("a.age"));
719710
}
720711
}
721712

@@ -733,18 +724,8 @@ public void testWriteTransactionWatch(){
733724
c2.query("social", "CREATE (:Person {name:'b'})");
734725
List<Object> returnValue = t1.exec();
735726
Assert.assertNull(returnValue);
736-
737-
try {
738-
c1.close();
739-
} catch (IOException e) {
740-
e.printStackTrace();
741-
}
742-
try {
743-
c2.close();
744-
} catch (IOException e) {
745-
e.printStackTrace();
746-
}
747-
727+
c1.close();
728+
c2.close();
748729
}
749730

750731
@Test
@@ -762,17 +743,7 @@ public void testReadTransactionWatch(){
762743
List<Object> returnValue = t1.exec();
763744

764745
Assert.assertNotNull(returnValue);
765-
766-
try {
767-
c1.close();
768-
} catch (IOException e) {
769-
e.printStackTrace();
770-
}
771-
try {
772-
c2.close();
773-
} catch (IOException e) {
774-
e.printStackTrace();
775-
}
776-
746+
c1.close();
747+
c2.close();
777748
}
778749
}

0 commit comments

Comments
 (0)