use of org.jmock.Expectations in project gradle by gradle.
the class AbstractReportTaskTest method completesRendererAtEndOfGeneration.
@Test
public void completesRendererAtEndOfGeneration() throws IOException {
context.checking(new Expectations() {
{
Sequence sequence = context.sequence("sequence");
one(renderer).setClientMetaData((BuildClientMetaData) with(notNullValue()));
inSequence(sequence);
one(renderer).setOutput((StyledTextOutput) with(notNullValue()));
inSequence(sequence);
one(renderer).startProject(project);
inSequence(sequence);
one(generator).run();
inSequence(sequence);
one(renderer).completeProject(project);
inSequence(sequence);
one(renderer).complete();
inSequence(sequence);
}
});
task.generate();
}
use of org.jmock.Expectations in project gradle by gradle.
the class PropertyReportTaskTest method setup.
@Before
public void setup() {
context.setImposteriser(ClassImposteriser.INSTANCE);
project = context.mock(ProjectInternal.class);
renderer = context.mock(PropertyReportRenderer.class);
context.checking(new Expectations() {
{
allowing(project).absoluteProjectPath("list");
will(returnValue(":path"));
allowing(project).getConvention();
will(returnValue(null));
}
});
task = TestUtil.create(temporaryFolder).task(PropertyReportTask.class);
task.setRenderer(renderer);
}
use of org.jmock.Expectations in project gradle by gradle.
the class PropertyReportTaskTest method doesNotShowContentsOfThePropertiesProperty.
@Test
public void doesNotShowContentsOfThePropertiesProperty() throws IOException {
context.checking(new Expectations() {
{
oneOf(project).getProperties();
will(returnValue(GUtil.map("prop", "value", "properties", "prop")));
Sequence sequence = context.sequence("seq");
oneOf(renderer).addProperty("prop", "value");
inSequence(sequence);
oneOf(renderer).addProperty("properties", "{...}");
inSequence(sequence);
}
});
task.generate(project);
}
use of org.jmock.Expectations in project gradle by gradle.
the class TaskReportTaskTest method passesEachRuleToRenderer.
@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);
}
use of org.jmock.Expectations in project gradle by gradle.
the class TaskReportTaskTest method task.
private Task task(final String name, final String taskGroup, final Task... dependencies) {
final Task task = context.mock(Task.class);
context.checking(new Expectations() {
{
allowing(task).getName();
will(returnValue(name));
allowing(task).getPath();
will(returnValue(':' + name));
allowing(task).getProject();
will(returnValue(project));
allowing(project).relativeProjectPath(':' + name);
will(returnValue(name));
allowing(task).getGroup();
will(returnValue(taskGroup));
allowing(task).compareTo(with(Matchers.notNullValue(Task.class)));
will(new Action() {
public Object invoke(Invocation invocation) throws Throwable {
Task other = (Task) invocation.getParameter(0);
return name.compareTo(other.getName());
}
public void describeTo(Description description) {
description.appendText("compare to");
}
});
TaskDependency dependency = context.mock(TaskDependency.class);
allowing(task).getTaskDependencies();
will(returnValue(dependency));
allowing(dependency).getDependencies(task);
will(returnValue(toSet(dependencies)));
}
});
return task;
}
Aggregations