use of com.github.hakko.musiccabinet.domain.model.library.Directory in project musiccabinet by hakko.
the class DirectoryBrowserServiceTest method addedSubdirectoryDetectedWhenListingFiles.
@Test
public void addedSubdirectoryDetectedWhenListingFiles() throws ApplicationException, IOException {
scannerService.add(set(media1));
File newDir = new File(media1 + separatorChar + "newdir");
newDir.mkdir();
newDir.deleteOnExit();
Directory dirMedia1 = getFirstRootDirectory();
DirectoryContent found = browserService.getDirectoryDiff(dirMedia1.getId());
Assert.assertTrue(found.getFiles().isEmpty());
Assert.assertFalse(found.getSubDirectories().isEmpty());
Assert.assertEquals(1, found.getSubDirectories().size());
Assert.assertTrue(found.getSubDirectories().contains(newDir.getAbsolutePath()));
newDir.delete();
}
use of com.github.hakko.musiccabinet.domain.model.library.Directory in project musiccabinet by hakko.
the class DirectoryBrowserServiceTest method noChangesWhenListingFiles.
@Test
public void noChangesWhenListingFiles() throws ApplicationException {
scannerService.add(set(media1));
Directory dirMedia1 = getFirstRootDirectory();
DirectoryContent found = browserService.getDirectoryDiff(dirMedia1.getId());
Assert.assertTrue(found.getFiles().isEmpty());
Assert.assertTrue(found.getSubDirectories().isEmpty());
}
use of com.github.hakko.musiccabinet.domain.model.library.Directory in project musiccabinet by hakko.
the class DirectoryBrowserServiceTest method addedFileDetectedWhenListingFiles.
@Test
public void addedFileDetectedWhenListingFiles() throws ApplicationException, IOException {
scannerService.add(set(media1));
File newFile = new File(media1 + separatorChar + "newfile");
newFile.createNewFile();
newFile.deleteOnExit();
Directory dirMedia1 = getFirstRootDirectory();
DirectoryContent found = browserService.getDirectoryDiff(dirMedia1.getId());
Assert.assertFalse(found.getFiles().isEmpty());
Assert.assertTrue(found.getSubDirectories().isEmpty());
Assert.assertEquals(1, found.getFiles().size());
Assert.assertEquals(found.getFiles().iterator().next().getFilename(), newFile.getName());
newFile.delete();
}
use of com.github.hakko.musiccabinet.domain.model.library.Directory in project musiccabinet by hakko.
the class DirectoryBrowserServiceTest method addsDirectory.
@Test
public void addsDirectory() throws ApplicationException {
scannerService.add(set(cd1));
Directory root = getFirstRootDirectory();
browserService.addDirectory(cd1 + separatorChar + "subdir", root.getId());
Set<Directory> subDirs = browserService.getSubDirectories(root.getId());
Assert.assertFalse(subDirs.isEmpty());
Assert.assertEquals(1, subDirs.size());
Assert.assertEquals(cd1 + separatorChar + "subdir", subDirs.iterator().next().getPath());
}
use of com.github.hakko.musiccabinet.domain.model.library.Directory in project musiccabinet by hakko.
the class DirectoryBrowserServiceTest method findsParentDirectory.
@Test
public void findsParentDirectory() throws ApplicationException {
scannerService.add(set(media1));
Directory root = getFirstRootDirectory();
Set<Directory> subDirectories = browserService.getSubDirectories(root.getId());
Assert.assertEquals(2, subDirectories.size());
for (Directory subDirectory : subDirectories) {
Assert.assertEquals(root.getId(), browserService.getParentId(subDirectory.getId()));
}
}
Aggregations