Search in sources :

Example 1 with ContentService

use of com.enonic.xp.content.ContentService in project xp by enonic.

the class IdentityHandlerTest method setup.

@BeforeEach
public final void setup() throws Exception {
    this.request = new PortalRequest();
    final ContentService contentService = Mockito.mock(ContentService.class);
    final IdProviderControllerService idProviderControllerService = Mockito.mock(IdProviderControllerService.class);
    final HttpServletRequest rawRequest = Mockito.mock(HttpServletRequest.class);
    Mockito.when(idProviderControllerService.execute(Mockito.any())).thenAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        final IdProviderControllerExecutionParams arg = (IdProviderControllerExecutionParams) args[0];
        if (IdProviderKey.from("myidprovider").equals(arg.getIdProviderKey()) && "get".equals(arg.getFunctionName())) {
            return PortalResponse.create().build();
        }
        return null;
    });
    this.handler = new IdentityHandler();
    this.handler.setContentService(contentService);
    this.handler.setIdProviderControllerService(idProviderControllerService);
    this.request.setMethod(HttpMethod.GET);
    this.request.setEndpointPath("/_/idprovider/myidprovider?param1=value1");
    this.request.setRawPath("/site/draft/_/idprovider/myidprovider?param1=value1");
    this.request.setRawRequest(rawRequest);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IdProviderControllerService(com.enonic.xp.portal.idprovider.IdProviderControllerService) ContentService(com.enonic.xp.content.ContentService) IdProviderControllerExecutionParams(com.enonic.xp.portal.idprovider.IdProviderControllerExecutionParams) PortalRequest(com.enonic.xp.portal.PortalRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ContentService

use of com.enonic.xp.content.ContentService in project xp by enonic.

the class ContentResourceTest method getResourceInstance.

@Override
protected Object getResourceInstance() {
    this.contentService = Mockito.mock(ContentService.class);
    this.taskService = Mockito.mock(TaskService.class);
    final ProjectService projectService = Mockito.mock(ProjectService.class);
    final SyncContentService syncContentService = Mockito.mock(SyncContentService.class);
    final ContentResource resource = new ContentResource();
    resource.setContentService(contentService);
    resource.setTaskService(taskService);
    resource.setProjectService(projectService);
    resource.setSyncContentService(syncContentService);
    return resource;
}
Also used : SyncContentService(com.enonic.xp.content.SyncContentService) TaskService(com.enonic.xp.task.TaskService) ProjectService(com.enonic.xp.project.ProjectService) ContentService(com.enonic.xp.content.ContentService) SyncContentService(com.enonic.xp.content.SyncContentService)

Example 3 with ContentService

use of com.enonic.xp.content.ContentService in project xp by enonic.

the class ImageUrlBuilderTest method init.

@BeforeEach
public void init() {
    final PortalRequest portalRequest = new PortalRequest();
    portalRequest.setBranch(Branch.from("draft"));
    portalRequest.setApplicationKey(ApplicationKey.from("myapplication"));
    portalRequest.setBaseUri("/site");
    portalRequest.setContentPath(ContentPath.from("context/path"));
    this.imageUrlParams = new ImageUrlParams().portalRequest(portalRequest).scale("testScale");
    urlBuilder = new ImageUrlBuilder();
    urlBuilder.setParams(imageUrlParams);
    final Attachment attachment = Attachment.create().name("attachmentName").mimeType("attachmentMimeType").size(1).build();
    media = Mockito.mock(Media.class);
    final ContentId contentId = ContentId.from("testID");
    Mockito.when(media.getId()).thenReturn(contentId);
    Mockito.when(media.getName()).thenReturn(ContentName.from("testName"));
    Mockito.when(media.getType()).thenReturn(ContentTypeName.imageMedia());
    Mockito.when(media.getMediaAttachment()).thenReturn(attachment);
    final ContentService contentService = Mockito.mock(ContentService.class);
    Mockito.when(contentService.getByPath(Mockito.any())).thenReturn(media);
    Mockito.when(contentService.getById(Mockito.any())).thenReturn(media);
    Mockito.when(contentService.getBinaryKey(contentId, attachment.getBinaryReference())).thenReturn("binaryHash");
    urlBuilder.contentService = contentService;
}
Also used : Media(com.enonic.xp.content.Media) Attachment(com.enonic.xp.attachment.Attachment) ContentId(com.enonic.xp.content.ContentId) ContentService(com.enonic.xp.content.ContentService) PortalRequest(com.enonic.xp.portal.PortalRequest) ImageUrlParams(com.enonic.xp.portal.url.ImageUrlParams) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ContentService

use of com.enonic.xp.content.ContentService in project xp by enonic.

the class ContentOutboundDependenciesIdsResolverTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    this.contentService = Mockito.mock(ContentService.class);
    this.contentDataSerializer = Mockito.mock(ContentDataSerializer.class);
    this.resolver = new ContentOutboundDependenciesIdsResolver(contentService, contentDataSerializer);
}
Also used : ContentDataSerializer(com.enonic.xp.core.impl.content.serializer.ContentDataSerializer) ContentOutboundDependenciesIdsResolver(com.enonic.xp.core.impl.content.ContentOutboundDependenciesIdsResolver) ContentService(com.enonic.xp.content.ContentService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ContentService

use of com.enonic.xp.content.ContentService in project xp by enonic.

the class ContentDependenciesResolverTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    this.contentService = Mockito.mock(ContentService.class);
    this.contentTypeService = Mockito.mock(ContentTypeService.class);
    resolver = new ContentDependenciesResolver(contentService);
}
Also used : ContentService(com.enonic.xp.content.ContentService) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) ContentDependenciesResolver(com.enonic.xp.core.impl.content.ContentDependenciesResolver) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ContentService (com.enonic.xp.content.ContentService)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 PortalRequest (com.enonic.xp.portal.PortalRequest)4 ResourceService (com.enonic.xp.resource.ResourceService)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Attachment (com.enonic.xp.attachment.Attachment)1 ContentId (com.enonic.xp.content.ContentId)1 Media (com.enonic.xp.content.Media)1 SyncContentService (com.enonic.xp.content.SyncContentService)1 ContentDependenciesResolver (com.enonic.xp.core.impl.content.ContentDependenciesResolver)1 ContentOutboundDependenciesIdsResolver (com.enonic.xp.core.impl.content.ContentOutboundDependenciesIdsResolver)1 ContentDataSerializer (com.enonic.xp.core.impl.content.serializer.ContentDataSerializer)1 PortalResponse (com.enonic.xp.portal.PortalResponse)1 ControllerScript (com.enonic.xp.portal.controller.ControllerScript)1 ControllerScriptFactory (com.enonic.xp.portal.controller.ControllerScriptFactory)1 FilterScript (com.enonic.xp.portal.filter.FilterScript)1 FilterScriptFactory (com.enonic.xp.portal.filter.FilterScriptFactory)1 IdProviderControllerExecutionParams (com.enonic.xp.portal.idprovider.IdProviderControllerExecutionParams)1 IdProviderControllerService (com.enonic.xp.portal.idprovider.IdProviderControllerService)1 ContentResolver (com.enonic.xp.portal.impl.ContentResolver)1