Exemple #1
0
  @Test
  public void passesEachRuleToRenderer() throws IOException {
    context.checking(
        new Expectations() {
          {
            Rule rule1 = context.mock(Rule.class);
            Rule rule2 = context.mock(Rule.class);

            List<String> defaultTasks = toList();
            allowing(project).getDefaultTasks();
            will(returnValue(defaultTasks));

            allowing(taskContainer).realize();

            allowing(taskContainer).size();
            will(returnValue(0));

            allowing(taskContainer).iterator();
            will(returnIterator(toLinkedSet()));

            allowing(implicitTasks).iterator();
            will(returnIterator(toLinkedSet()));

            one(taskContainer).getRules();
            will(returnValue(toList(rule1, rule2)));

            Sequence sequence = context.sequence("seq");

            one(renderer).showDetail(false);
            inSequence(sequence);

            one(renderer).addDefaultTasks(defaultTasks);
            inSequence(sequence);

            one(renderer).completeTasks();
            inSequence(sequence);

            one(renderer).addRule(rule1);
            inSequence(sequence);

            one(renderer).addRule(rule2);
            inSequence(sequence);
          }
        });

    task.generate(project);
  }
Exemple #2
0
  @Before
  public void setup() {
    context.checking(
        new Expectations() {
          {
            allowing(project).absoluteProjectPath("list");
            will(returnValue(":path"));
            allowing(project).getTasks();
            will(returnValue(taskContainer));
            allowing(project).getConvention();
            will(returnValue(null));
            allowing(project).getAllprojects();
            will(returnValue(toSet(project)));
            allowing(project).getSubprojects();
            will(returnValue(toSet()));
          }
        });

    task = TestUtil.create(temporaryFolder).task(TaskReportTask.class);
    task.setRenderer(renderer);
  }
Exemple #3
0
  @Test
  public void groupsTasksByTaskGroupAndPassesTasksToTheRenderer() throws IOException {
    context.checking(
        new Expectations() {
          {
            Task task1 = task("a", "group a");
            Task task2 = task("b", "group b");
            Task task3 = task("c");
            Task task4 = task("d", "group b", task3);

            List<String> testDefaultTasks = toList("defaultTask1", "defaultTask2");
            allowing(project).getDefaultTasks();
            will(returnValue(testDefaultTasks));

            allowing(taskContainer).realize();

            allowing(taskContainer).size();
            will(returnValue(4));

            allowing(taskContainer).iterator();
            will(returnIterator(toLinkedSet(task2, task3, task4, task1)));

            allowing(implicitTasks).iterator();
            will(returnIterator(toLinkedSet()));

            allowing(taskContainer).getRules();
            will(returnValue(toList()));

            Sequence sequence = context.sequence("seq");

            one(renderer).showDetail(false);
            inSequence(sequence);

            one(renderer).addDefaultTasks(testDefaultTasks);
            inSequence(sequence);

            one(renderer).startTaskGroup("group a");
            inSequence(sequence);

            one(renderer).addTask(with(isTask(task1)));
            inSequence(sequence);

            one(renderer).startTaskGroup("group b");
            inSequence(sequence);

            one(renderer).addTask(with(isTask(task2)));
            inSequence(sequence);

            one(renderer).addTask(with(isTask(task4)));
            inSequence(sequence);

            one(renderer).addChildTask(with(isTask(task3)));
            inSequence(sequence);

            one(renderer).completeTasks();
            inSequence(sequence);
          }
        });

    task.generate(project);
  }