@Test public void bookFilePathWithSeriesInItWillReturnBookWithSeriesInItsName() throws Exception { String author = "Лукьяненко Сергей"; String bookName = "Лукьяненко 3 Калеки"; String seriesName = "Геном"; final String fileName = bookName + ".fb2.zip"; final String path = PathUtils.createPath("ru", "Л", author, seriesName, fileName); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(false)); allowing(fs).getName(path); will(returnValue(fileName)); } }); Book item = (Book) extractor.get(path); assertThat(item.name, hasWords(seriesName)); }
@Test public void underscoreFolderPathReturnsFolder() throws Exception { final String folderName = "_scifi"; final String path = PathUtils.createPath("ru", "_", folderName); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(true)); allowing(fs).getName(path); will(returnValue(folderName)); } }); Folder item = (Folder) extractor.get(path); assertThat(item, equalTo(new Folder(path, folderName))); }
@Test public void authorFolderPathReturnsAuthorObjectWithProperName() throws Exception { final String author = "Лукьяненко Сергей"; final String path = PathUtils.createPath("ru", "Л", author); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(true)); allowing(fs).getName(path); will(returnValue(author)); } }); Author item = (Author) extractor.get(path); assertThat(item, equalTo(new Author(path, author))); }
@Test public void bookFilePathReturnsBookItemWithProperName() throws Exception { String author = "Лукьяненко Сергей"; String bookName = "Геном"; final String fileName = bookName + ".fb2.zip"; final String path = PathUtils.createPath("ru", "Л", author, fileName); mockery.checking( new Expectations() { { allowing(fs).exists(path); will(returnValue(true)); allowing(fs).isDirectory(path); will(returnValue(false)); allowing(fs).getName(path); will(returnValue(fileName)); } }); Book item = (Book) extractor.get(path); assertThat(item, equalTo(new Book(path, bookName))); }