Skip to content

Commit

Permalink
inject ACL restrictions into JPA query with sort / pageable #33
Browse files Browse the repository at this point in the history
  • Loading branch information
lordlothar99 committed Aug 10, 2016
1 parent 8b39f1c commit 0e8768d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;

import com.github.lothar.security.acl.jpa.domain.Customer;

public interface CustomerRepository extends JpaRepository<Customer, String> {
Expand All @@ -28,6 +30,8 @@ public interface CustomerRepository extends JpaRepository<Customer, String> {

List<Customer> findByFirstNameContains(String firstNameContains, Sort sort);

List<Customer> findByFirstNameContains(String firstNameContains, Pageable pageable);

int countByLastName(String lastName);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.orm.jpa.JpaObjectRetrievalFailureException;
Expand Down Expand Up @@ -219,6 +220,12 @@ public void should_find_members_of_Smith_family_with_sortable_query_method() {
assertThat(repository.findByFirstNameContains("o", new Sort("id"))).containsOnly(bobSmith);
}

@Test
@Ignore
public void should_find_members_of_Smith_family_with_pageable_query_method() {
assertThat(repository.findByFirstNameContains("o", new PageRequest(0, 10))).containsOnly(bobSmith);
}

// utils

private void doWithoutCustomerSpec(Runnable runnable) {
Expand Down

0 comments on commit 0e8768d

Please sign in to comment.