예제 #1
0
  @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));
  }
예제 #2
0
  @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)));
  }
예제 #3
0
  @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)));
  }
예제 #4
0
  @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)));
  }