### Question:
JpaWidgetRepository implements WidgetRepository { @Override public int getCountByStatusAndTypeAndFreeText(WidgetStatus widgetStatus, String type, String searchTerm) { final CriteriaBuilder cb = manager.getCriteriaBuilder(); final CriteriaQuery<Long> query = cb.createQuery(Long.class); final Root<JpaWidget> widgetType = query.from(JpaWidget.class); query.select(cb.count(widgetType)); query.where(getStatusAndTypeAndFreeTextPredicates(cb, widgetType, widgetStatus, type, searchTerm)); final Long countResult = manager.createQuery(query).getSingleResult(); return countResult.intValue(); }  @Override List<Widget> getAll(); @Override List<Widget> getLimitedList(int offset, int pageSize); @Override int getCountAll(); @Override List<Widget> getByFreeTextSearch(String searchTerm, int offset, int pageSize); @Override int getCountFreeTextSearch(String searchTerm); @Override List<Widget> getByStatus(WidgetStatus widgetStatus, int offset, int pageSize); @Override int getCountByStatus(WidgetStatus widgetStatus); @Override List<Widget> getByStatusAndTypeAndFreeTextSearch(WidgetStatus widgetStatus, String type, String searchTerm,
                                                            int offset, int pageSize); @Override int getCountByStatusAndTypeAndFreeText(WidgetStatus widgetStatus, String type, String searchTerm); @Override List<Widget> getByOwner(User owner, int offset, int pageSize); @Override int getCountByOwner(User owner, int offset, int pageSize); @Override JpaWidget getByUrl(String widgetUrl); @Override WidgetStatistics getWidgetStatistics(String widget_id, String user_id); @Override Map<String, WidgetRating> getUsersWidgetRatings(String user_id); @SuppressWarnings("unchecked") @Override Map<String, WidgetStatistics> getAllWidgetStatistics(String userId); @Override List<Widget> getWidgetsByTag(String tagKeyword, int offset, int pageSize); @Override int getCountByTag(String tagKeyword); @Override int unassignWidgetOwner(String userId); @Override Class<? extends Widget> getType(); @Override Widget get(String id); @Override Widget save(Widget item); @Override void delete(Widget item); @Override WidgetTag getTagByWidgetIdAndKeyword(String widgetId, String keyword); @Override WidgetTag getTagById(String widgetTagId); @Override WidgetTag saveWidgetTag(String widgetId, WidgetTag tag); @Override void deleteWidgetTag(WidgetTag tag); @Override WidgetComment getCommentById(String widgetId, String widgetCommentId); @Override WidgetComment createWidgetComment(String widgetId, WidgetComment comment); @Override WidgetComment updateWidgetComment(String widgetId, WidgetComment comment); @Override void deleteWidgetComment(String widgetId, WidgetComment comment); @Override int deleteAllWidgetComments(String userId); @Override WidgetRating getRatingById(String widgetId, String widgetRatingId); @Override WidgetRating createWidgetRating(String widgetId, WidgetRating rating); @Override WidgetRating updateWidgetRating(String widgetId, WidgetRating rating); @Override void deleteWidgetRating(String widgetId, WidgetRating rating); @Override WidgetRating getWidgetRatingsByWidgetIdAndUserId(String widgetId, String userId); @Override int deleteAllWidgetRatings(String userId);  }### Answer:
@Test public void countByStatusAndTypeAndFreeText() { final String searchTerm = "gAdGet"; final String type = "OpenSocial"; int publishedCount = repository.getCountByStatusAndTypeAndFreeText(WidgetStatus.PUBLISHED, type, searchTerm); assertTrue(publishedCount >= 2); }