本文整理汇总了Java中org.hamcrest.core.IsEqual.equalTo方法的典型用法代码示例。如果您正苦于以下问题:Java IsEqual.equalTo方法的具体用法?Java IsEqual.equalTo怎么用?Java IsEqual.equalTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hamcrest.core.IsEqual
的用法示例。
在下文中一共展示了IsEqual.equalTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equalToOptional
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
public static <T> Matcher<Optional<T>> equalToOptional(final T operand) {
return new TypeSafeMatcher<Optional<T>>() {
private Matcher<T> equalTo;
@Override
protected boolean matchesSafely(Optional<T> t) {
if(t.isPresent()) {
equalTo = IsEqual.equalTo(t.get());
return equalTo.matches(operand);
}
return false;
}
@Override
public void describeTo(Description description) {
IsEqual.equalTo(equalTo).describeTo(description);
}
};
}
示例2: testLoadObjectsByIds_ExpectManyLoadByLongsOk
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
@Test
public void testLoadObjectsByIds_ExpectManyLoadByLongsOk() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
EasyCrudService service = Mockito.mock(EasyCrudService.class);
when(fixture.getEasyCrudServiceResolver().resolveByEntityType("dto1")).thenReturn(service);
Matcher<Query> matcher = IsEqual.equalTo(Query.n().in(HasId.FN_ID, new Long[] { 1L, 2L }));
PaginatedList mockret = new PaginatedList<>(new PagerParams(), Arrays.asList(new TestDto1(), new TestDto1()),
2);
when(service.query(any(PagerParams.class), argThat(matcher))).thenReturn(mockret);
List<HasId> ret = fixture.loadObjectsByIds(ids(1L, 2L), "dto1");
assertNotNull(ret);
assertEquals(2, ret.size());
}
示例3: testLoadObjectsByIds_ExpectManyLoadByStrings
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
@Test
public void testLoadObjectsByIds_ExpectManyLoadByStrings() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
EasyCrudService service = Mockito.mock(EasyCrudService.class);
when(fixture.getEasyCrudServiceResolver().resolveByEntityType("dto1")).thenReturn(service);
Matcher<Query> matcher = IsEqual.equalTo(Query.n().in(HasId.FN_ID, new String[] { "s1", "s2" }));
PaginatedList mockret = new PaginatedList<>(new PagerParams(), Arrays.asList(new TestDto1(), new TestDto1()),
2);
when(service.query(any(PagerParams.class), argThat(matcher))).thenReturn(mockret);
List<HasId> ret = fixture.loadObjectsByIds(ids("s1", "s2"), "dto1");
assertNotNull(ret);
assertEquals(2, ret.size());
}
示例4: matcherFor
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
private Matcher<?> matcherFor(Object value) {
if (value instanceof Matcher<?>) {
return (Matcher<?>) value;
} else if (value == null) {
return IsNull.nullValue();
} else {
return IsEqual.equalTo(value);
}
}
示例5: istGleich
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
public static <T> Matcher<T> istGleich(T operand) {
return IsEqual.<T> equalTo(operand);
}
示例6: equalTo
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
public static <T> Matcher<T> jestRówno(T operand) {
return IsEqual.<T> equalTo(operand);
}
示例7: isString
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
public static Matcher<DatabaseValue> isString(String expected) {
return IsEqual.equalTo(string(expected));
}
示例8: isList
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
public static Matcher<DatabaseValue> isList(String ... expected) {
return IsEqual.equalTo(list(expected));
}
示例9: isSet
import org.hamcrest.core.IsEqual; //导入方法依赖的package包/类
public static Matcher<DatabaseValue> isSet(String ... expected) {
return IsEqual.equalTo(set(expected));
}