use of com.enonic.xp.content.ResetContentInheritParams in project xp by enonic.
the class ResetInheritanceHandlerTest method testExample.
@Test
public void testExample() {
final Content content = Mockito.mock(Content.class);
Mockito.when(content.getId()).thenReturn(ContentId.from("mycontent-id"));
Mockito.when(content.getPath()).thenReturn(ContentPath.from("/a/b/mycontent"));
Mockito.when(contentService.getByPath(Mockito.any(ContentPath.class))).thenReturn(content);
Mockito.when(contentService.getById(Mockito.any(ContentId.class))).thenReturn(content);
runScript("/lib/xp/examples/content/resetInheritance.js");
Mockito.verify(this.syncContentService, Mockito.times(2)).resetInheritance(captor.capture());
final ResetContentInheritParams idParams = this.captor.getAllValues().get(0);
Assert.assertEquals("mycontent-id", idParams.getContentId().toString());
Assert.assertEquals("child1", idParams.getProjectName().toString());
Assert.assertTrue(idParams.getInherit().contains(ContentInheritType.NAME));
Assert.assertTrue(idParams.getInherit().contains(ContentInheritType.CONTENT));
final ResetContentInheritParams pathParams = this.captor.getAllValues().get(1);
Assert.assertEquals("mycontent-id", pathParams.getContentId().toString());
Assert.assertEquals("child2", pathParams.getProjectName().toString());
Assert.assertTrue(pathParams.getInherit().contains(ContentInheritType.SORT));
}
Aggregations