Search in sources :

Example 6 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-kettle by pentaho.

the class RevisionResourceTest method setUp.

/**
 * @throws Exception
 */
@org.junit.Before
public void setUp() throws Exception {
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    RevisionResource.setRepositoryVersionManager(mockRepositoryVersionManager);
    mockRepositoryFile = mock(RepositoryFile.class);
    when(mockRepositoryFile.getId()).thenReturn(MOCK_FILE_ID);
    IUnifiedRepository mockRepository = mock(IUnifiedRepository.class);
    when(mockRepository.getFile(FileUtils.idToPath(MOCK_FILE_PATH))).thenReturn(mockRepositoryFile);
    when(mockRepository.getVersionSummaries(MOCK_FILE_ID)).thenReturn(getMockVersionSummaries());
    revisionResource = new RevisionResource(mockRepository);
}
Also used : RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 7 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-kettle by pentaho.

the class PurRepositoryIT method setUp.

@Before
public void setUp() throws Exception {
    this.testContextManager = new TestContextManager(getClass());
    this.testContextManager.prepareTestInstance(this);
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
    loginAsRepositoryAdmin();
    SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
    mp = new MicroPlatform();
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(testJcrTemplate, repositoryFileDao));
    mp.defineInstance("useMultiByteEncoding", new Boolean(false));
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    super.setUp();
    KettleEnvironment.init();
    // programmatically register plugins, annotation based plugins do not get loaded unless
    // they are in kettle's plugins folder.
    JobEntryPluginType.getInstance().registerCustom(JobEntryAttributeTesterJobEntry.class, "test", "JobEntryAttributeTester", "JobEntryAttributeTester", "JobEntryAttributeTester", "");
    StepPluginType.getInstance().registerCustom(TransStepAttributeTesterTransStep.class, "test", "StepAttributeTester", "StepAttributeTester", "StepAttributeTester", "");
    repositoryMeta = new PurRepositoryMeta();
    repositoryMeta.setName("JackRabbit");
    repositoryMeta.setDescription("JackRabbit test repository");
    userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
    repository = new PurRepository();
    repository.init(repositoryMeta);
    login(sysAdminUserName, systemTenant, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, EXP_TENANT, singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(tenantAcme, EXP_LOGIN, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    setUpUser();
    PurRepository purRep = (PurRepository) repository;
    purRep.setPurRepositoryConnector(new PurRepositoryConnector(purRep, (PurRepositoryMeta) repositoryMeta, purRep.getRootRef()));
    ((PurRepository) repository).setTest(repo);
    repository.connect(EXP_LOGIN, "password");
    login(EXP_LOGIN, tenantAcme, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    System.out.println("PUR NAME!!!: " + repo.getClass().getCanonicalName());
    RepositoryFile repositoryFile = repo.getFile(ClientRepositoryPaths.getPublicFolderPath());
    Serializable repositoryFileId = repositoryFile.getId();
    List<RepositoryFile> files = repo.getChildren(repositoryFileId);
    StringBuilder buf = new StringBuilder();
    for (RepositoryFile file : files) {
        buf.append("\n").append(file);
    }
    assertTrue("files not deleted: " + buf, files.isEmpty());
}
Also used : Serializable(java.io.Serializable) UserInfo(org.pentaho.di.repository.UserInfo) TestContextManager(org.springframework.test.context.TestContextManager) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) ITenant(org.pentaho.platform.api.mt.ITenant) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory) Before(org.junit.Before)

Example 8 with IRepositoryVersionManager

use of org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager in project pentaho-kettle by pentaho.

the class PurRepositoryTestBase method mockVersionManager.

private void mockVersionManager() {
    existingVersionManager = JcrRepositoryFileUtils.getRepositoryVersionManager();
    IRepositoryVersionManager versionManager = mock(IRepositoryVersionManager.class);
    when(versionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(versionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(versionManager);
}
Also used : IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager)

Example 9 with IRepositoryVersionManager

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

the class DefaultUnifiedRepositoryContentIT method setUp.

// ~ Methods
// =========================================================================================================
@Override
@Before
public void setUp() throws Exception {
    super.initialize(Boolean.TRUE);
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
}
Also used : IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) Before(org.junit.Before)

Example 10 with IRepositoryVersionManager

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

the class DefaultUnifiedRepositoryVersioningIT method setup.

@Before
public void setup() {
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
}
Also used : IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) Before(org.junit.Before)

Aggregations

IRepositoryVersionManager (org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager)15 Before (org.junit.Before)7 Test (org.junit.Test)4 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)2 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 URL (java.net.URL)1 Map (java.util.Map)1 Properties (java.util.Properties)1 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 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1