use of org.jmock.Expectations in project jewelcli by lexicalscope.
the class TestArgumentValidatorImpl method testMultipleValue.
@Test
@Ignore
public void testMultipleValue() throws ArgumentValidationException {
context.checking(new Expectations() {
{
oneOf(specification).isSpecified("name");
will(returnValue(true));
oneOf(specification).getSpecification("name");
will(returnValue(option));
oneOf(option).isHelpOption();
will(returnValue(false));
oneOf(option).allowedThisManyValues(2);
will(returnValue(true));
oneOf(option).allowedValue("a");
will(returnValue(true));
oneOf(option).allowedValue("b");
will(returnValue(true));
oneOf(validationErrorBuilder).validate();
oneOf(specification).getMandatoryOptions();
will(returnValue($.asList(option)));
oneOf(validationErrorBuilder).validate();
}
});
argumentValidator.processOption("name", asList("a", "b"));
argumentValidator.finishedProcessing();
}
use of org.jmock.Expectations in project gradle by gradle.
the class DefaultDomainObjectCollectionTest method callsClosureWithNewObjectAsParameterWhenObjectAdded.
@Test
public void callsClosureWithNewObjectAsParameterWhenObjectAdded() {
final TestClosure closure = context.mock(TestClosure.class);
context.checking(new Expectations() {
{
oneOf(closure).call("a");
}
});
container.whenObjectAdded(TestUtil.toClosure(closure));
container.add("a");
}
use of org.jmock.Expectations in project gradle by gradle.
the class DefaultDomainObjectCollectionTest method callsClosureWithRemovedObjectAsParameterWhenObjectRemoved.
@Test
public void callsClosureWithRemovedObjectAsParameterWhenObjectRemoved() {
final TestClosure closure = context.mock(TestClosure.class);
container.add("a");
context.checking(new Expectations() {
{
oneOf(closure).call("a");
}
});
container.whenObjectRemoved(TestUtil.toClosure(closure));
container.remove("a");
}
use of org.jmock.Expectations in project gradle by gradle.
the class DefaultDomainObjectCollectionTest method filteredCollectionExecutesActionWhenMatchingObjectAdded.
@Test
public void filteredCollectionExecutesActionWhenMatchingObjectAdded() {
@SuppressWarnings("unchecked") final Action<CharSequence> action = context.mock(Action.class);
context.checking(new Expectations() {
{
oneOf(action).execute("a");
}
});
Spec<CharSequence> spec = new Spec<CharSequence>() {
public boolean isSatisfiedBy(CharSequence element) {
return !element.equals("b");
}
};
container.matching(spec).whenObjectAdded(action);
container.add("a");
container.add("b");
}
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"));
}
Aggregations