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"));
}
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());
}
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");
}
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")));
}
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");
}
Aggregations