use of org.entando.entando.web.component.ComponentUsageEntity in project entando-core by entando.
the class PageModelServiceTest method getPageModelUsageTest.
@Test
public void getPageModelUsageTest() {
String managerName = "PageManager";
PageModel pageModel = PageMockHelper.mockServicePageModel();
PageDto pageDto = PageMockHelper.mockPageDto();
Map<String, Object> pageModelServiceUtilizerMap = new HashMap<>();
pageModelServiceUtilizerMap.put(managerName, pageModelServiceUtilizer);
when(pageModelManager.getPageModel(Mockito.anyString())).thenReturn(pageModel);
when(applicationContext.getBeansOfType(any())).thenReturn(pageModelServiceUtilizerMap);
when(pageModelServiceUtilizer.getManagerName()).thenReturn(managerName);
when(pageModelServiceUtilizer.getPageModelUtilizer(Mockito.anyString())).thenReturn(Collections.singletonList(pageDto));
RestListRequest restListRequest = new RestListRequest();
restListRequest.setPageSize(1);
List<ComponentUsageEntity> componentUsageEntityList = Arrays.asList(new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageMockHelper.PAGE_CODE, IPageService.STATUS_ONLINE));
PagedMetadata pagedMetadata = new PagedMetadata(restListRequest, componentUsageEntityList, 1);
pagedMetadata.setPageSize(1);
pagedMetadata.setPage(1);
pagedMetadata.imposeLimits();
when(pagedMetadataMapper.getPagedResult(any(), any())).thenReturn(pagedMetadata);
PagedMetadata<ComponentUsageEntity> usageDetails = pageModelService.getComponentUsageDetails(pageModel.getCode(), new PageSearchRequest(pageModel.getCode()));
PageModelAssertionHelper.assertUsageDetails(usageDetails);
}
use of org.entando.entando.web.component.ComponentUsageEntity in project entando-core by entando.
the class PageServiceTest method testSinglePageUsageDetails.
/**
* contains generic code to test a single paged page usage details
*
* @param pageDto
* @throws Exception
*/
private void testSinglePageUsageDetails(PageDto pageDto) {
Page page = PageMockHelper.mockTestPage(PageMockHelper.PAGE_CODE);
mockForSinglePage(page, pageDto, PageMockHelper.UTILIZERS);
PagedMetadata<ComponentUsageEntity> pageUsageDetails = pageService.getComponentUsageDetails(PageMockHelper.PAGE_CODE, new PageSearchRequest(PageMockHelper.PAGE_CODE));
PageAssertionHelper.assertUsageDetails(pageUsageDetails, pageDto.getStatus());
}
use of org.entando.entando.web.component.ComponentUsageEntity in project entando-core by entando.
the class PageControllerIntegrationTest method testPageUsageDetailsWithUnpublishedPageShouldNOTBeIncluded.
@Test
public void testPageUsageDetailsWithUnpublishedPageShouldNOTBeIncluded() throws Exception {
List<ComponentUsageEntity> expectedResult = Arrays.asList(new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageRequestMockHelper.ADD_FIRST_CHILD_PAGE_CODE, IPageService.STATUS_UNPUBLISHED));
this.execPageUsageDetailsTest(false, expectedResult);
}
use of org.entando.entando.web.component.ComponentUsageEntity in project entando-core by entando.
the class PageControllerIntegrationTest method testPageUsageDetailsWithPublishedPageShouldBeIncluded.
@Test
public void testPageUsageDetailsWithPublishedPageShouldBeIncluded() throws Exception {
List<ComponentUsageEntity> expectedResult = Arrays.asList(new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageRequestMockHelper.ADD_FIRST_CHILD_PAGE_CODE, IPageService.STATUS_UNPUBLISHED), new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE, PageRequestMockHelper.ADD_PAGE_CODE, IPageService.STATUS_ONLINE));
this.execPageUsageDetailsTest(true, expectedResult);
}
use of org.entando.entando.web.component.ComponentUsageEntity in project entando-core by entando.
the class GuiFragmentService method getComponentUsageDetails.
@Override
public PagedMetadata<ComponentUsageEntity> getComponentUsageDetails(String componentCode, RestListRequest restListRequest) {
List<ComponentUsageEntity> componentUsageEntityList = new ArrayList<>();
GuiFragmentDto fragmentDto = this.getGuiFragment(componentCode);
if (null != fragmentDto.getWidgetType()) {
componentUsageEntityList.add(new ComponentUsageEntity(ComponentUsageEntity.TYPE_WIDGET, fragmentDto.getWidgetTypeCode()));
}
if (null != fragmentDto.getFragments()) {
List<ComponentUsageEntity> fragmentList = fragmentDto.getFragments().stream().map(fragmentRef -> new ComponentUsageEntity(ComponentUsageEntity.TYPE_FRAGMENT, fragmentRef.getCode())).collect(Collectors.toList());
componentUsageEntityList.addAll(fragmentList);
}
if (null != fragmentDto.getPageModels()) {
List<ComponentUsageEntity> pageModelList = fragmentDto.getPageModels().stream().map(pageModelRef -> new ComponentUsageEntity(ComponentUsageEntity.TYPE_PAGE_TEMPLATE, pageModelRef.getCode())).collect(Collectors.toList());
componentUsageEntityList.addAll(pageModelList);
}
return pagedMetadataMapper.getPagedResult(restListRequest, componentUsageEntityList);
}
Aggregations