use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class CanPaginateVisitorTest method testNotOperationExpression.
@Test
public void testNotOperationExpression() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "NOT In Memory Check")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class CanPaginateVisitorTest method testSparseFields.
@Test
public void testSparseFields() throws Exception {
@Entity
@Include(rootLevel = false)
@ReadPermission(expression = "In Memory Check")
class Book {
@Id
private long id;
@ReadPermission(expression = "Filter Expression Check")
private String title;
@ReadPermission(expression = "Filter Expression Check")
private Date publicationDate;
private boolean outOfPrint;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
Set<String> sparseFields = new HashSet<>();
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, sparseFields));
sparseFields.add("title");
sparseFields.add("publicationDate");
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, sparseFields));
sparseFields.add("outOfPrint");
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, sparseFields));
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class CanPaginateVisitorTest method testFieldFilterPermissions.
@Test
public void testFieldFilterPermissions() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "Filter Expression Check")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class CanPaginateVisitorTest method testFalseUserOROperationExpression.
@Test
public void testFalseUserOROperationExpression() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "False User Check OR In Memory Check")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertFalse(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
use of com.yahoo.elide.annotation.Include in project elide by yahoo.
the class CanPaginateVisitorTest method testComplexTrueExpression.
@Test
public void testComplexTrueExpression() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "(Filter Expression Check AND False User Check) OR (Filter Expression Check OR NOT False User Check)")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
Aggregations