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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations