本文整理汇总了Java中org.hamcrest.FeatureMatcher类的典型用法代码示例。如果您正苦于以下问题:Java FeatureMatcher类的具体用法?Java FeatureMatcher怎么用?Java FeatureMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FeatureMatcher类属于org.hamcrest包,在下文中一共展示了FeatureMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasBorderTitle
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<Component> hasBorderTitle(final Matcher<String> m)
{
return new FeatureMatcher<Component, String>(m, "title", "title") {
@Override
protected String featureValueOf(Component actual)
{
if (actual instanceof JPanel)
{
Border border = ((JPanel) actual).getBorder();
if (border == null)
{
return null;
}
if (border instanceof TitledBorder)
{
return ((TitledBorder) border).getTitle();
}
return "BORDER CLASS " + border.getClass() + " DOES NOT WORK HERE"; // fixme: stupid!
}
return "CLASS " + actual.getClass() + " DOES NOT WORK HERE"; // fixme: stupid!
}
};
}
示例2: hasValue
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<Component> hasValue(final Matcher<String> m)
{
return new FeatureMatcher<Component, String>(m, "value", "value") {
@Override
protected String featureValueOf(Component actual)
{
if (actual instanceof JTextField)
{
return ((JTextField) actual).getText();
}
if (actual instanceof JLabel)
{
return ((JLabel) actual).getText();
}
return "CLASS " + actual.getClass() + " DOES NOT WORK HERE"; // fixme: stupid!
}
};
}
示例3: hasContents
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
/**
* Returns a matcher whether the item has the specified contents or not.
* @param value the expected contents
* @return the matcher
*/
public static Matcher<ResourceItem> hasContents(String value) {
return new FeatureMatcher<ResourceItem, String>(is(value), "has contents", "hasContents") {
@Override
protected String featureValueOf(ResourceItem actual) {
String contents = contents(actual);
try {
String provider = new String(dump(actual), ENCODING);
assertThat(provider, is(contents));
} catch (IOException e) {
throw new AssertionError(e);
}
return contents;
}
};
}
示例4: apiWithAcceptAsYaml
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
@Test
public void apiWithAcceptAsYaml() throws Exception {
final MediaType yaml = MediaType.parseMediaType("application/yaml");
final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
final JsonNode expected = mapper.readTree(yamlResource.getInputStream());
mvc.perform(request(HttpMethod.GET, API_PATH)
.accept(yaml))
.andExpect(content().contentType(yaml))
.andExpect(content().string(new FeatureMatcher<String, JsonNode>(equalTo(expected), "yaml", "yaml") {
@Override
protected JsonNode featureValueOf(String actual) {
try {
return mapper.readTree(actual);
} catch (IOException e) {
throw new AssertionError(e);
}
}
}));
}
示例5: hasMessage
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<Diagnostic<? extends JavaFileObject>> hasMessage( Matcher<String> messageMatcher ) {
return new FeatureMatcher<Diagnostic<? extends JavaFileObject>, String>(messageMatcher, "message", "message") {
@Override
protected String featureValueOf(Diagnostic<? extends JavaFileObject> actual) {
return actual.getMessage(Locale.ENGLISH);
}
};
}
示例6: type
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static <Q extends TypeName> Matcher<ParameterSpec> type(Matcher<Q> match) {
return new FeatureMatcher<ParameterSpec, Q>(match, "type name", "type name") {
@Override
protected Q featureValueOf(ParameterSpec actual) {
return (Q) actual.type;
}
};
}
示例7: name
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<TypeSpec> name(Matcher<String> match) {
return new FeatureMatcher<TypeSpec, String>(match, "type name", "type name") {
@Override
protected String featureValueOf(TypeSpec actual) {
return actual.name;
}
};
}
示例8: superInterfaces
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<TypeSpec> superInterfaces(Matcher<Iterable<? extends TypeName>> memberMatcher) {
return new FeatureMatcher<TypeSpec, Iterable<? extends TypeName>>(memberMatcher, "super interfaces", "super interfaces") {
@Override
protected Iterable<? extends TypeName> featureValueOf(TypeSpec actual) {
return actual.superinterfaces;
}
};
}
示例9: methods
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<TypeSpec> methods(Matcher<Iterable<? extends MethodSpec>> memberMatcher) {
return new FeatureMatcher<TypeSpec, Iterable<? extends MethodSpec>>(memberMatcher, "method", "method") {
@Override
protected Iterable<? extends MethodSpec> featureValueOf(TypeSpec actual) {
return actual.methodSpecs;
}
};
}
示例10: fields
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<TypeSpec> fields(Matcher<Iterable<? extends FieldSpec>> memberMatcher) {
return new FeatureMatcher<TypeSpec, Iterable<? extends FieldSpec>>(memberMatcher, "field", "field") {
@Override
protected Iterable<? extends FieldSpec> featureValueOf(TypeSpec actual) {
return actual.fieldSpecs;
}
};
}
示例11: innerTypes
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<TypeSpec> innerTypes(Matcher<Iterable<? extends TypeSpec>> typeMatcher) {
return new FeatureMatcher<TypeSpec, Iterable<? extends TypeSpec>>(typeMatcher, "inner type", "inner type") {
@Override
protected Iterable<? extends TypeSpec> featureValueOf(TypeSpec actual) {
return actual.typeSpecs;
}
};
}
示例12: key
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<Map.Entry<?, ?>> key(Matcher<?> matcher) {
return new FeatureMatcher<Map.Entry<?, ?>, Object>((Matcher<? super Object>) matcher, "key", "key") {
@Override
protected Object featureValueOf(Map.Entry<?, ?> actual) {
return actual.getKey();
}
};
}
示例13: fieldName
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<FieldSpec> fieldName(Matcher<String> match) {
return new FeatureMatcher<FieldSpec, String>(match, "field name", "field name") {
@Override
protected String featureValueOf(FieldSpec actual) {
return actual.name;
}
};
}
示例14: initializer
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static Matcher<FieldSpec> initializer(Matcher<String> match) {
return new FeatureMatcher<FieldSpec, String>(match, "field initializer", "field initializer") {
@Override
protected String featureValueOf(FieldSpec actual) {
return actual.initializer.toString();
}
};
}
示例15: fieldType
import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
public static <T extends TypeName> Matcher<FieldSpec> fieldType(Matcher<T> match) {
return new FeatureMatcher<FieldSpec, T>(match, "type name", "type name") {
@Override
protected T featureValueOf(FieldSpec actual) {
return (T) actual.type;
}
};
}