Skip to content

Create trait for BaseIdRepository #39

@nagirrab

Description

@nagirrab

Hi,

would it be possible to make it such that the BaseIdRepository class implements some kind of trait which includes all the methods not in BaseIdQueries (e.g. findAll, deleteAll)? I am looking to use a cake pattern to allow easy mocking of the repositories for testing and it would be significantly easier if I could refactor them to be used as follows:

   trait UserRepositoryComponent {
     def userRepository: UserRepository

     trait UserRepository extends BaseIdRepository[User,...]
   }
   trait PostgresUserRepositoryComponent {
     val userRepository = new PostgresUserRepository
     class PostgresUserRepository extends BaseIdRepositoryImpl[User,...]
   }
   trait TestUserRepositoryComponent {
     val userRepository = mock[UserRepository]
   }

It seems cleaner to mock the trait than having to mock the final class instead.

What do you think? I'm happy to work on a PR for this if you think it acceptable.

Cheers,
Hugh

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions