### Question:
LocalKinoRepository extends CrudRepository<LocalKinoDao, LocalKino> { public LocalKino findByMovieId(long movieId) { Query<LocalKino> localKinoQuery = dao.queryBuilder() .where(LocalKinoDao.Properties.Tmdb_id.eq(movieId)) .limit(1) .build(); List<LocalKino> localKinos = localKinoQuery.list(); return localKinos != null && localKinos.size() > 0 ? localKinos.get(0) : null; } LocalKinoRepository(DaoSession daoSession); LocalKino findByMovieId(long movieId); List<LocalKino> findAllByRating(boolean asc); List<LocalKino> findAllByYear(boolean asc); List<LocalKino> findAllByReviewDate(boolean asc); List<LocalKino> findAllByTitle(final boolean asc);  }### Answer:
@Test public void findByMovieId() { QueryBuilder queryBuilder = mock(QueryBuilder.class); doReturn(queryBuilder).when(localKinoDao).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(Arrays.asList(localKino)).when(query).list(); assertEquals( localKino, new LocalKinoRepository(daoSession).findByMovieId(45) ); }