下面列出了怎么用org.mockito.internal.matchers.LessOrEqual的API类实例代码及写法,或者点击链接到github查看源代码。
private JavaxMailFolder makeMockFolderWithMessages(int numMessages,
JavaxMailFolder... folders) {
JavaxMailFolder javaxMailFolder = mock(JavaxMailFolder.class);
when(javaxMailFolder.getType())
.thenReturn(Folder.HOLDS_FOLDERS | Folder.HOLDS_MESSAGES);
when(javaxMailFolder.getMessageCount())
.thenReturn(numMessages);
when(javaxMailFolder.getMessage(Matchers.intThat(new LessOrEqual<>(numMessages))))
.thenReturn(mock(JavaxMailMessage.class));
when(javaxMailFolder.getMessage(Matchers.intThat(new GreaterThan<>(numMessages))))
.thenThrow(new RuntimeMessagingException(
new MessagingException("crap")));
when(javaxMailFolder.list()).thenReturn(folders);
return javaxMailFolder;
}
private void assertTextNodesLayInsideBoxBounds( RenderBox box, List<RenderableText> texts ) {
assertFalse( texts.isEmpty() );
GreaterOrEqual<Long> greaterThanBoxX = new GreaterOrEqual<Long>( box.getX() );
LessOrEqual<Long> lessThanBoxWidth = new LessOrEqual<Long>( box.getWidth() );
for ( RenderableText text : texts ) {
assertThat( text.getX(), is( greaterThanBoxX ) );
assertThat( text.getWidth(), is( lessThanBoxWidth ) );
}
}
/**
* comparable argument less than or equal the given value details.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>null</code>.
*/
public static <T extends Comparable<T>> T leq(Comparable<T> value) {
return reportMatcher(new LessOrEqual<T>(value)).<T>returnNull();
}
/**
* byte argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static byte leq(byte value) {
return reportMatcher(new LessOrEqual<Byte>(value)).returnZero();
}
/**
* double argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static double leq(double value) {
return reportMatcher(new LessOrEqual<Double>(value)).returnZero();
}
/**
* float argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static float leq(float value) {
return reportMatcher(new LessOrEqual<Float>(value)).returnZero();
}
/**
* int argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static int leq(int value) {
return reportMatcher(new LessOrEqual<Integer>(value)).returnZero();
}
/**
* long argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static long leq(long value) {
return reportMatcher(new LessOrEqual<Long>(value)).returnZero();
}
/**
* short argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static short leq(short value) {
return reportMatcher(new LessOrEqual<Short>(value)).returnZero();
}
/**
* comparable argument less than or equal the given value details.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>null</code>.
*/
public static <T extends Comparable<T>> T leq(Comparable<T> value) {
return reportMatcher(new LessOrEqual<T>(value)).<T>returnNull();
}
/**
* byte argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static byte leq(byte value) {
return reportMatcher(new LessOrEqual<Byte>(value)).returnZero();
}
/**
* double argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static double leq(double value) {
return reportMatcher(new LessOrEqual<Double>(value)).returnZero();
}
/**
* float argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static float leq(float value) {
return reportMatcher(new LessOrEqual<Float>(value)).returnZero();
}
/**
* int argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static int leq(int value) {
return reportMatcher(new LessOrEqual<Integer>(value)).returnZero();
}
/**
* long argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static long leq(long value) {
return reportMatcher(new LessOrEqual<Long>(value)).returnZero();
}
/**
* short argument less than or equal to the given value.
* <p>
* See examples in javadoc for {@link AdditionalMatchers} class
*
* @param value
* the given value.
* @return <code>0</code>.
*/
public static short leq(short value) {
return reportMatcher(new LessOrEqual<Short>(value)).returnZero();
}