@Test public void testDirectoryExists() { Repository repository = new VFSRepository(producer.getIoService()); ((VFSRepository) repository).setDescriptor(descriptor); boolean rootFolderExists = repository.directoryExists("/test"); assertFalse(rootFolderExists); Directory directoryId = repository.createDirectory("/test"); assertNotNull(directoryId); assertEquals("test", directoryId.getName()); assertEquals("/", directoryId.getLocation()); assertNotNull(directoryId.getUniqueId()); rootFolderExists = repository.directoryExists("/test"); assertTrue(rootFolderExists); AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte); builder.content("simple content".getBytes()).type("png").name("test").location("/test"); String id = repository.createAsset(builder.getAsset()); assertNotNull(id); boolean assetPathShouldNotExists = repository.directoryExists("/test/test.png"); assertFalse(assetPathShouldNotExists); }
@Ignore // git based vfs does not yet support move @Test public void testMoveEmptyDirectory() throws NoSuchFileException { Repository repository = new VFSRepository(producer.getIoService()); ((VFSRepository) repository).setDescriptor(descriptor); Directory sourceDir = repository.createDirectory("/source"); boolean directoryExists = repository.directoryExists(sourceDir.getLocation() + sourceDir.getName()); assertTrue(directoryExists); Collection<Asset> foundAsset = repository.listAssets("/source", new FilterByExtension("bpmn2")); assertNotNull(foundAsset); assertEquals(0, foundAsset.size()); boolean copied = repository.moveDirectory("/source", "/", "target"); assertTrue(copied); boolean movedDirectoryExists = repository.directoryExists("/source"); assertFalse(movedDirectoryExists); movedDirectoryExists = repository.directoryExists("/target"); assertTrue(movedDirectoryExists); foundAsset = repository.listAssets("/target", new FilterByExtension("bpmn2")); assertNotNull(foundAsset); assertEquals(0, foundAsset.size()); }
@Test public void testCreateDirectory() { Repository repository = new VFSRepository(producer.getIoService()); ((VFSRepository) repository).setDescriptor(descriptor); boolean rootFolderExists = repository.directoryExists("/test"); assertFalse(rootFolderExists); Directory directoryId = repository.createDirectory("/test"); assertNotNull(directoryId); assertEquals("test", directoryId.getName()); assertEquals("/", directoryId.getLocation()); assertNotNull(directoryId.getUniqueId()); rootFolderExists = repository.directoryExists("/test"); assertTrue(rootFolderExists); }