Java 类org.hamcrest.FeatureMatcher 实例源码
项目:cgarbs-javalib-test
文件:Swing.java
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!
}
};
}
项目:cgarbs-javalib-test
文件:Swing.java
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!
}
};
}
项目:asakusafw-compiler
文件:ResourceTestRoot.java
/**
* 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;
}
};
}
项目:twintip-spring-web
文件:SchemaResourceTest.java
@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);
}
}
}));
}
项目:GitHub
文件:CompilerWarningIT.java
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);
}
};
}
项目:raml-java-tools
文件:ParameterSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:TypeSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:TypeSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:TypeSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:TypeSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:TypeSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:EntryMatchers.java
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();
}
};
}
项目:raml-java-tools
文件:FieldSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:FieldSpecMatchers.java
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();
}
};
}
项目:raml-java-tools
文件:FieldSpecMatchers.java
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;
}
};
}
项目:raml-java-tools
文件:MethodSpecMatchers.java
public static Matcher<MethodSpec> methodName(Matcher<String> match) {
return new FeatureMatcher<MethodSpec, String>(match, "method name", "method name") {
@Override
protected String featureValueOf(MethodSpec actual) {
return actual.name;
}
};
}
项目:raml-java-tools
文件:MethodSpecMatchers.java
public static<K extends TypeName> Matcher<MethodSpec> returnType(Matcher<K> match) {
return new FeatureMatcher<MethodSpec, K>(match, "return type", "return type") {
@Override
protected K featureValueOf(MethodSpec actual) {
return (K)actual.returnType;
}
};
}
项目:raml-java-tools
文件:MethodSpecMatchers.java
public static Matcher<MethodSpec> codeContent(Matcher<String> match) {
return new FeatureMatcher<MethodSpec, String>(match, "method content", "method content") {
@Override
protected String featureValueOf(MethodSpec actual) {
return actual.code.toString();
}
};
}
项目:raml-java-tools
文件:MethodSpecMatchers.java
public static Matcher<MethodSpec> parameters(Matcher<Iterable<? extends ParameterSpec>> memberMatcher) {
return new FeatureMatcher<MethodSpec, Iterable<? extends ParameterSpec>>(memberMatcher, "parameter", "parameter") {
@Override
protected Iterable<? extends ParameterSpec> featureValueOf(MethodSpec actual) {
return actual.parameters;
}
};
}
项目:HotaruFX
文件:HotaruLexerTest.java
Matcher<Token> tokenId(Matcher<HotaruTokenId> matcher) {
return new FeatureMatcher<Token, HotaruTokenId>(matcher, "tokenId", "tokenId") {
@Override
protected HotaruTokenId featureValueOf(Token actual) {
return actual.getType();
}
};
}
项目:spring-cloud-dashboard
文件:Proposals.java
static org.hamcrest.Matcher<CompletionProposal> proposalThat(org.hamcrest.Matcher<String> matcher) {
return new FeatureMatcher<CompletionProposal, String>(matcher, "a proposal whose text", "text") {
@Override
protected String featureValueOf(CompletionProposal actual) {
return actual.getText();
}
};
}
项目:oma-riista-web
文件:MobileAnnouncementFeatureTest.java
private static Matcher<MobileAnnouncementDTO> hasAnnouncementBody(Matcher<String> childMatcher) {
return new FeatureMatcher<MobileAnnouncementDTO, String>(childMatcher, "body", "body") {
@Override
protected String featureValueOf(MobileAnnouncementDTO actual) {
return actual.getBody();
}
};
}
项目:oma-riista-web
文件:MobileAnnouncementFeatureTest.java
private static Matcher<MobileAnnouncementDTO> hasAnnouncementSubject(Matcher<String> childMatcher) {
return new FeatureMatcher<MobileAnnouncementDTO, String>(childMatcher, "subject", "subject") {
@Override
protected String featureValueOf(MobileAnnouncementDTO actual) {
return actual.getSubject();
}
};
}
项目:oma-riista-web
文件:MobileAnnouncementFeatureTest.java
private static Matcher<MobileAnnouncementDTO> hasAnnouncementId(Matcher<Long> childMatcher) {
return new FeatureMatcher<MobileAnnouncementDTO, Long>(childMatcher, "id", "id") {
@Override
protected Long featureValueOf(MobileAnnouncementDTO actual) {
return actual.getId();
}
};
}
项目:oma-riista-web
文件:AnnouncementMatcher.java
public static FeatureMatcher<ListAnnouncementDTO, String> hasBody(final String expected) {
return new FeatureMatcher<ListAnnouncementDTO, String>(equalTo(expected), "body", "body") {
@Override
protected String featureValueOf(final ListAnnouncementDTO announcement) {
return announcement.getBody();
}
};
}
项目:oma-riista-web
文件:AnnouncementMatcher.java
public static FeatureMatcher<ListAnnouncementDTO, String> hasSubject(final String expected) {
return new FeatureMatcher<ListAnnouncementDTO, String>(equalTo(expected), "subject", "subject") {
@Override
protected String featureValueOf(final ListAnnouncementDTO announcement) {
return announcement.getSubject();
}
};
}
项目:oma-riista-web
文件:AnnouncementMatcher.java
public static FeatureMatcher<ListAnnouncementDTO, AnnouncementSenderType> hasSenderType(final AnnouncementSenderType expected) {
return new FeatureMatcher<ListAnnouncementDTO, AnnouncementSenderType>(equalTo(expected), "senderType", "senderType") {
@Override
protected AnnouncementSenderType featureValueOf(final ListAnnouncementDTO announcement) {
return announcement.getSenderType();
}
};
}
项目:oma-riista-web
文件:AnnouncementMatcher.java
public static FeatureMatcher<ListAnnouncementDTO, Map<String, String>> hasFromOrganisation(final Organisation expected) {
return new FeatureMatcher<ListAnnouncementDTO, Map<String, String>>(equalTo(expected.getNameLocalisation().asMap()), "fromOrganisation", "fromOrganisation") {
@Override
protected Map<String, String> featureValueOf(final ListAnnouncementDTO announcement) {
return announcement.getFromOrganisation().getName();
}
};
}
项目:oma-riista-web
文件:OccupationMatchers.java
public static Matcher<Occupation> hasOccupationType(final Matcher<OccupationType> childMatcher) {
return new FeatureMatcher<Occupation, OccupationType>(childMatcher, "occupationType", "occupationType") {
@Override
protected OccupationType featureValueOf(Occupation actual) {
return actual.getOccupationType();
}
};
}
项目:oma-riista-web
文件:OccupationMatchers.java
public static Matcher<Occupation> hasPersonId(final Matcher<Long> childMatcher) {
return new FeatureMatcher<Occupation, Long>(childMatcher, "personId", "personId") {
@Override
protected Long featureValueOf(Occupation actual) {
return F.getId(actual.getPerson());
}
};
}
项目:oma-riista-web
文件:OccupationMatchers.java
public static Matcher<Occupation> hasCallOrder(final Matcher<Integer> childMatcher) {
return new FeatureMatcher<Occupation, Integer>(childMatcher, "callOrder", "callOrder") {
@Override
protected Integer featureValueOf(Occupation actual) {
return actual.getCallOrder();
}
};
}
项目:oma-riista-web
文件:CommonMatchers.java
public static <T extends HasID<Long>> Matcher<T> hasId(Matcher<Long> childMatcher) {
return new FeatureMatcher<T, Long>(childMatcher, "id", "id") {
@Override
protected Long featureValueOf(T actual) {
return actual.getId();
}
};
}
项目:JCVD
文件:StorableFenceMatcher.java
public static Matcher<StorableFence> isNotAnd() {
return new FeatureMatcher<StorableFence, Boolean>(equalTo(true), "andFences empty", "andFences empty") {
@Override
protected Boolean featureValueOf(StorableFence fence) {
return fence.getAndFences().isEmpty();
}
};
}
项目:JCVD
文件:StorableFenceMatcher.java
public static Matcher<StorableFence> isNotOr() {
return new FeatureMatcher<StorableFence, Boolean>(equalTo(true), "orFences empty", "orFences empty") {
@Override
protected Boolean featureValueOf(StorableFence fence) {
return fence.getOrFences().isEmpty();
}
};
}
项目:JCVD
文件:StorableFenceMatcher.java
public static Matcher<StorableFence> isNotNot() {
return new FeatureMatcher<StorableFence, Boolean>(equalTo(true), "notFence is null", "notFence is null") {
@Override
protected Boolean featureValueOf(StorableFence fence) {
return fence.getNotFence() == null;
}
};
}
项目:vertx-redis
文件:RedisCommandClientTest.java
private static DeliveryOptions withTimeout(final Long expectedTimeout) {
return MockitoHamcrest.argThat(new FeatureMatcher<DeliveryOptions, Long>(IsEqual.equalTo(expectedTimeout), "timeout", "timeout") {
@Override
protected Long featureValueOf(DeliveryOptions deliveryOptions) {
return deliveryOptions.getSendTimeout();
}
});
}
项目:vertx-redis
文件:RedisCommandTransactionTest.java
private static DeliveryOptions withTimeout(final Long expectedTimeout) {
return MockitoHamcrest.argThat(new FeatureMatcher<DeliveryOptions, Long>(IsEqual.equalTo(expectedTimeout), "timeout", "timeout") {
@Override
protected Long featureValueOf(DeliveryOptions deliveryOptions) {
return deliveryOptions.getSendTimeout();
}
});
}
项目:java-restify
文件:DefaultEndpointResponseErrorFallbackTest.java
private <T> FeatureMatcher<RestifyEndpointResponseException, T> method(Function<RestifyEndpointResponseException, T> function, Matcher<T> matcher) {
return new FeatureMatcher<RestifyEndpointResponseException, T>(matcher, "method", "value") {
@Override
protected T featureValueOf(RestifyEndpointResponseException actual) {
return function.apply(actual);
}
};
}
项目:Mondo
文件:RecordedRequestMatchers.java
public static Matcher<RecordedRequest> withPath(String path) {
return new FeatureMatcher<RecordedRequest, String>(equalTo(path), "request path", "path") {
@Override
protected String featureValueOf(RecordedRequest recordedRequest) {
return recordedRequest.getPath();
}
};
}
项目:docker-compose-rule
文件:IOMatchers.java
public static Matcher<File> fileWithConents(Matcher<String> contentsMatcher) {
return new FeatureMatcher<File, String>(contentsMatcher, "file contents", "file contents") {
@Override
protected String featureValueOf(File file) {
try {
return FileUtils.readFileToString(file, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}