Skip to content

Commit c1b604a

Browse files
committed
Added tests and removed unused internal methods to improve test coverage.
1 parent d318531 commit c1b604a

File tree

7 files changed

+53
-29
lines changed

7 files changed

+53
-29
lines changed

driver/src/main/java/org/neo4j/driver/v1/GraphDatabase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class GraphDatabase
3434
*/
3535
public static Driver driver( String url )
3636
{
37-
return driver( URI.create( url ) );
37+
return driver( url, Config.defaultConfig() );
3838
}
3939

4040
/**

driver/src/main/java/org/neo4j/driver/v1/Records.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
*/
2626
public abstract class Records
2727
{
28-
private Records()
29-
{
30-
throw new UnsupportedOperationException();
31-
}
32-
3328
public static Function<RecordAccessor, Record> recordAsIs()
3429
{
3530
return RECORD;

driver/src/main/java/org/neo4j/driver/v1/exceptions/DatabaseException.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
*/
2525
public class DatabaseException extends Neo4jException
2626
{
27-
public DatabaseException( String message )
28-
{
29-
super( message );
30-
}
31-
3227
public DatabaseException( String code, String message )
3328
{
3429
super( code, message );

driver/src/main/java/org/neo4j/driver/v1/exceptions/TransientException.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
*/
2525
public class TransientException extends Neo4jException
2626
{
27-
public TransientException( String message )
28-
{
29-
super( message );
30-
}
31-
3227
public TransientException( String code, String message )
3328
{
3429
super( code, message );

driver/src/test/java/org/neo4j/driver/internal/ConfigTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
*/
1919
package org.neo4j.driver.internal;
2020

21-
import java.io.File;
22-
2321
import org.junit.Test;
2422

23+
import java.io.File;
24+
2525
import org.neo4j.driver.v1.Config;
2626

27+
import static org.hamcrest.CoreMatchers.equalTo;
2728
import static org.junit.Assert.assertEquals;
2829
import static org.junit.Assert.assertFalse;
30+
import static org.junit.Assert.assertThat;
2931
import static org.junit.Assert.assertTrue;
3032

3133
public class ConfigTest
@@ -76,6 +78,16 @@ public void shouldChangeToTrustedCert()
7678
assertEquals( trustedCert.getAbsolutePath(), authConfig.certFile().getAbsolutePath() );
7779
}
7880

81+
@Test
82+
public void shouldConfigureMinIdleTime() throws Throwable
83+
{
84+
// when
85+
Config config = Config.build().withMinIdleTimeBeforeConnectionTest( 1337 ).toConfig();
86+
87+
// then
88+
assertThat( config.idleTimeBeforeConnectionTest(), equalTo( 1337l ));
89+
}
90+
7991
public static void deleteDefaultKnownCertFileIfExists()
8092
{
8193
if( DEFAULT_KNOWN_CERTS.exists() )

driver/src/test/java/org/neo4j/driver/internal/ValuesTest.java

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
*/
1919
package org.neo4j.driver.internal;
2020

21+
import org.junit.Rule;
22+
import org.junit.Test;
23+
import org.junit.rules.ExpectedException;
24+
2125
import java.util.HashMap;
2226
import java.util.HashSet;
2327
import java.util.Iterator;
2428
import java.util.List;
2529
import java.util.Map;
2630
import java.util.Set;
2731

28-
import org.junit.Rule;
29-
import org.junit.Test;
30-
import org.junit.rules.ExpectedException;
31-
3232
import org.neo4j.driver.internal.value.ListValue;
3333
import org.neo4j.driver.internal.value.MapValue;
3434
import org.neo4j.driver.internal.value.StringValue;
@@ -40,7 +40,6 @@
4040
import static org.hamcrest.MatcherAssert.assertThat;
4141
import static org.junit.Assert.assertEquals;
4242
import static org.junit.Assert.assertNotEquals;
43-
4443
import static org.neo4j.driver.v1.Values.value;
4544
import static org.neo4j.driver.v1.Values.valueAsList;
4645
import static org.neo4j.driver.v1.Values.valueToString;
@@ -160,4 +159,34 @@ public void shouldMapDriverMapsToJavaMaps() throws Throwable
160159
assertThat( result.get( "Dog" ), equalTo( "2" ) );
161160
assertThat( result.get( "Cat" ), equalTo( "1" ) );
162161
}
162+
163+
@Test
164+
public void shouldNotBeAbleToGetKeysFromNonKeyedValue() throws Throwable
165+
{
166+
// expect
167+
exception.expect( ClientException.class );
168+
169+
// when
170+
value( "asd" ).get(1);
171+
}
172+
173+
@Test
174+
public void shouldNotBeAbleToDoCrazyCoercions() throws Throwable
175+
{
176+
// expect
177+
exception.expect( ClientException.class );
178+
179+
// when
180+
value(1).asPath();
181+
}
182+
183+
@Test
184+
public void shouldNotBeAbleToGetSizeOnNonSizedValues() throws Throwable
185+
{
186+
// expect
187+
exception.expect( ClientException.class );
188+
189+
// when
190+
value(1).size();
191+
}
163192
}

driver/src/test/java/org/neo4j/driver/internal/pool/InternalConnectionPoolTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,20 @@
1818
*/
1919
package org.neo4j.driver.internal.pool;
2020

21-
import java.net.URI;
22-
import java.util.Collections;
23-
2421
import org.junit.Rule;
2522
import org.junit.Test;
2623
import org.junit.rules.ExpectedException;
2724

25+
import java.net.URI;
26+
import java.util.Collections;
27+
2828
import org.neo4j.driver.internal.spi.Connection;
2929
import org.neo4j.driver.internal.spi.Connector;
3030
import org.neo4j.driver.internal.util.Clock;
3131
import org.neo4j.driver.v1.Config;
3232
import org.neo4j.driver.v1.exceptions.ClientException;
3333

3434
import static java.util.Collections.singletonList;
35-
3635
import static org.mockito.Matchers.any;
3736
import static org.mockito.Mockito.mock;
3837
import static org.mockito.Mockito.times;
@@ -47,10 +46,9 @@ public class InternalConnectionPoolTest
4746
public ExpectedException exception = ExpectedException.none();
4847

4948
@Test
50-
public void shouldThrowExceptionWhenConnectionPoolIsFullWhatever() throws Throwable
49+
public void shouldThrowExceptionWhenConnectionPoolIsFull() throws Throwable
5150
{
5251
// Given
53-
5452
URI uri = URI.create( "bolt://asd" );
5553
Connector connector = connector( "bolt" );
5654
Config config = Config.build().withConnectionPoolSize( 1 ).toConfig();

0 commit comments

Comments
 (0)