Unverified Commit 835c09ba authored by Cristina Yenyxe Gonzalez Garcia's avatar Cristina Yenyxe Gonzalez Garcia Committed by GitHub
Browse files

Merge pull request #7 from selvaebi/T2D-207

T2D-207 adding paging to repository queries
parents d5279b25 a8ae9093
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
package uk.ac.ebi.ampt2d.registry.repositories; 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.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import uk.ac.ebi.ampt2d.registry.entities.Phenotype; import uk.ac.ebi.ampt2d.registry.entities.Phenotype;
...@@ -25,7 +25,7 @@ import uk.ac.ebi.ampt2d.registry.entities.Phenotype; ...@@ -25,7 +25,7 @@ import uk.ac.ebi.ampt2d.registry.entities.Phenotype;
import java.util.List; import java.util.List;
@RepositoryRestResource @RepositoryRestResource
public interface PhenotypeRepository extends CrudRepository<Phenotype, String> { public interface PhenotypeRepository extends PagingAndSortingRepository<Phenotype, String> {
List<Phenotype> findByPhenotypeGroup(@Param("phenotypeGroup") Phenotype.Group group); List<Phenotype> findByPhenotypeGroup(@Param("phenotypeGroup") Phenotype.Group group);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
package uk.ac.ebi.ampt2d.registry.repositories; 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.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import uk.ac.ebi.ampt2d.registry.entities.Property; import uk.ac.ebi.ampt2d.registry.entities.Property;
...@@ -25,7 +25,7 @@ import uk.ac.ebi.ampt2d.registry.entities.Property; ...@@ -25,7 +25,7 @@ import uk.ac.ebi.ampt2d.registry.entities.Property;
import java.util.List; import java.util.List;
@RepositoryRestResource @RepositoryRestResource
public interface PropertyRepository extends CrudRepository<Property, String> { public interface PropertyRepository extends PagingAndSortingRepository<Property, String> {
List<Property> findByType(@Param("type") Property.Type type); List<Property> findByType(@Param("type") Property.Type type);
......
...@@ -221,4 +221,26 @@ public class PropertyRegistryServiceApplicationTests { ...@@ -221,4 +221,26 @@ public class PropertyRegistryServiceApplicationTests {
mockMvc.perform(get(location)).andExpect(status().isNotFound()); 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