org.hamcrest.FeatureMatcher Java Examples
The following examples show how to use
org.hamcrest.FeatureMatcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestClientCallArgumentMatcher.java From ods-provisioning-app with Apache License 2.0 | 6 votes |
@Override public boolean matches(RestClientCall argument) { invalidMatcherList.clear(); mismatchDescription = new StringDescription(); for (Pair<FeatureMatcher, Function<RestClientCall, ?>> pair : featureMatcherList) { FeatureMatcher featureMatcher = pair.getLeft(); featureMatcher.describeMismatch(argument, mismatchDescription); if (!featureMatcher.matches(argument)) { Function<RestClientCall, ?> valueExtractor = pair.getRight(); Object apply = argument == null ? null : valueExtractor.apply(argument); invalidMatcherList.add(Pair.of(featureMatcher, apply)); } } boolean isValid = invalidMatcherList.size() == 0; if (isValid) { captureArgumentValues(argument); } return isValid; }
Example #2
Source File: RestClientCallArgumentMatcher.java From ods-provisioning-app with Apache License 2.0 | 6 votes |
public String toString() { if (invalidMatcherList.isEmpty()) { String validMatchers = featureMatcherList.stream() .map(Pair::getLeft) .map(BaseMatcher::toString) .collect(Collectors.joining(",")); return "All matchers suceeded: " + validMatchers; } Description description = new StringDescription(); // result.append("A ClientCall with the following properties:"); for (Pair<FeatureMatcher, Object> pair : invalidMatcherList) { FeatureMatcher invalidMatcher = pair.getLeft(); description.appendText("Expecting '"); invalidMatcher.describeTo(description); description.appendText("', but got values:").appendValue(pair.getRight()); } return description.toString(); }
Example #3
Source File: TestUtils.java From flo with Apache License 2.0 | 5 votes |
public static <T> Matcher<Task<? extends T>> taskId(Matcher<TaskId> taskIdMatcher) { return new FeatureMatcher<Task<? extends T>, TaskId>(taskIdMatcher, "Task with id", "taskId") { @Override protected TaskId featureValueOf(Task<? extends T> actual) { return actual.id(); } }; }
Example #4
Source File: EvaluatorTest.java From java-repl with Apache License 2.0 | 5 votes |
private static Matcher<Either<? extends Throwable, Evaluation>> hasCompilationError() { return new FeatureMatcher<Either<? extends Throwable, Evaluation>, Object>(Matchers.<Object>is(instanceOf(ExpressionCompilationException.class)), "result value", "result value") { protected Throwable featureValueOf(Either<? extends Throwable, Evaluation> evaluation) { return evaluation.left(); } }; }
Example #5
Source File: TokenRefreshInterceptorTest.java From wear-notify-for-reddit with Apache License 2.0 | 5 votes |
private Matcher<Request> hasAuthorisationHeader(String authHeader) { return new FeatureMatcher<Request, String>(equalTo(authHeader), "Authorisation header", "Unexpected auth header") { @Override protected String featureValueOf(Request actual) { return actual.header(AUTHORIZATION); } }; }
Example #6
Source File: JobCreateCommandTest.java From helios with Apache License 2.0 | 5 votes |
private Matcher<Job> hasMetadata(final Matcher<Map<String, String>> matcher) { return new FeatureMatcher<Job, Map<String, String>>(matcher, "metadata", "metadata") { @Override protected Map<String, String> featureValueOf(final Job actual) { return actual.getMetadata(); } }; }
Example #7
Source File: HeliosClientTest.java From helios with Apache License 2.0 | 5 votes |
/** A Matcher that tests that the URI has a path equal to the given path. */ private static Matcher<URI> hasPath(final String path) { return new FeatureMatcher<URI, String>(Matchers.equalTo(path), "path", "path") { @Override protected String featureValueOf(final URI actual) { return actual.getPath(); } }; }
Example #8
Source File: WatermarkMatchers.java From flink with Apache License 2.0 | 5 votes |
/** * Creates a matcher that matches when the examined watermark has the given timestamp. */ public static Matcher<Watermark> legacyWatermark(long timestamp) { return new FeatureMatcher<Watermark, Long>( equalTo(timestamp), "a watermark with value", "value of watermark" ) { @Override protected Long featureValueOf(Watermark actual) { return actual.getTimestamp(); } }; }
Example #9
Source File: WorkspaceAndProjectGeneratorTest.java From buck with Apache License 2.0 | 5 votes |
private Matcher<XCScheme.TestableReference> testableReferenceWithName(String name) { return new FeatureMatcher<XCScheme.TestableReference, String>( equalTo(name), "TestableReference named", "name") { @Override protected String featureValueOf(XCScheme.TestableReference testableReference) { return testableReference.getBuildableReference().blueprintName; } }; }
Example #10
Source File: CreateTableLikeTest.java From flink with Apache License 2.0 | 5 votes |
private static Matcher<SqlNode> hasLikeClause(Matcher<SqlTableLike> likeMatcher) { return new FeatureMatcher<SqlNode, SqlTableLike>( likeMatcher, "create table statement has like clause", "like clause") { @Override protected SqlTableLike featureValueOf(SqlNode actual) { if (!(actual instanceof SqlCreateTable)) { throw new AssertionError("Node is not a CREATE TABLE stmt."); } return ((SqlCreateTable) actual).getTableLike().orElse(null); } }; }
Example #11
Source File: SettingMatcher.java From crate with Apache License 2.0 | 5 votes |
public static Matcher<Settings> hasKey(String key) { return new FeatureMatcher<>(equalTo(true), key, "hasKey") { @Override protected Boolean featureValueOf(Settings actual) { return actual.keySet().contains(key); } }; }
Example #12
Source File: TestingHelpers.java From crate with Apache License 2.0 | 5 votes |
public static Matcher<SQLResponse> isPrintedTable(String expectedPrintedResponse) { return new FeatureMatcher<>(equalTo(expectedPrintedResponse), "same output", "printedTable") { @Override protected String featureValueOf(SQLResponse actual) { return printedTable(actual.rows()); } }; }
Example #13
Source File: ImageRefTest.java From docker-client with Apache License 2.0 | 5 votes |
private static Matcher<ImageRef> hasRegistryUrl(final String expected) { return new FeatureMatcher<ImageRef, String>(equalTo(expected), "registryNameUrl", "registryNameUrl") { @Override protected String featureValueOf(final ImageRef actual) { return actual.getRegistryUrl(); } }; }
Example #14
Source File: ImageRefTest.java From docker-client with Apache License 2.0 | 5 votes |
private static Matcher<ImageRef> hasRegistry(final String expected) { return new FeatureMatcher<ImageRef, String>(equalTo(expected), "registryName", "registryName") { @Override protected String featureValueOf(final ImageRef actual) { return actual.getRegistryName(); } }; }
Example #15
Source File: SQLExceptionMatchers.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * Matcher for the message of an Exception. * * @param matcher * Matcher for the exception message * @return The Matcher */ public static Matcher<Exception> message(final Matcher<String> matcher) { return new FeatureMatcher<Exception, String>(matcher, "exception message", "exception message") { @Override protected String featureValueOf(Exception e) { return e.getMessage(); } }; }
Example #16
Source File: SQLExceptionMatchers.java From jaybird with GNU Lesser General Public License v2.1 | 5 votes |
/** * Matcher for the value of {@link java.sql.SQLException#getSQLState()}. * * @param matcher * Matcher for the value of the SQL State * @return The Matcher */ public static Matcher<SQLException> sqlState(final Matcher<String> matcher) { return new FeatureMatcher<SQLException, String>(matcher, "SQL state", "SQL state") { @Override protected String featureValueOf(SQLException e) { return e.getSQLState(); } }; }
Example #17
Source File: WorkspaceAndProjectGeneratorTest.java From buck with Apache License 2.0 | 5 votes |
private Matcher<XCScheme.BuildActionEntry> withNameAndBuildingFor( String name, Matcher<? super EnumSet<XCScheme.BuildActionEntry.BuildFor>> buildFor) { return AllOf.allOf( buildActionEntryWithName(name), new FeatureMatcher<XCScheme.BuildActionEntry, EnumSet<XCScheme.BuildActionEntry.BuildFor>>( buildFor, "Building for", "BuildFor") { @Override protected EnumSet<XCScheme.BuildActionEntry.BuildFor> featureValueOf( XCScheme.BuildActionEntry entry) { return entry.getBuildFor(); } }); }
Example #18
Source File: TypeTestingUtils.java From flink with Apache License 2.0 | 5 votes |
public static Matcher<DataType> hasLogicalType(LogicalType logicalType) { return new FeatureMatcher<DataType, LogicalType>( CoreMatchers.equalTo(logicalType), "logical type of the data type", "logical type") { @Override protected LogicalType featureValueOf(DataType actual) { return actual.getLogicalType(); } }; }
Example #19
Source File: ResultMatchers.java From java-mammoth with BSD 2-Clause "Simplified" License | 5 votes |
public static Matcher<InternalResult<?>> isInternalResult(Matcher<?> valueMatcher, Iterable<String> warnings) { return new FeatureMatcher<InternalResult<?>, Result<?>>(isResult(valueMatcher, warnings), "InternalResult as Result", "Result") { @Override protected Result<?> featureValueOf(InternalResult<?> actual) { return actual.toResult(); } }; }
Example #20
Source File: ComponentMatcher.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
public static FeatureMatcher<Component, String> name(Matcher<String> matcher) { return new FeatureMatcher<Component, String>(matcher, "name", "name") { @Override protected String featureValueOf(Component actual) { return actual.name(); } }; }
Example #21
Source File: AssetMatcher.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
public static FeatureMatcher<Asset, String> path(Matcher<String> matcher) { return new FeatureMatcher<Asset, String>(matcher, "path", "path") { @Override protected String featureValueOf(Asset actual) { return actual.path(); } }; }
Example #22
Source File: TabOnTapCompletionProviderTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private 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(); } }; }
Example #23
Source File: FileMatchers.java From logging-log4j2 with Apache License 2.0 | 5 votes |
/** * Matches if the File exists. * * @return the Matcher. */ public static Matcher<File> exists() { return new FeatureMatcher<File, Boolean>(is(true), "file exists", "file exists") { @Override protected Boolean featureValueOf(final File actual) { return actual.exists(); } }; }
Example #24
Source File: PipelineOptionsReflectorTest.java From beam with Apache License 2.0 | 5 votes |
private static Matcher<PipelineOptionSpec> shouldSerialize() { return new FeatureMatcher<PipelineOptionSpec, Boolean>( equalTo(true), "should serialize", "shouldSerialize") { @Override protected Boolean featureValueOf(PipelineOptionSpec actual) { return actual.shouldSerialize(); } }; }
Example #25
Source File: PipelineOptionsReflectorTest.java From beam with Apache License 2.0 | 5 votes |
private static Matcher<PipelineOptionSpec> hasGetter(String methodName) { return new FeatureMatcher<PipelineOptionSpec, String>(is(methodName), "getter method", "name") { @Override protected String featureValueOf(PipelineOptionSpec actual) { return actual.getGetterMethod().getName(); } }; }
Example #26
Source File: PipelineOptionsReflectorTest.java From beam with Apache License 2.0 | 5 votes |
private static Matcher<PipelineOptionSpec> hasClass(Class<?> clazz) { return new FeatureMatcher<PipelineOptionSpec, Class<?>>( Matchers.<Class<?>>is(clazz), "defining class", "class") { @Override protected Class<?> featureValueOf(PipelineOptionSpec actual) { return actual.getDefiningInterface(); } }; }
Example #27
Source File: PipelineOptionsReflectorTest.java From beam with Apache License 2.0 | 5 votes |
private static Matcher<PipelineOptionSpec> hasName(Matcher<String> matcher) { return new FeatureMatcher<PipelineOptionSpec, String>(matcher, "name", "name") { @Override protected String featureValueOf(PipelineOptionSpec actual) { return actual.getName(); } }; }
Example #28
Source File: DisplayDataMatchers.java From beam with Apache License 2.0 | 5 votes |
/** * Creates a matcher that matches if the examined {@link DisplayData.Item} has a label matching * the specified label matcher. */ public static Matcher<DisplayData.Item> hasLabel(Matcher<String> labelMatcher) { return new FeatureMatcher<DisplayData.Item, String>( labelMatcher, "display item with label", "label") { @Override protected String featureValueOf(DisplayData.Item actual) { return actual.getLabel(); } }; }
Example #29
Source File: DisplayDataMatchers.java From beam with Apache License 2.0 | 5 votes |
/** * Creates a matcher that matches if the examined {@link DisplayData.Item} contains a value * matching the specified value matcher. */ public static <T> Matcher<DisplayData.Item> hasValue(Matcher<T> valueMatcher) { return new FeatureMatcher<DisplayData.Item, T>(valueMatcher, "with value", "value") { @Override protected T featureValueOf(DisplayData.Item actual) { @SuppressWarnings("unchecked") T value = (T) actual.getValue(); return value; } }; }
Example #30
Source File: DisplayDataMatchers.java From beam with Apache License 2.0 | 5 votes |
/** * Creates a matcher that matches if the examined {@link DisplayData.Item} has a type matching the * specified type matcher. */ public static Matcher<DisplayData.Item> hasType(Matcher<DisplayData.Type> typeMatcher) { return new FeatureMatcher<DisplayData.Item, DisplayData.Type>( typeMatcher, "with type", "type") { @Override protected DisplayData.Type featureValueOf(DisplayData.Item actual) { return actual.getType(); } }; }