-
Notifications
You must be signed in to change notification settings - Fork 427
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
Remove dependencies from tests that require additional libraries #729
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #729 +/- ##
============================================
- Coverage 48.03% 47.95% -0.09%
+ Complexity 2631 2629 -2
============================================
Files 118 118
Lines 26753 26753
Branches 4493 4493
============================================
- Hits 12852 12829 -23
- Misses 11773 11801 +28
+ Partials 2128 2123 -5
Continue to review full report at Codecov.
|
} else if (this.precision == 1) { | ||
randomNumeric = rnd.nextInt(10); | ||
} else { | ||
randomNumeric = (int) Math.pow(10, this.precision - 1) + rnd.nextInt((int) (9 * Math.pow(10, this.precision - 1))); |
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.
can we save this to a var so we don't have to call Math.pow(10, this.precision - 1) twice?
} else { | ||
randomNumeric = (int) Math.pow(10, this.scale - 1) + rnd.nextInt((int) (9 * Math.pow(10, this.scale - 1))); | ||
} | ||
|
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.
this is the same as above can we move this out to a method which generates n random digits?
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.
sure!
@@ -474,4 +472,11 @@ boolean passDataAsHex(int colNum) { | |||
return (JDBCType.BINARY == getColumn(colNum).getJdbctype() || JDBCType.VARBINARY == getColumn(colNum).getJdbctype() | |||
|| JDBCType.LONGVARBINARY == getColumn(colNum).getJdbctype()); |
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.
I know this didn't get changed, but would be better if we just do getColumn(colNum).getJdbctype() once
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.
cool, done
@@ -41,4 +42,22 @@ public SqlDateTime() { | |||
public Object createdata() { | |||
return new Timestamp(ThreadLocalRandom.current().nextLong(((Timestamp) minvalue).getTime(), ((Timestamp) maxvalue).getTime())); | |||
} | |||
|
|||
protected int generateRandomInt(int length) { |
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.
comment header? (applies to other places below)
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.
nah we don't need it
//Example of how this works: | ||
// if length is 3, then we add 100 + random number between 0~899, so that we get a random number between 100~999. | ||
int randomNumeric; | ||
if (length <= 0) { |
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.
nitpicking....
we normally do (0 >= blah) etc...
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.
i think that's only for comparing to null (for good reasons)
@@ -474,4 +472,11 @@ boolean passDataAsHex(int colNum) { | |||
return (JDBCType.BINARY == getColumn(colNum).getJdbctype() || JDBCType.VARBINARY == getColumn(colNum).getJdbctype() | |||
|| JDBCType.LONGVARBINARY == getColumn(colNum).getJdbctype()); | |||
} | |||
|
|||
private String byteArrayToHex(byte[] a) { |
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.
comment header?
Remove dependencies from tests that are from outside required libraries.
Replaced:
org.apache.commons.lang3.RandomStringUtils
org.apache.commons.codec.binary.Hex
org.apache.commons.codec.DecoderException;
And replaced with with other methods / java.util functions.