use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class CreateFragmentCommandTest method captorFragmentCreation.
private ArgumentCaptor<CreateContentParams> captorFragmentCreation() {
final Content fragment = Mockito.mock(Content.class);
Mockito.when(fragment.getId()).thenReturn(ContentId.from("fragment-id"));
final ArgumentCaptor<CreateContentParams> argument = ArgumentCaptor.forClass(CreateContentParams.class);
Mockito.when(contentService.create(argument.capture())).thenReturn(fragment);
return argument;
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class CreateFragmentCommandTest method testLayoutComponentName.
private String testLayoutComponentName(final String name) {
final ArgumentCaptor<CreateContentParams> captor = captorFragmentCreation();
final DescriptorKey layoutKey = DescriptorKey.from(ApplicationKey.from("application"), "layout1");
Mockito.when(this.layoutDescriptorService.getByKey(layoutKey)).thenReturn(layoutDescriptor(layoutKey, name));
createFragmentCommand(createFragmentParams(layoutComponent(layoutKey))).execute();
return captor.getValue().getDisplayName();
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_publish method audit_data.
@Test
public void audit_data() throws Exception {
final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").name("myContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final PublishContentResult push = this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).includeDependencies(false).build());
Mockito.verify(auditLogService, Mockito.timeout(5000).atLeast(16)).log(captor.capture());
final PropertySet logResultSet = captor.getAllValues().stream().filter(log -> log.getType().equals("system.content.publish")).findFirst().get().getData().getSet("result");
assertEquals(content.getId().toString(), logResultSet.getStrings("pushedContents").iterator().next());
assertFalse(logResultSet.getStrings("deletedContents").iterator().hasNext());
assertFalse(logResultSet.getStrings("pendingContents").iterator().hasNext());
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class ContentServiceImplTest_resolvePublishDependencies method resolve_single.
@Test
public void resolve_single() throws Exception {
nodeService.push(NodeIds.from(ROOT_UUID), WS_OTHER);
refresh();
final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
refresh();
final CompareContentResults result = this.contentService.resolvePublishDependencies(ResolvePublishDependenciesParams.create().contentIds(ContentIds.from(content.getId())).excludeChildrenIds(ContentIds.from(content.getId())).target(WS_OTHER).build());
assertEquals(1, result.contentIds().getSize());
}
use of com.enonic.xp.content.CreateContentParams in project xp by enonic.
the class CreateContentHandlerTest method createContentWithWorkflow.
@Test
public void createContentWithWorkflow() throws Exception {
when(this.contentService.create(any(CreateContentParams.class))).thenAnswer(mock -> createContent((CreateContentParams) mock.getArguments()[0]));
final ContentType contentType = ContentType.create().name("test:myContentType").superType(ContentTypeName.structured()).build();
GetContentTypeParams getContentType = GetContentTypeParams.from(ContentTypeName.from("test:myContentType"));
when(this.contentTypeService.getByName(Mockito.eq(getContentType))).thenReturn(contentType);
runFunction("/test/CreateContentHandlerTest.js", "createContentWithWorkflow");
}
Aggregations