0

I am stuck with update test for my DAO. Update method works just fine, but at the end I get an exception:

junit.framework.ComparisonFailure: value (table=theme, row=0, col=Id) expected:<[1]> but was:<[97]>

Here is my Test:

@Test
@DatabaseSetup("/ThemeData.xml")
@DatabaseTearDown("/clear.xml")
@ExpectedDatabase(value = "/ExpectedThemeData.xml", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED)
public void testThemeUpdate(){
    String newDescription = "Childhood";
    String oldDescription = "Sport";
    Theme th = new Theme("Sport");

    th.setDescription(newDescription);
    int affectedRows = themeDAO.update(th, oldDescription);

    System.out.println(th);

    assertEquals(1, affectedRows);
}

And here is dataSets. ThemeData.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
   <!--News Table -->
   <THEME Id="1" Description="Sport"/>
   <THEME Id="2" Description="Cinema"/>
   <THEME Id="3" Description="Politics"/>
</dataset>

ExpectedThemeData.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
   <!--News Table -->
   <THEME Id="1" Description="Childhood"/>
   <THEME Id="2" Description="Cinema"/>
   <THEME Id="3" Description="Politics"/>
</dataset>
Alexander Tolkachev
  • 227
  • 1
  • 4
  • 15

1 Answers1

0

Probably your id value is auto-incremental and what you are doing is a new insert. You have to find the row by id and then modify it. Check the rows after the update in your DB.