@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 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); }
@Test public void testEnsureSize() { Directory dir = new RAMDirectory(); graph = newGHStorage(dir, false).create(defaultSize); int testIndex = dir.find("edges").getSegmentSize() * 3; graph.edge(0, testIndex, 10, true); // test if optimize works without error graph.optimize(); }
@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); }
@Test public void testCreateGlobalDirOnNewProject() throws FileAlreadyExistsException { VFSRepository repository = new VFSRepository(producer.getIoService()); repository.setDescriptor(descriptor); Directory testProjectDir = repository.createDirectory("/mytestproject"); final KieProject mockProject = mock(KieProject.class); when(mockProject.getRootPath()) .thenReturn( Paths.convert( producer .getIoService() .get(URI.create(decodeUniqueId(testProjectDir.getUniqueId()))))); NewProjectEvent event = mock(NewProjectEvent.class); when(event.getProject()).thenReturn(mockProject); repository.createGlobalDirOnNewProject(event); boolean globalDirectoryExists = repository.directoryExists("/mytestproject/global"); assertTrue(globalDirectoryExists); Collection<Asset> foundFormTemplates = repository.listAssets("/mytestproject/global", new FilterByExtension("fw")); assertNotNull(foundFormTemplates); assertEquals(25, foundFormTemplates.size()); // call again to try to trigger FileAlreadyExistsException repository.createGlobalDirOnNewProject(event); boolean globalDirectoryStillExists = repository.directoryExists("/mytestproject/global"); assertTrue(globalDirectoryStillExists); // no new files or copies were added Collection<Asset> foundFormTemplatesAfterSecondCall = repository.listAssets("/mytestproject/global", new FilterByExtension("fw")); assertNotNull(foundFormTemplatesAfterSecondCall); assertEquals(25, foundFormTemplatesAfterSecondCall.size()); }