Ejemplo n.º 1
0
  private FileCopyDetails expectActionExecutedWhenFileVisited() {
    final Collector<FileCopyDetails> collectDetails = collector();
    final Action<FileCopyDetails> action = context.mock(Action.class, "action1");

    context.checking(
        new Expectations() {
          {
            Sequence seq = context.sequence("seq");
            one(delegate).visitSpec(spec);
            inSequence(seq);

            allowing(spec).getAllCopyActions();
            will(returnValue(toList(action)));

            one(action).execute(with(notNullValue(FileCopyDetails.class)));
            inSequence(seq);
            will(collectTo(collectDetails));

            one(delegate).visitFile(with(not(sameInstance(details))));
            inSequence(seq);
          }
        });

    visitor.visitSpec(spec);
    visitor.visitFile(details);

    FileCopyDetails copyDetails = collectDetails.get();
    return copyDetails;
  }
Ejemplo n.º 2
0
  private FileVisitDetails expectSpecAndDirVisited() {
    final Collector<FileVisitDetails> collector = collector();

    context.checking(
        new Expectations() {
          {
            one(delegate).visitSpec(spec);
            one(delegate).visitDir(with(not(sameInstance(details))));

            will(collectTo(collector));
          }
        });

    visitor.visitSpec(spec);
    visitor.visitDir(details);

    return collector.get();
  }
Ejemplo n.º 3
0
  @Test
  public void visitFileInvokesEachCopyAction() {
    final Action<FileCopyDetails> action1 = context.mock(Action.class, "action1");
    final Action<FileCopyDetails> action2 = context.mock(Action.class, "action2");
    final Collector<FileCopyDetails> collectDetails1 = collector();
    final Collector<Object> collectDetails2 = collector();
    final Collector<Object> collectDetails3 = collector();

    context.checking(
        new Expectations() {
          {
            Sequence seq = context.sequence("seq");
            one(delegate).visitSpec(spec);
            inSequence(seq);

            allowing(spec).getAllCopyActions();
            will(returnValue(toList(action1, action2)));

            one(action1).execute(with(notNullValue(FileCopyDetails.class)));
            inSequence(seq);
            will(collectTo(collectDetails1));

            one(action2).execute(with(notNullValue(FileCopyDetails.class)));
            inSequence(seq);
            will(collectTo(collectDetails2));

            one(delegate).visitFile(with(not(sameInstance(details))));
            inSequence(seq);
            will(collectTo(collectDetails3));
          }
        });

    visitor.visitSpec(spec);
    visitor.visitFile(details);

    assertThat(collectDetails1.get(), sameInstance(collectDetails2.get()));
    assertThat(collectDetails1.get(), sameInstance(collectDetails3.get()));
  }
Ejemplo n.º 4
0
  @Test
  public void copyActionCanExcludeFile() {
    final Action<FileCopyDetails> action1 = context.mock(Action.class, "action1");
    final Action<FileCopyDetails> action2 = context.mock(Action.class, "action2");

    context.checking(
        new Expectations() {
          {
            Sequence seq = context.sequence("seq");
            one(delegate).visitSpec(spec);
            inSequence(seq);

            allowing(spec).getAllCopyActions();
            will(returnValue(toList(action1, action2)));

            one(action1).execute(with(notNullValue(FileCopyDetails.class)));
            inSequence(seq);
            will(excludeFile());
          }
        });

    visitor.visitSpec(spec);
    visitor.visitFile(details);
  }