use of com.enonic.xp.content.ApplyContentPermissionsParams in project xp by enonic.
the class ContentServiceImplTest_applyPermissions 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").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
final Content content = this.contentService.create(createContentParams);
final ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(content.getId()).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
Mockito.verify(auditLogService, Mockito.timeout(5000).times(2)).log(captor.capture());
final PropertySet logResultSet = captor.getValue().getData().getSet("result");
assertEquals(content.getPath().toString(), logResultSet.getStrings("succeedContents").iterator().next());
}
use of com.enonic.xp.content.ApplyContentPermissionsParams in project xp by enonic.
the class ContentServiceImplTest_applyPermissions method content_not_found.
@Test
public void content_not_found() throws Exception {
final ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(ContentId.from("id1")).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
assertEquals(result.getSkippedContents().getSize(), 0);
assertEquals(result.getSucceedContents().getSize(), 0);
}
use of com.enonic.xp.content.ApplyContentPermissionsParams in project xp by enonic.
the class ContentServiceImplTest_applyPermissions method success.
@Test
public void success() throws Exception {
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);
final Content child = this.contentService.create(CreateContentParams.create(createContentParams).parent(content.getPath()).build());
final ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(content.getId()).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
assertEquals(result.getSkippedContents().getSize(), 0);
assertEquals(result.getSucceedContents().getSize(), 2);
assertTrue(result.getSucceedContents().contains(child.getPath()));
assertTrue(result.getSucceedContents().contains(content.getPath()));
}
use of com.enonic.xp.content.ApplyContentPermissionsParams in project xp by enonic.
the class ModifyProjectReadAccessHandlerTest method initialize.
@Override
public void initialize() throws Exception {
super.initialize();
when(this.contentService.applyPermissions(any(ApplyContentPermissionsParams.class))).thenAnswer(mock -> {
final ApplyContentPermissionsParams params = (ApplyContentPermissionsParams) mock.getArguments()[0];
Mockito.when(contentService.getByPath(ContentPath.ROOT)).thenReturn(Content.create().id(ContentId.from("123")).name(ContentName.from("root")).parentPath(ContentPath.ROOT).permissions(AccessControlList.empty()).data(new PropertyTree()).extraDatas(ExtraDatas.empty()).permissions(params.getPermissions()).build());
return null;
});
}
Aggregations