### Question:
WishlistMovieRepository extends CrudRepository<WishlistMovieDao, WishlistMovie> { public WishlistMovie findByTmdbId(long movieId) { Query<WishlistMovie> wishlistMovieQuery = dao.queryBuilder() .where(WishlistMovieDao.Properties.Tmdb_id.eq(movieId)) .limit(1) .build(); List<WishlistMovie> wishlistMovies = wishlistMovieQuery.list(); return wishlistMovies != null && wishlistMovies.size() > 0 ? wishlistMovies.get(0) : null; } WishlistMovieRepository(DaoSession daoSession); WishlistMovie findByTmdbId(long movieId);  }### Answer:
@Test public void findByMovieId() { QueryBuilder queryBuilder = mock(QueryBuilder.class); doReturn(queryBuilder).when(wishlistMovieDao).queryBuilder(); doReturn(queryBuilder).when(queryBuilder).where(any(WhereCondition.class)); doReturn(queryBuilder).when(queryBuilder).limit(1); Query query = mock(Query.class); doReturn(query).when(queryBuilder).build(); doReturn(Collections.singletonList(wishlistMovie)).when(query).list(); assertEquals( wishlistMovie, new WishlistMovieRepository(daoSession).findByTmdbId(45) ); }