Search in sources :

Example 71 with Expectations

use of org.jmock.Expectations in project gradle by gradle.

the class DefaultDomainObjectCollectionTest method callsVetoActionOnceBeforeCollectionIsRemoved.

@Test
public void callsVetoActionOnceBeforeCollectionIsRemoved() {
    final Action<Void> action = Cast.uncheckedCast(context.mock(Action.class));
    container.beforeChange(action);
    context.checking(new Expectations() {

        {
            oneOf(action).execute(null);
        }
    });
    container.removeAll(toList("a", "b"));
}
Also used : Expectations(org.jmock.Expectations) Action(org.gradle.api.Action) Test(org.junit.Test)

Example 72 with Expectations

use of org.jmock.Expectations in project gradle by gradle.

the class DefaultDomainObjectCollectionTest method callsVetoActionOnceBeforeCollectionIsIntersected.

@Test
public void callsVetoActionOnceBeforeCollectionIsIntersected() {
    final Action<Void> action = Cast.uncheckedCast(context.mock(Action.class));
    container.add("a");
    container.add("b");
    container.beforeChange(action);
    context.checking(new Expectations() {

        {
            oneOf(action).execute(null);
        }
    });
    container.retainAll(toList());
}
Also used : Expectations(org.jmock.Expectations) Action(org.gradle.api.Action) Test(org.junit.Test)

Example 73 with Expectations

use of org.jmock.Expectations in project gradle by gradle.

the class DefaultDomainObjectCollectionTest method callsVetoActionBeforeObjectIsAdded.

@Test
public void callsVetoActionBeforeObjectIsAdded() {
    final Action action = context.mock(Action.class);
    container.beforeChange(action);
    context.checking(new Expectations() {

        {
            oneOf(action).execute(null);
        }
    });
    container.add("a");
}
Also used : Expectations(org.jmock.Expectations) Action(org.gradle.api.Action) Test(org.junit.Test)

Example 74 with Expectations

use of org.jmock.Expectations in project gradle by gradle.

the class DefaultDomainObjectCollectionTest method objectIsNotAddedWhenVetoActionThrowsAnException.

@Test
public void objectIsNotAddedWhenVetoActionThrowsAnException() {
    final Action<Void> action = Cast.uncheckedCast(context.mock(Action.class));
    final RuntimeException failure = new RuntimeException();
    container.beforeChange(action);
    context.checking(new Expectations() {

        {
            oneOf(action).execute(null);
            will(throwException(failure));
        }
    });
    try {
        container.add("a");
        fail();
    } catch (RuntimeException e) {
        assertThat(e, sameInstance(failure));
    }
    assertThat(container, not(hasItem((CharSequence) "a")));
}
Also used : Expectations(org.jmock.Expectations) Action(org.gradle.api.Action) Test(org.junit.Test)

Example 75 with Expectations

use of org.jmock.Expectations in project gradle by gradle.

the class DefaultDomainObjectCollectionTest method callsVetoActionBeforeObjectIsRemoved.

@Test
public void callsVetoActionBeforeObjectIsRemoved() {
    final Action<Void> action = Cast.uncheckedCast(context.mock(Action.class));
    container.beforeChange(action);
    context.checking(new Expectations() {

        {
            oneOf(action).execute(null);
        }
    });
    container.remove("a");
}
Also used : Expectations(org.jmock.Expectations) Action(org.gradle.api.Action) Test(org.junit.Test)

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