@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); }
@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); }