Search in sources :

Example 1 with SpringSecurityCurrentUserProvider

use of org.pentaho.test.platform.repository2.unified.MockUnifiedRepository.SpringSecurityCurrentUserProvider in project pentaho-platform by pentaho.

the class RepositoryUtilsTest method testGetFolder.

@Test
public void testGetFolder() throws Exception {
    final MockUnifiedRepository repository = new MockUnifiedRepository(new SpringSecurityCurrentUserProvider());
    final RepositoryUtils repositoryUtils = new RepositoryUtils(repository);
    RepositoryFile test = repositoryUtils.getFolder("/public/one/two/three", true, true, null);
    assertNotNull(test);
    assertEquals("The folder name is invalid", "three", test.getName());
    assertEquals("The path is invalid", "/public/one/two/three", test.getPath());
    assertTrue("The folder should be defined as a folder", test.isFolder());
    // Make sure it created the parents
    RepositoryFile one = repositoryUtils.getFolder("/public/one", false, false, null);
    assertNotNull(one);
    RepositoryFile two = repositoryUtils.getFolder("/public/one/two", false, false, null);
    assertNotNull(two);
}
Also used : RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) SpringSecurityCurrentUserProvider(org.pentaho.test.platform.repository2.unified.MockUnifiedRepository.SpringSecurityCurrentUserProvider) MockUnifiedRepository(org.pentaho.test.platform.repository2.unified.MockUnifiedRepository) Test(org.junit.Test)

Example 2 with SpringSecurityCurrentUserProvider

use of org.pentaho.test.platform.repository2.unified.MockUnifiedRepository.SpringSecurityCurrentUserProvider in project pentaho-platform by pentaho.

the class RepositoryUtilsTest method testGetFile.

@Test
public void testGetFile() throws Exception {
    final MockUnifiedRepository repository = new MockUnifiedRepository(new SpringSecurityCurrentUserProvider());
    final RepositoryUtils repositoryUtils = new RepositoryUtils(repository);
    final SimpleRepositoryFileData data = new SimpleRepositoryFileData(new ByteArrayInputStream("Test".getBytes()), "UTF-8", "text/plain");
    RepositoryFile test = repositoryUtils.getFile("/public/one/two/three.prpt", data, true, true, null);
    assertNotNull(test);
    assertEquals("The filename is invalid", "three.prpt", test.getName());
    assertEquals("The path is invalid", "/public/one/two/three.prpt", test.getPath());
    assertFalse("The file should not be defined as a folder", test.isFolder());
    // Make sure it created the parents
    RepositoryFile one = repositoryUtils.getFolder("/public/one", false, false, null);
    assertNotNull(one);
    RepositoryFile two = repositoryUtils.getFolder("/public/one/two", false, false, null);
    assertNotNull(two);
}
Also used : SimpleRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData) ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) SpringSecurityCurrentUserProvider(org.pentaho.test.platform.repository2.unified.MockUnifiedRepository.SpringSecurityCurrentUserProvider) MockUnifiedRepository(org.pentaho.test.platform.repository2.unified.MockUnifiedRepository) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 MockUnifiedRepository (org.pentaho.test.platform.repository2.unified.MockUnifiedRepository)2 SpringSecurityCurrentUserProvider (org.pentaho.test.platform.repository2.unified.MockUnifiedRepository.SpringSecurityCurrentUserProvider)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)1