use of org.entando.entando.web.page.model.PageSearchRequest in project entando-core by entando.
the class WidgetServiceTest method getWidgetUsageDetailsWithInvalidCodeShouldThrowResourceNotFoundException.
@Test
public void getWidgetUsageDetailsWithInvalidCodeShouldThrowResourceNotFoundException() throws Exception {
Page page1 = PageMockHelper.mockTestPage(PageMockHelper.PAGE_MISSION_CODE, WidgetMockHelper.WIDGET_1_CODE);
Page page2 = PageMockHelper.mockTestPage(PageMockHelper.PAGE_CODE, WidgetMockHelper.WIDGET_1_CODE);
List mockedPageList = Arrays.asList(page1, page2);
mockPagedMetadata(Arrays.asList(PageMockHelper.PAGE_MISSION_CODE, PageMockHelper.PAGE_CODE), 1, 1, 100, 4);
PageSearchRequest pageSearchRequest = new PageSearchRequest(PageMockHelper.PAGE_CODE);
Arrays.stream(new String[] { "not existing", null, "" }).forEach(code -> {
try {
widgetService.getComponentUsageDetails(code, pageSearchRequest);
fail("NoSuchElementException NOT thrown with code " + code);
} catch (Exception e) {
assertTrue(e instanceof NoSuchElementException || e instanceof NullPointerException);
}
});
}
use of org.entando.entando.web.page.model.PageSearchRequest in project entando-core by entando.
the class WidgetServiceTest method getWidgetUsageDetails.
@Test
public void getWidgetUsageDetails() throws Exception {
this.mockPagedMetadata(Arrays.asList(PageMockHelper.PAGE_CODE), 1, 1, 100, 2);
PagedMetadata<ComponentUsageEntity> usageDetails = widgetService.getComponentUsageDetails(WidgetMockHelper.WIDGET_1_CODE, new PageSearchRequest(WidgetMockHelper.WIDGET_1_CODE));
WidgetAssertionHelper.assertUsageDetails(usageDetails);
}
use of org.entando.entando.web.page.model.PageSearchRequest in project entando-core by entando.
the class PageServiceTest method getPageUsageDetailsWithNoChildrenShouldReturnItself.
@Test
public void getPageUsageDetailsWithNoChildrenShouldReturnItself() {
PageDto pageDto = PageMockHelper.mockPageDto();
pageDto.setChildren(new ArrayList<>());
mockForSinglePage(PageMockHelper.mockTestPage(PageMockHelper.PAGE_CODE), pageDto, new String[0]);
PagedMetadata<ComponentUsageEntity> pageUsageDetails = pageService.getComponentUsageDetails(PageMockHelper.PAGE_CODE, new PageSearchRequest(PageMockHelper.PAGE_CODE));
PageAssertionHelper.assertUsageDetails(pageUsageDetails, new String[0], 0, 1, pageDto.getStatus());
}
use of org.entando.entando.web.page.model.PageSearchRequest in project entando-core by entando.
the class GuiFragmentServiceTest method getFragmentUsageTest.
@Test
public void getFragmentUsageTest() throws Exception {
Lang lang = new Lang();
lang.setCode("IT");
when(langManager.getDefaultLang()).thenReturn(lang);
GuiFragment fragment = FragmentMockHelper.mockGuiFragment();
GuiFragmentDto fragmentDto = FragmentMockHelper.mockGuiFragmentDto(fragment, langManager);
mockPagedMetadata(fragment, fragmentDto, 1, 1, 100, 5);
PagedMetadata<ComponentUsageEntity> componentUsageDetails = guiFragmentService.getComponentUsageDetails(fragment.getCode(), new PageSearchRequest(PageMockHelper.PAGE_CODE));
GuiFragmentAssertionHelper.assertUsageDetails(componentUsageDetails);
}
use of org.entando.entando.web.page.model.PageSearchRequest in project entando-core by entando.
the class WidgetServiceTest method getWidgetUsageDetailsWithPagination.
@Test
public void getWidgetUsageDetailsWithPagination() throws Exception {
int pageSize = 3;
// creates paged data
List<Integer> pageNumList = Arrays.asList(1, 2);
Map<Integer, List<ComponentUsageEntity>> usageEntityMap = new HashMap<>();
usageEntityMap.put(pageNumList.get(0), Arrays.asList(new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageMockHelper.PAGE_MISSION_CODE, IPageService.STATUS_ONLINE), new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageMockHelper.PAGE_CODE, IPageService.STATUS_ONLINE), new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageMockHelper.PAGE_MISSION_CODE, IPageService.STATUS_DRAFT)));
usageEntityMap.put(pageNumList.get(1), Arrays.asList(new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageMockHelper.PAGE_CODE, IPageService.STATUS_DRAFT)));
PageSearchRequest pageSearchRequest = new PageSearchRequest(WidgetMockHelper.WIDGET_1_CODE);
pageSearchRequest.setPageSize(pageSize);
// does assertions
IntStream.range(0, pageNumList.size()).forEach(i -> {
mockPagedMetadata(Arrays.asList(PageMockHelper.PAGE_MISSION_CODE, PageMockHelper.PAGE_CODE), pageNumList.get(i), pageNumList.get(pageNumList.size() - 1), pageSize, 4);
pageSearchRequest.setPage(pageNumList.get(i));
PagedMetadata<ComponentUsageEntity> pageUsageDetails = widgetService.getComponentUsageDetails(WIDGET_1_CODE, pageSearchRequest);
WidgetAssertionHelper.assertUsageDetails(pageUsageDetails, usageEntityMap.get(i + 1), 4, pageNumList.get(i));
});
}
Aggregations