@Test
  public void copyActionCanChangeFileDestinationPath() {
    FileCopyDetails copyDetails = expectActionExecutedWhenFileVisited();

    RelativePath newPath = new RelativePath(true, "new");
    copyDetails.setRelativePath(newPath);
    assertThat(copyDetails.getRelativePath(), equalTo(newPath));

    copyDetails.setPath("/a/b");
    assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "a", "b")));

    copyDetails.setName("new name");
    assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "a", "new name")));
  }
  @Test
  public void initialRelativePathForFileIsSpecPathPlusFilePath() {
    FileCopyDetails copyDetails = expectActionExecutedWhenFileVisited();

    context.checking(
        new Expectations() {
          {
            allowing(spec).getDestPath();
            will(returnValue(new RelativePath(false, "spec")));
            allowing(details).getRelativePath();
            will(returnValue(new RelativePath(true, "file")));
          }
        });

    assertThat(copyDetails.getRelativePath(), equalTo(new RelativePath(true, "spec", "file")));
  }
Esempio n. 3
0
 public void execute(FileCopyDetails fileCopyDetails) {
   RelativePath path = fileCopyDetails.getRelativePath();
   path = path.replaceLastName(transformer.transform(path.getLastName()));
   fileCopyDetails.setRelativePath(path);
 }