question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regex support with 'CompareOperation.CONTAINS' on expected datasets

See original GitHub issue

In my test case I’m declaring

  @Test
  @ExpectedDataSet(
      value = "dataset/expecteddata.yml",
      compareOperation = CompareOperation.CONTAINS)
  void myTest() {
    ...
  }

When running the test I got the following exception:

...
13:28:01.295 [main] DEBUG org.dbunit.dataset.FilteredTableMetaData - getFilteredColumns(tableName=myschema.mytable, columns=[(pse_id, BIGINT, noNulls)], columnFilter=org.dbunit.dataset.filter.DefaultColumnFilter[_includeMatcher=org.dbunit.dataset.filter.PatternMatcher[_acceptedNames=[STATUS, MANDATE, OPERATION, OBJECT_TYPE, PAYLOAD, OBJECT_BK], _acceptedPatterns=[]], _excludeMatcher=org.dbunit.dataset.filter.PatternMatcher[_acceptedNames=[], _acceptedPatterns=[]]]) - start
13:28:01.295 [main] DEBUG org.dbunit.dataset.filter.DefaultColumnFilter - accept(tableName=myschema.mytable, column=(pse_id, BIGINT, noNulls)) - start
13:28:01.295 [main] DEBUG org.dbunit.dataset.filter.PatternMatcher - isEmpty() - start
13:28:01.295 [main] DEBUG org.dbunit.dataset.filter.PatternMatcher - accept(name=pse_id) - start
13:28:01.295 [main] DEBUG org.dbunit.dataset.ColumnFilterTable - getTableMetaData() - start


java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

	at com.github.database.rider.core.dataset.DataSetExecutorImpl.filterTableByPrimaryKey(DataSetExecutorImpl.java:927)
	at com.github.database.rider.core.dataset.DataSetExecutorImpl.compareCurrentDataSetWith(DataSetExecutorImpl.java:917)
	at com.github.database.rider.core.RiderRunner.performDataSetComparison(RiderRunner.java:165)
	at com.github.database.rider.core.RiderRunner.runAfterTest(RiderRunner.java:80)
	at com.github.database.rider.junit5.DBUnitExtension.afterTestExecution(DBUnitExtension.java:85)
  ...
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

After a bit debugging, I found that I must add the primary key column to the expected data set. Because I can’t know the actual Id’s in advance, I added a regex pattern:

myschema.mytable:
- pse_id: regex:\d+
  some_field: ...

while ‘pse_id’ is my primary column of type BIGINT.

But now I get a TypeCastException - almost at the same location: DataSetExecutorImpl.java:931

org.dbunit.dataset.datatype.TypeCastException: Unable to typecast value <regex:\d+> of type <java.lang.String> to BIGINT

	at org.dbunit.dataset.datatype.BigIntegerDataType.typeCast(BigIntegerDataType.java:88)
	at com.github.database.rider.core.dataset.DataSetExecutorImpl.filterTableByPrimaryKey(DataSetExecutorImpl.java:931)
	at com.github.database.rider.core.dataset.DataSetExecutorImpl.compareCurrentDataSetWith(DataSetExecutorImpl.java:917)
	at com.github.database.rider.core.RiderRunner.performDataSetComparison(RiderRunner.java:165)
	at com.github.database.rider.core.RiderRunner.runAfterTest(RiderRunner.java:80)
	at com.github.database.rider.junit5.DBUnitExtension.afterTestExecution(DBUnitExtension.java:85)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAfterTestExecutionCallbacks$8(TestMethodTestDescriptor.java:221)
  ...
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.NumberFormatException: Character r is neither a decimal digit number, decimal point, nor "e" notation exponential mark.
	at java.base/java.math.BigDecimal.<init>(BigDecimal.java:518)
	at java.base/java.math.BigDecimal.<init>(BigDecimal.java:401)
	at java.base/java.math.BigDecimal.<init>(BigDecimal.java:834)
	at org.dbunit.dataset.datatype.BigIntegerDataType.typeCast(BigIntegerDataType.java:84)
	... 110 more

Did anyone else encounter the same issue? Is there a solution or a known workaround - except using CompareOperation.EQUAL (which bloats the data set in my case)?

Thanks in advance!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
phloxcommented, Dec 16, 2019

Thanks a lot for your answers and efforts. I’ll checkout and test asap.

0reactions
rmpestanocommented, Jun 19, 2020

Hi Daniel, no worries, happy it worked!

On Thu, Jun 18, 2020 at 7:06 PM Daniel notifications@github.com wrote:

sorry for not answering earlier - your fix is working fine - thanks a lot

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/database-rider/database-rider/issues/162#issuecomment-646180314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMEXUMCXYD4VHK7HY4E3YDRXJCSXANCNFSM4JPGIKVQ .

[image: Mobiquity-Logo-blue 100w.png]

Rafael Pestano

Backend Developer

T: +31 20 40 43 982

Tommaso Albinonistraat 9

1083 HM, Amsterdam

The Netherlands

Web http://mobiquityinc.com/ | Twitter https://twitter.com/mobiquityincEU | Facebook https://www.facebook.com/MobiquityAMS/ | LinkedIn https://www.linkedin.com/company/mobiquity-inc-europe/ | YouTube https://www.youtube.com/user/Mobiquityinc

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rafael Pestano on Twitter: "Database Rider v1.9.0, your persistence ...
Release notes Regex support with 'CompareOperation.CONTAINS' on expected datasets (#162 and #169) JUnit 5 module should not dependent on Junit4 (#168) Rider ...
Read more >
How to efficiently match regular expressions in a large dataset ...
I have almost 750 regular expressions to match against the Google BigQuery GitHub Public Dataset. At first, I was writing the query as...
Read more >
Everything you need to know about Regular Expressions
After reading this article you will have a solid understanding of what regular expressions are, what they can do, and what they can't...
Read more >
Component Reference - Apache JMeter - User's Manual
CSV Data Set Config; FTP Request Defaults; DNS Cache Manager; HTTP Authorization Manager ... However the Java sampler only supports slow HTTPS connections....
Read more >
US11232100B2 - Resource allocation for multiple datasets - Google ...
One dataset source can include indexers that index and store data. ... 29 is a flow diagram illustrating a timeline mechanism that supports...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found