类org.mockito.internal.matchers.GreaterThan源码实例Demo

下面列出了怎么用org.mockito.internal.matchers.GreaterThan的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: mail-importer   文件: JavaxMailStorageTest.java
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;
}
 
@Test
public void testCreateOrganization() throws Exception {
	
	// 1. Only required input field is name
	CreateOrganizationDTO organizationDto = new CreateOrganizationDTO();
	organizationDto.setName("Test Organization 1"); 
	    	 
	mockMvc.perform(post(URI_ADD_ORGANIZATION)
			.content(asJsonString(organizationDto))
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
		.andExpect(status().isOk())
		.andExpect(jsonPath("$.organization.id", new GreaterThan<Integer>(0))) 
		.andExpect(jsonPath("$.organization.name",is("Test Organization 1"))) 
		.andExpect(jsonPath("$.organization.category",is("N"))) // default category is N
		.andExpect(jsonPath("$.organization.status",is("A"))); // default status is A
	
	// 2. Tests all the fields
	organizationDto = new CreateOrganizationDTO();
	organizationDto.setName("Test Organization 2"); 
	organizationDto.setWebsiteUrl("websiteUrl");
	organizationDto.setDescription("description");
	organizationDto.setAddress1("address1");
	organizationDto.setAddress2("address2");
	organizationDto.setCity("city");
	organizationDto.setState("state");
	organizationDto.setZip("zip");
	organizationDto.setCountry("country");
	organizationDto.setContactName("contactName");
	organizationDto.setContactPhone("contactPhone");
	organizationDto.setContactEmail("contactEmail");
	organizationDto.setCategory("O");
	
	mockMvc.perform(post(URI_ADD_ORGANIZATION)
			.content(asJsonString(organizationDto))
			.contentType(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON))
		.andExpect(status().isOk())
		.andExpect(jsonPath("$.organization.id", new GreaterThan<Integer>(0))) 
		.andExpect(jsonPath("$.organization.name",is("Test Organization 2"))) 
		.andExpect(jsonPath("$.organization.websiteUrl",is("websiteUrl"))) 
		.andExpect(jsonPath("$.organization.description",is("description"))) 
		.andExpect(jsonPath("$.organization.address1",is("address1"))) 
		.andExpect(jsonPath("$.organization.address2",is("address2"))) 
		.andExpect(jsonPath("$.organization.city",is("city"))) 
		.andExpect(jsonPath("$.organization.state",is("state"))) 
		.andExpect(jsonPath("$.organization.zip",is("zip"))) 
		.andExpect(jsonPath("$.organization.country",is("country"))) 
		.andExpect(jsonPath("$.organization.contactName",is("contactName"))) 
		.andExpect(jsonPath("$.organization.contactPhone",is("contactPhone"))) 
		.andExpect(jsonPath("$.organization.contactEmail",is("contactEmail"))) 
		.andExpect(jsonPath("$.organization.category",is("O")))
		.andExpect(jsonPath("$.organization.status",is("A")))
.andExpect(jsonPath("$.organization.createdTime", is(nullValue())));
}
 
源代码3 项目: hadoop   文件: MetricsAsserts.java
/**
 * Assert that a long counter metric is greater than a value
 * @param name  of the metric
 * @param greater value of the metric should be greater than this
 * @param rb  the record builder mock used to getMetrics
 */
public static void assertCounterGt(String name, long greater,
                                   MetricsRecordBuilder rb) {
  Assert.assertThat("Bad value for metric " + name, getLongCounter(name, rb),
      new GreaterThan<Long>(greater));
}
 
源代码4 项目: hadoop   文件: MetricsAsserts.java
/**
 * Assert that a double gauge metric is greater than a value
 * @param name  of the metric
 * @param greater value of the metric should be greater than this
 * @param rb  the record builder mock used to getMetrics
 */
public static void assertGaugeGt(String name, double greater,
                                 MetricsRecordBuilder rb) {
  Assert.assertThat("Bad value for metric " + name, getDoubleGauge(name, rb),
      new GreaterThan<Double>(greater));
}
 
源代码5 项目: big-c   文件: MetricsAsserts.java
/**
 * Assert that a long counter metric is greater than a value
 * @param name  of the metric
 * @param greater value of the metric should be greater than this
 * @param rb  the record builder mock used to getMetrics
 */
public static void assertCounterGt(String name, long greater,
                                   MetricsRecordBuilder rb) {
  Assert.assertThat("Bad value for metric " + name, getLongCounter(name, rb),
      new GreaterThan<Long>(greater));
}
 
源代码6 项目: big-c   文件: MetricsAsserts.java
/**
 * Assert that a double gauge metric is greater than a value
 * @param name  of the metric
 * @param greater value of the metric should be greater than this
 * @param rb  the record builder mock used to getMetrics
 */
public static void assertGaugeGt(String name, double greater,
                                 MetricsRecordBuilder rb) {
  Assert.assertThat("Bad value for metric " + name, getDoubleGauge(name, rb),
      new GreaterThan<Double>(greater));
}
 
源代码7 项目: astor   文件: AdditionalMatchers.java
/**
 * comparable argument greater than the given value.
 * <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 gt(Comparable<T> value) {
    return reportMatcher(new GreaterThan<T>(value)).<T>returnNull();
}
 
源代码8 项目: astor   文件: AdditionalMatchers.java
/**
 * byte argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static byte gt(byte value) {
    return reportMatcher(new GreaterThan<Byte>(value)).returnZero();
}
 
源代码9 项目: astor   文件: AdditionalMatchers.java
/**
 * double argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static double gt(double value) {
    return reportMatcher(new GreaterThan<Double>(value)).returnZero();
}
 
源代码10 项目: astor   文件: AdditionalMatchers.java
/**
 * float argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static float gt(float value) {
    return reportMatcher(new GreaterThan<Float>(value)).returnZero();
}
 
源代码11 项目: astor   文件: AdditionalMatchers.java
/**
 * int argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static int gt(int value) {
    return reportMatcher(new GreaterThan<Integer>(value)).returnZero();
}
 
源代码12 项目: astor   文件: AdditionalMatchers.java
/**
 * long argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static long gt(long value) {
    return reportMatcher(new GreaterThan<Long>(value)).returnZero();
}
 
源代码13 项目: astor   文件: AdditionalMatchers.java
/**
 * short argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static short gt(short value) {
    return reportMatcher(new GreaterThan<Short>(value)).returnZero();
}
 
源代码14 项目: astor   文件: AdditionalMatchers.java
/**
 * comparable argument greater than the given value.
 * <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 gt(Comparable<T> value) {
    return reportMatcher(new GreaterThan<T>(value)).<T>returnNull();
}
 
源代码15 项目: astor   文件: AdditionalMatchers.java
/**
 * byte argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static byte gt(byte value) {
    return reportMatcher(new GreaterThan<Byte>(value)).returnZero();
}
 
源代码16 项目: astor   文件: AdditionalMatchers.java
/**
 * double argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static double gt(double value) {
    return reportMatcher(new GreaterThan<Double>(value)).returnZero();
}
 
源代码17 项目: astor   文件: AdditionalMatchers.java
/**
 * float argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static float gt(float value) {
    return reportMatcher(new GreaterThan<Float>(value)).returnZero();
}
 
源代码18 项目: astor   文件: AdditionalMatchers.java
/**
 * int argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static int gt(int value) {
    return reportMatcher(new GreaterThan<Integer>(value)).returnZero();
}
 
源代码19 项目: astor   文件: AdditionalMatchers.java
/**
 * long argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static long gt(long value) {
    return reportMatcher(new GreaterThan<Long>(value)).returnZero();
}
 
源代码20 项目: astor   文件: AdditionalMatchers.java
/**
 * short argument greater than the given value.
 * <p>
 * See examples in javadoc for {@link AdditionalMatchers} class
 * 
 * @param value
 *            the given value.
 * @return <code>0</code>.
 */
public static short gt(short value) {
    return reportMatcher(new GreaterThan<Short>(value)).returnZero();
}
 
 类所在包
 同包方法