org.xj4.jmock.JMockUtils Maven / Gradle / Ivy
/**
* Copyright 2008 Peach Jean Solutions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xj4.jmock;
import org.hamcrest.Matcher;
import org.jmock.Expectations;
import org.jmock.Mockery;
/**
* Created by IntelliJ IDEA.
* User: jbunting
* Date: Mar 8, 2008
* Time: 12:02:38 PM
* To change this template use File | Settings | File Templates.
*/
public class JMockUtils {
private JMockUtils() {
}
public static void mockComparable(Mockery context,
final T mock,
final Matcher less,
final Matcher equals,
final Matcher greater) {
context.checking(new Expectations() {{
if(less != null) {
allowing(mock).compareTo(with(less));
will(returnValue(-1));
}
if(equals != null) {
allowing(mock).compareTo(with(equals));
will(returnValue(0));
}
if(greater != null) {
allowing(mock).compareTo(with(greater));
will(returnValue(1));
}
}});
}
}