-
Notifications
You must be signed in to change notification settings - Fork 20
increase code coverage #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gkorland
wants to merge
7
commits into
master
Choose a base branch
from
code_coverage_increase
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fc6a9a3
increase code coverage
gkorland 3f69a0e
add test to record.containsKey
gkorland dc11503
Extend the Edge tests coverage
gkorland 4243cf6
add Edge.toString() test
gkorland 71da3f0
Cover StatisticsImpl toString()
gkorland 983b9f3
Refactor code
gkorland b33aed1
Merge branch 'master' into code_coverage_increase
gkorland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,136 +6,190 @@ | |
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import java.util.HashMap; | ||
|
||
|
||
public class JRedisGraphErrorTest { | ||
|
||
private RedisGraphContextGenerator api; | ||
|
||
@Before | ||
public void createApi(){ | ||
api = new RedisGraph(); | ||
Assert.assertNotNull(api.query("social", "CREATE (:person{mixed_prop: 'strval'}), (:person{mixed_prop: 50})")); | ||
private RedisGraphContextGenerator api; | ||
|
||
@Before | ||
public void createApi(){ | ||
api = new RedisGraph(); | ||
Assert.assertNotNull(api.query("social", "CREATE (:person{mixed_prop: 'strval'}), (:person{mixed_prop: 50})")); | ||
} | ||
@After | ||
public void deleteGraph() { | ||
|
||
api.deleteGraph("social"); | ||
api.close(); | ||
} | ||
|
||
@Test | ||
public void testExceptions() { | ||
try { | ||
throw new JRedisGraphCompileTimeException("Test message 1"); | ||
}catch (JRedisGraphCompileTimeException e) { | ||
Assert.assertEquals( "Test message 1", e.getMessage()); | ||
} | ||
@After | ||
public void deleteGraph() { | ||
|
||
api.deleteGraph("social"); | ||
api.close(); | ||
Exception cause = new IndexOutOfBoundsException("Index Error"); | ||
try { | ||
throw new JRedisGraphCompileTimeException("Test message 2", cause); | ||
}catch (JRedisGraphCompileTimeException e) { | ||
Assert.assertEquals( "Test message 2", e.getMessage()); | ||
Assert.assertEquals( cause, e.getCause()); | ||
} | ||
|
||
@Rule | ||
public ExpectedException exceptionRule = ExpectedException.none(); | ||
|
||
@Test | ||
public void testSyntaxErrorReporting() { | ||
exceptionRule.expect(JRedisGraphCompileTimeException.class); | ||
exceptionRule.expectMessage("Type mismatch: expected String but was Integer"); | ||
try { | ||
throw new JRedisGraphCompileTimeException(cause); | ||
}catch (JRedisGraphCompileTimeException e) { | ||
Assert.assertEquals( "java.lang.IndexOutOfBoundsException: Index Error", e.getMessage()); | ||
Assert.assertEquals( cause, e.getCause()); | ||
} | ||
|
||
try { | ||
throw new JRedisGraphRunTimeException("Test message 3"); | ||
}catch (JRedisGraphRunTimeException e) { | ||
Assert.assertEquals( "Test message 3", e.getMessage()); | ||
} | ||
|
||
// Issue a query that causes a compile-time error | ||
api.query("social", "RETURN toUpper(5)"); | ||
try { | ||
throw new JRedisGraphRunTimeException("Test message 4", cause); | ||
}catch (JRedisGraphRunTimeException e) { | ||
Assert.assertEquals( "Test message 4", e.getMessage()); | ||
Assert.assertEquals( cause, e.getCause()); | ||
} | ||
|
||
try { | ||
throw new JRedisGraphRunTimeException(cause); | ||
}catch (JRedisGraphRunTimeException e) { | ||
Assert.assertEquals( "java.lang.IndexOutOfBoundsException: Index Error", e.getMessage()); | ||
Assert.assertEquals( cause, e.getCause()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testSyntaxErrorReporting() { | ||
try { | ||
// Issue a query that causes a compile-time error | ||
api.query("social", "RETURN toUpper(5)"); | ||
} catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass()); | ||
Assert.assertEquals( "redis.clients.jedis.exceptions.JedisDataException: Type mismatch: expected String but was Integer", e.getMessage()); | ||
Comment on lines
+75
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you use juint 5 for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are not using Junit 5 |
||
} | ||
|
||
@Test | ||
public void testRuntimeErrorReporting() { | ||
exceptionRule.expect(JRedisGraphRunTimeException.class); | ||
exceptionRule.expectMessage("Type mismatch: expected String but was Integer"); | ||
} | ||
|
||
// Issue a query that causes a run-time error | ||
api.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
@Test | ||
public void testRuntimeErrorReporting() { | ||
try { | ||
// Issue a query that causes a run-time error | ||
api.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
} catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertEquals( "redis.clients.jedis.exceptions.JedisDataException: Type mismatch: expected String but was Integer", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testExceptionFlow() { | ||
|
||
try { | ||
// Issue a query that causes a compile-time error | ||
api.query("social", "RETURN toUpper(5)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
@Test | ||
public void testExceptionFlow() { | ||
|
||
// On general api usage, user should get a new connection | ||
try { | ||
// Issue a query that causes a compile-time error | ||
api.query("social", "RETURN toUpper(5)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
|
||
try { | ||
// Issue a query that causes a compile-time error | ||
api.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
// On general api usage, user should get a new connection | ||
|
||
try { | ||
// Issue a query that causes a compile-time error | ||
api.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
|
||
} | ||
|
||
@Test | ||
public void testContextSyntaxErrorReporting() { | ||
exceptionRule.expect(JRedisGraphCompileTimeException.class); | ||
exceptionRule.expectMessage("Type mismatch: expected String but was Integer"); | ||
RedisGraphContext c = api.getContext(); | ||
|
||
// Issue a query that causes a compile-time error | ||
c.query("social", "RETURN toUpper(5)"); | ||
|
||
@Test | ||
public void testContextSyntaxErrorReporting() { | ||
RedisGraphContext c = api.getContext(); | ||
try { | ||
// Issue a query that causes a compile-time error | ||
c.query("social", "RETURN toUpper(5)"); | ||
} catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass()); | ||
Assert.assertEquals( "redis.clients.jedis.exceptions.JedisDataException: Type mismatch: expected String but was Integer", e.getMessage()); | ||
} | ||
|
||
@Test | ||
public void testMissingParametersSyntaxErrorReporting(){ | ||
exceptionRule.expect(JRedisGraphRunTimeException.class); | ||
exceptionRule.expectMessage("Missing parameters"); | ||
api.query("social","RETURN $param"); | ||
} | ||
|
||
@Test | ||
public void testMissingParametersSyntaxErrorReporting(){ | ||
try { | ||
api.query("social","RETURN $param"); | ||
} catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertEquals( "redis.clients.jedis.exceptions.JedisDataException: Missing parameters", e.getMessage()); | ||
} | ||
|
||
@Test | ||
public void testMissingParametersSyntaxErrorReporting2(){ | ||
exceptionRule.expect(JRedisGraphRunTimeException.class); | ||
exceptionRule.expectMessage("Missing parameters"); | ||
api.query("social","RETURN $param", new HashMap<>()); | ||
} | ||
|
||
@Test | ||
public void testMissingParametersSyntaxErrorReporting2(){ | ||
try { | ||
api.query("social","RETURN $param", new HashMap<>()); | ||
} catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertEquals( "redis.clients.jedis.exceptions.JedisDataException: Missing parameters", e.getMessage()); | ||
} | ||
|
||
@Test | ||
public void testContextRuntimeErrorReporting() { | ||
exceptionRule.expect(JRedisGraphRunTimeException.class); | ||
exceptionRule.expectMessage("Type mismatch: expected String but was Integer"); | ||
|
||
RedisGraphContext c = api.getContext(); | ||
// Issue a query that causes a run-time error | ||
c.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
} | ||
|
||
@Test | ||
public void testContextRuntimeErrorReporting() { | ||
|
||
RedisGraphContext c = api.getContext(); | ||
try { | ||
// Issue a query that causes a run-time error | ||
c.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
} catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertEquals( "redis.clients.jedis.exceptions.JedisDataException: Type mismatch: expected String but was Integer", e.getMessage()); | ||
} | ||
} | ||
|
||
|
||
@Test | ||
public void testContextExceptionFlow() { | ||
|
||
RedisGraphContext c = api.getContext(); | ||
try { | ||
// Issue a query that causes a compile-time error | ||
c.query("social", "RETURN toUpper(5)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
@Test | ||
public void testContextExceptionFlow() { | ||
|
||
// On contexted api usage, connection should stay open | ||
RedisGraphContext c = api.getContext(); | ||
try { | ||
// Issue a query that causes a compile-time error | ||
c.query("social", "RETURN toUpper(5)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphCompileTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
|
||
try { | ||
// Issue a query that causes a compile-time error | ||
c.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
// On contexted api usage, connection should stay open | ||
|
||
try { | ||
// Issue a query that causes a compile-time error | ||
c.query("social", "MATCH (p:person) RETURN toUpper(p.mixed_prop)"); | ||
} | ||
catch (Exception e) { | ||
Assert.assertEquals(JRedisGraphRunTimeException.class, e.getClass()); | ||
Assert.assertTrue( e.getMessage().contains("Type mismatch: expected String but was Integer")); | ||
} | ||
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to a different unit test file. break every functionality to test case