Announcement Announcement Module
Collapse
No announcement yet.
Unit testing spring data DAOs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unit testing spring data DAOs

    Hello,
    I would like to know if there are patterns or tips for unit testing spring data methods using the @Query annotation such as the one below (taken from a "spring data" dao interface):
    Code:
      @Modifying
      @Transactional
      @Query("UPDATE Account a SET a.accountActivated = true WHERE a.accountToken = ?1")
      int reactivateAccountFromToken(String accountToken);
    By unit testing I mean using some sort of mock maybe but not hitting the database of course.
    Regards,
    Julien.

  • #2
    Then what would you test not the query as that gets translated/converted by the EntityManager which you could mock but that doesn't give you much.

    I would create an integration test with maybe an in memory (H2, HSQLDB, Derby) database, but propably only for the complex queries the rest I would test with system tests.

    Comment


    • #3
      Thanks Marten

      Comment

      Working...
      X