Search in sources :

Example 1 with ResetContentInheritParams

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));
}
Also used : ResetContentInheritParams(com.enonic.xp.content.ResetContentInheritParams) Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Aggregations

Content (com.enonic.xp.content.Content)1 ContentId (com.enonic.xp.content.ContentId)1 ContentPath (com.enonic.xp.content.ContentPath)1 ResetContentInheritParams (com.enonic.xp.content.ResetContentInheritParams)1 Test (org.junit.jupiter.api.Test)1