@Test public void testCustomQueries() { // Named Query from named-queries.properties List<Product> products = repo.findByNameOrCategory(SOLR_STRING, sortByIdDesc()); Assert.assertEquals(1, products.size()); // Method Name Query test for findByPopularityGreaterThanEqual() Product product = SolrTestUtils.createProduct(PRODUCT_ID); repo.save(product); Page<Product> popularProducts = repo.findByPopularityGreaterThanEqual(10000, new PageRequest(0, 10)); Assert.assertEquals(1, popularProducts.getTotalElements()); Assert.assertEquals(Integer.toString(PRODUCT_ID), popularProducts.getContent().get(0).getId()); }
@Override public Page<Product> getProductsByPopularity(int popularity) { logger.debug("Using JPA Method Name Query - findByPopularityGreaterThanEqual()"); return productRepo.findByPopularityGreaterThanEqual(popularity, new PageRequest(0, 10)); }