コード例 #1
0
  @Override
  public void shouldCorrectlyBuildASinglePath() {
    ICategory[] categories = {
      Category.DATE, Category.WORKSPACE, Category.PROJECT, Category.FOLDER, Category.FILE
    };
    List<TreePath> expected =
        asList(
            newPath(
                date,
                ws,
                fileHasParentFolder.getProject(),
                fileHasParentFolder.getParent(),
                fileHasParentFolder,
                duration));

    ICategoryProvider provider = mock(ICategoryProvider.class);
    given(provider.getSelected()).willReturn(asList(categories));
    ITreePathBuilder builder = create(provider);

    IFileDataProvider input = mock(IFileDataProvider.class);
    given(input.get()).willReturn(asList(data));
    List<TreePath> actual = builder.build(input);

    assertThat(toString(actual, expected), actual, equalTo(expected));
  }
コード例 #2
0
  @Override
  public void shouldCorrectlyBuildMultiplePaths() {
    WorkspaceStorage ws2 = new WorkspaceStorage(new Path(".b"), null);
    LocalDate date2 = date.minusDays(2);
    Duration duration2 = duration.withMillis(10000);
    IFile fileHasNoParentFolder = root.getFile(new Path("/project/file.txt"));

    ICategory[] categories = {Category.PROJECT, Category.FOLDER, Category.FILE};
    List<TreePath> expected =
        asList(
            newPath(
                fileHasParentFolder.getProject(),
                fileHasParentFolder.getParent(),
                fileHasParentFolder,
                duration),
            newPath(fileHasNoParentFolder.getProject(), fileHasNoParentFolder, duration2));

    IFileData data2 = mock(IFileData.class);
    given(data2.get(IFileData.DATE)).willReturn(date2);
    given(data2.get(IFileData.DURATION)).willReturn(duration2);
    given(data2.get(IFileData.FILE)).willReturn(fileHasNoParentFolder);
    given(data2.get(IFileData.WORKSPACE)).willReturn(ws2);

    ICategoryProvider provider = mock(ICategoryProvider.class);
    given(provider.getSelected()).willReturn(asList(categories));
    ITreePathBuilder builder = create(provider);

    IFileDataProvider input = mock(IFileDataProvider.class);
    given(input.get()).willReturn(asList(data, data2));
    List<TreePath> actual = builder.build(input);

    assertThat(actual.size(), equalTo(expected.size()));
    assertThat(toString(actual, expected), actual, hasItems(expected.toArray(new TreePath[0])));
  }
コード例 #3
0
  @Override
  public void shouldRetainIdenticalPaths() {
    ICategory[] categories = {Category.DATE, Category.WORKSPACE};
    List<TreePath> expected = asList(newPath(date, ws, duration), newPath(date, ws, duration));

    ICategoryProvider provider = mock(ICategoryProvider.class);
    given(provider.getSelected()).willReturn(asList(categories));
    ITreePathBuilder builder = create(provider);

    IFileDataProvider input = mock(IFileDataProvider.class);
    given(input.get()).willReturn(asList(data, data));
    List<TreePath> actual = builder.build(input);

    assertThat(toString(actual, expected), actual, equalTo(expected));
  }