Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-1809

@ShouldMatchDataSet is broken when ordering by non-string columns

    XMLWordPrintable

Details

    Description

      Steps to reproduce:

      1. Create a table, "test", with a single column, an integer primary key, "id".
      2. Try the following test case under the persistence extension:

      @UsingDataSet({test.yml})
      @ShouldMatchDataSet(value={test.yml})
      @Test
      public void test() {
          // do nothing
      }
      
      test.yml
      test:
        - id: -1
        - id: -2
      

      Result: test fails like so:

      java.lang.AssertionError: Test failed in 2 cases. 
      test | In row 0: expected value of id "-1" but was "-2".
      test | In row 1: expected value of id "-2" but was "-1".
      

      Reason:

      The expected dataset is loaded by the YamlDataSetProducer, and has all of its column types set to UNKNOWN.

      The actual dataset is loaded by <whatever>, and has all of its column types set to their actual types in the database.

      DataSetComparator wraps each dataset in a SortedTable, to provide a consistent row ordering for comparison.

      SortedTable ends up sorting every column of the expected dataset as strings, because the column types are UNKNOWN, but it sorts the actual dataset columns using their actual column types, e.g. numeric sort in the test case above.

      As a result, the rows of the expected and actual datasets are not consistently sorted for comparison, which results in totally inaccurate comparison results.

      Suggested Fix:

      The expected dataset needs to have accurate column types assigned, not UNKNOWN.

      Attachments

        Activity

          People

            bartosz-1 Bartosz Majsak
            doddio Steven Dodd (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: