Search in sources :

Example 1 with Directory

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();
}
Also used : DirectoryContent(com.github.hakko.musiccabinet.domain.model.aggr.DirectoryContent) File(java.io.File) Directory(com.github.hakko.musiccabinet.domain.model.library.Directory) Test(org.junit.Test)

Example 2 with Directory

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());
}
Also used : DirectoryContent(com.github.hakko.musiccabinet.domain.model.aggr.DirectoryContent) Directory(com.github.hakko.musiccabinet.domain.model.library.Directory) Test(org.junit.Test)

Example 3 with Directory

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();
}
Also used : DirectoryContent(com.github.hakko.musiccabinet.domain.model.aggr.DirectoryContent) File(java.io.File) Directory(com.github.hakko.musiccabinet.domain.model.library.Directory) Test(org.junit.Test)

Example 4 with Directory

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());
}
Also used : Directory(com.github.hakko.musiccabinet.domain.model.library.Directory) Test(org.junit.Test)

Example 5 with Directory

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()));
    }
}
Also used : Directory(com.github.hakko.musiccabinet.domain.model.library.Directory) Test(org.junit.Test)

Aggregations

Directory (com.github.hakko.musiccabinet.domain.model.library.Directory)7 Test (org.junit.Test)6 DirectoryContent (com.github.hakko.musiccabinet.domain.model.aggr.DirectoryContent)4 File (java.io.File)2 File (com.github.hakko.musiccabinet.domain.model.library.File)1