Search in sources :

Example 36 with Expectations

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();
}
Also used : Expectations(org.jmock.Expectations) BuildClientMetaData(org.gradle.initialization.BuildClientMetaData) Sequence(org.jmock.Sequence) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) Test(org.junit.Test)

Example 37 with Expectations

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);
}
Also used : Expectations(org.jmock.Expectations) PropertyReportRenderer(org.gradle.api.tasks.diagnostics.internal.PropertyReportRenderer) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Before(org.junit.Before)

Example 38 with Expectations

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);
}
Also used : Expectations(org.jmock.Expectations) Sequence(org.jmock.Sequence) Test(org.junit.Test)

Example 39 with Expectations

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);
}
Also used : Expectations(org.jmock.Expectations) List(java.util.List) Rule(org.gradle.api.Rule) Sequence(org.jmock.Sequence) Test(org.junit.Test)

Example 40 with Expectations

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;
}
Also used : Expectations(org.jmock.Expectations) TaskDependency(org.gradle.api.tasks.TaskDependency) Task(org.gradle.api.Task) Action(org.jmock.api.Action) Description(org.hamcrest.Description) Invocation(org.jmock.api.Invocation)

Aggregations

Expectations (org.jmock.Expectations)651 Test (org.junit.Test)443 UnitTest (org.apache.geode.test.junit.categories.UnitTest)109 File (java.io.File)41 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)41 InternalCache (org.apache.geode.internal.cache.InternalCache)35 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)33 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)32 Resource (org.apache.sling.api.resource.Resource)31 RewriterResponse (org.apache.sling.security.impl.ContentDispositionFilter.RewriterResponse)31 ArrayList (java.util.ArrayList)27 DiskStore (org.apache.geode.cache.DiskStore)23 ValueMap (org.apache.sling.api.resource.ValueMap)21 Before (org.junit.Before)20 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)20 Sequence (org.jmock.Sequence)19 Cache (org.apache.geode.cache.Cache)18 Region (org.apache.geode.cache.Region)18 DistributedMember (org.apache.geode.distributed.DistributedMember)18 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)17