Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-4710

Refactor DummyInternalVersion in VersionIteratorImplTest.java to improve test logic

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • None
    • None
    • jackrabbit-core

    Description

      Description

      I noticed that there is a test class DummyInternalVersion implements a production interface InternalVersion to assist testing production constructor VersionIteratorImpl::VersionIteratorImpl(Session, InternalVersion). This might not be the best priactice in unit testing and can be improved by leveraging mocking frameworks.

      Current Implementation

      • DummyInternalVersion implements InternalVersion, creates two variables id and successors to control the behavior of method getId() and getSuccessors().
      • Impelements other redundant methods and make them return null.

      Proposed Implementation

      • Replace DummyInternalVersion with a mocking object created by Mockito.
      • Use method stub to control the behavior of getId() and getSuccessors() in the mocking object.
      • Ignore the redundant methods to make test logic more clear.
      • Create a method to return the mocking object for reuse purpose.

      Motivation

      • Decoupling test class DummyInternalVersion from production interface InternalVersion.
      • Making test condition more clear by removing all redundant overridden methods.
      • Making test logic more clear by using method stub instead of method overriding.

      Attachments

        Activity

          People

            Unassigned Unassigned
            wx930910 Xiao Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified