Search in sources :

Example 1 with IRepositoryFileAclDao

use of org.pentaho.platform.repository2.unified.IRepositoryFileAclDao in project pentaho-platform by pentaho.

the class JcrRepositoryFileDaoTest method setUp.

@Before
public void setUp() throws RepositoryException {
    Node node = mock(Node.class);
    Node nodeParent = mock(Node.class);
    when(node.getIdentifier()).thenReturn("");
    when(nodeParent.getIdentifier()).thenReturn("");
    when(node.getParent()).thenReturn(nodeParent);
    when(node.isNodeType("null:pentahoFile")).thenReturn(true);
    when(node.isNodeType("null:pentahoVersionable")).thenReturn(true);
    VersionManagerImpl versionManager = mock(VersionManagerImpl.class);
    Workspace workspace = mock(Workspace.class);
    when(workspace.getVersionManager()).thenReturn(versionManager);
    Session session = mock(Session.class);
    when(session.getWorkspace()).thenReturn(workspace);
    when(session.getNodeByIdentifier(anyString())).thenReturn(node);
    when(session.getItem(anyString())).thenReturn(node);
    pentahoSession = mock(IPentahoSession.class);
    PentahoSessionHolder.setSession(pentahoSession);
    IRepositoryVersionManager repositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(repositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    PentahoSystem.registerObject(repositoryVersionManager);
    JcrTemplate jcrTemplate = new JcrTemplate() {

        @Override
        public Object execute(JcrCallback callback) throws DataAccessException {
            try {
                return callback.doInJcr(session);
            } catch (Exception e) {
                // wrapping exception to comply overriding rules
                throw new RuntimeException(e);
            }
        }
    };
    List<ITransformer<IRepositoryFileData>> transformerList = Collections.emptyList();
    IPathConversionHelper pathConversionHelper = new DefaultPathConversionHelper();
    IRepositoryFileAclDao aclDao = mock(IRepositoryFileAclDao.class);
    accessVoterManager = mock(IRepositoryAccessVoterManager.class);
    JcrRepositoryFileDao jcrDao = new JcrRepositoryFileDao(jcrTemplate, transformerList, null, null, pathConversionHelper, aclDao, null, accessVoterManager);
    dao = spy(jcrDao);
}
Also used : JcrTemplate(org.springframework.extensions.jcr.JcrTemplate) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Node(javax.jcr.Node) JcrCallback(org.springframework.extensions.jcr.JcrCallback) IRepositoryFileAclDao(org.pentaho.platform.repository2.unified.IRepositoryFileAclDao) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) DataAccessException(org.springframework.dao.DataAccessException) AccessDeniedException(javax.jcr.AccessDeniedException) RepositoryException(javax.jcr.RepositoryException) VersionManagerImpl(org.apache.jackrabbit.core.VersionManagerImpl) IRepositoryAccessVoterManager(org.pentaho.platform.api.repository2.unified.IRepositoryAccessVoterManager) Workspace(javax.jcr.Workspace) Session(javax.jcr.Session) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Before(org.junit.Before)

Aggregations

AccessDeniedException (javax.jcr.AccessDeniedException)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1 Workspace (javax.jcr.Workspace)1 VersionManagerImpl (org.apache.jackrabbit.core.VersionManagerImpl)1 Before (org.junit.Before)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 IRepositoryAccessVoterManager (org.pentaho.platform.api.repository2.unified.IRepositoryAccessVoterManager)1 IRepositoryVersionManager (org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager)1 IRepositoryFileAclDao (org.pentaho.platform.repository2.unified.IRepositoryFileAclDao)1 DataAccessException (org.springframework.dao.DataAccessException)1 JcrCallback (org.springframework.extensions.jcr.JcrCallback)1 JcrTemplate (org.springframework.extensions.jcr.JcrTemplate)1