Commit a8ae9093 authored by Selvakumar Kamatchinathan's avatar Selvakumar Kamatchinathan
Browse files

add paging and sorting

parent d5279b25
......@@ -17,7 +17,7 @@
*/
package uk.ac.ebi.ampt2d.registry.repositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import uk.ac.ebi.ampt2d.registry.entities.Phenotype;
......@@ -25,7 +25,7 @@ import uk.ac.ebi.ampt2d.registry.entities.Phenotype;
import java.util.List;
@RepositoryRestResource
public interface PhenotypeRepository extends CrudRepository<Phenotype, String> {
public interface PhenotypeRepository extends PagingAndSortingRepository<Phenotype, String> {
List<Phenotype> findByPhenotypeGroup(@Param("phenotypeGroup") Phenotype.Group group);
......
......@@ -17,7 +17,7 @@
*/
package uk.ac.ebi.ampt2d.registry.repositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import uk.ac.ebi.ampt2d.registry.entities.Property;
......@@ -25,7 +25,7 @@ import uk.ac.ebi.ampt2d.registry.entities.Property;
import java.util.List;
@RepositoryRestResource
public interface PropertyRepository extends CrudRepository<Property, String> {
public interface PropertyRepository extends PagingAndSortingRepository<Property, String> {
List<Property> findByType(@Param("type") Property.Type type);
......
......@@ -221,4 +221,26 @@ public class PropertyRegistryServiceApplicationTests {
mockMvc.perform(get(location)).andExpect(status().isNotFound());
}
@Test
public void testPaging() throws Exception {
String content1 = "{\"id\":\"CALL_RATE\"," +
"\"type\":\"FLOAT\"," +
"\"meaning\":\"CALL_RATE\"," +
"\"description\":\"calling rate\"}";
postTestEntity("/properties", content1);
String content2 = "{\"id\":\"MAF\"," +
"\"type\":\"FLOAT\"," +
"\"meaning\":\"MAF\"," +
"\"description\":\"MAF\"}";
postTestEntity("/properties", content2);
mockMvc.perform(get("/properties?size=1")).andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.properties.length()").value(1));
mockMvc.perform(get("/properties?size=2")).andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.properties.length()").value(2));
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment