use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class AttachmentServiceImplTest method testAttachment_expectMultipleResults.
@Test
public void testAttachment_expectMultipleResults() throws Exception {
Attachment a = new Attachment();
a.setArticleId(createTestArticle());
a.setName("test attachment");
a.setSize(123);
a.setContents(createValidContentsReader());
attachmentService.create(a);
a.setContents(createValidContentsReader());
a.setName("test attachment 2");
attachmentService.create(a);
PaginatedList<Attachment> result = attachmentService.query(new PagerParams(0, 100), Query.n().eq(Attachment.FN_ARTICLE_ID, a.getArticleId()));
assertEquals(2, result.getItems().size());
}
use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class StringIdAliasServiceEagerImpl method loadAllAliases.
protected final BiMap<String, Long> loadAllAliases() {
try {
BiMap<String, Long> ret = HashBiMap.create();
long maxOffset = -2;
for (long offset = 0; maxOffset == -2 || offset < maxOffset; offset = offset + EAGER_LOAD_BATCH_SIZE) {
PagerParams pagerParams = new PagerParams(offset, EAGER_LOAD_BATCH_SIZE);
PaginatedList<AliasEntry> loadedAliases = stringIdAliasDao.loadAllAliases(pagerParams);
maxOffset = loadedAliases.getTotalResults() - 1;
for (Entry<String, Long> entry : loadedAliases.getItems()) {
ret.put(entry.getKey(), entry.getValue());
}
}
return ret;
} catch (Throwable t) {
String msg = "Failed to eagerly load alias map";
log.error(msg, t);
throw new PropertyServiceUnexpectedException(msg, t);
}
}
use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class GenericCrudServiceTestTemplate method testQuery_expectOrderingWorksCorrectly.
@Test
public void testQuery_expectOrderingWorksCorrectly() throws Exception {
createTestData();
PaginatedList<TestDto1> result = getTestDto1Service().query(new PagerParams(0, 100), Query.n().contains("env", "env-"), OrderBy.Asc("minorVersion"));
assertEquals("env-prd", result.getItems().get(2).getEnv());
assertEquals("env-pilot", result.getItems().get(1).getEnv());
assertEquals("env-uat", result.getItems().get(0).getEnv());
result = getTestDto1Service().query(new PagerParams(0, 100), Query.n().contains("env", "env-"), OrderBy.Desc("minorVersion"));
assertEquals("env-prd", result.getItems().get(0).getEnv());
assertEquals("env-pilot", result.getItems().get(1).getEnv());
assertEquals("env-uat", result.getItems().get(2).getEnv());
}
use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class GenericCrudServiceTestTemplate method testFindByQueryNotContains.
@Test
public void testFindByQueryNotContains() throws Exception {
createTestData();
PaginatedList<TestDto1> result = getTestDto1Service().query(new PagerParams(0, 100), Query.n().notContains("env", "env-P"));
assertEquals(1, result.getTotalResults());
}
use of org.summerb.easycrud.api.dto.PagerParams in project summerb by skarpushin.
the class GenericCrudServiceTestTemplate method testFindByQueryNumberNotIn.
@Test
public void testFindByQueryNumberNotIn() throws Exception {
createTestData();
PaginatedList<TestDto1> result = getTestDto1Service().query(new PagerParams(0, 100), Query.n().notIn("minorVersion", 4L, 5L));
assertEquals(1, result.getTotalResults());
}
Aggregations