Search in sources :

Example 16 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 17 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 18 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 19 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)

Example 20 with Expectations

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

the class DefaultDomainObjectCollectionTest method callsRemoveActionWhenObjectRemoved.

@Test
public void callsRemoveActionWhenObjectRemoved() {
    @SuppressWarnings("unchecked") final Action<CharSequence> action = context.mock(Action.class);
    final String original = "a";
    context.checking(new Expectations() {

        {
            oneOf(action).execute(with(sameInstance(original)));
        }
    });
    container.whenObjectRemoved(action);
    container.add(original);
    assertTrue(container.remove(original));
}
Also used : Expectations(org.jmock.Expectations) 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)46 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