Java Code Examples for org.hamcrest.Matchers#equalTo()

The following examples show how to use org.hamcrest.Matchers#equalTo() . These examples are extracted from open source projects. 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 Project: cactoos   File: InputStreamOfTest.java    License: MIT License 5 votes vote down vote up
@Test
public void readsFromCharSequenceWithCharsetName() throws Exception {
    final String content = "Simple content";
    new Assertion<>(
        "Can't read from char sequence with charset name",
        new TextOf(
            new InputStreamOf(
                content,
                StandardCharsets.UTF_8.name()
            )
        ).asString(),
        Matchers.equalTo(content)
    );
}
 
Example 2
Source Project: helios   File: HeliosClientTest.java    License: Apache License 2.0 5 votes vote down vote up
/** 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 3
Source Project: cactoos   File: InputStreamOfTest.java    License: MIT License 5 votes vote down vote up
@Test
public void readsFromCharSequenceWithCharset() throws Exception {
    final String content = "Another simple content";
    new Assertion<>(
        "Can't read from char sequence with charset",
        new TextOf(
            new InputStreamOf(
                content,
                StandardCharsets.UTF_8
            )
        ).asString(),
        Matchers.equalTo(content)
    );
}
 
Example 4
Source Project: cactoos   File: InputStreamOfTest.java    License: MIT License 5 votes vote down vote up
@Test
public void readsFileContent() throws Exception {
    final File file = this.folder.newFile("readFileContent.txt-2");
    final String content = "Content in a file";
    new LengthOf(
        new TeeInput(content, file)
    ).intValue();
    new Assertion<>(
        "Can't read from file",
        new TextOf(new InputStreamOf(file)).asString(),
        Matchers.equalTo(content)
    );
}
 
Example 5
private static <T> boolean matchesPrimitive(String path, T expected, T actual, Description mismatchDescription) {
    Matcher<Object> matcher = Matchers.equalTo(expected);
    if (!matcher.matches(actual)) {
        appendPath(mismatchDescription, path);
        matcher.describeMismatch(actual, mismatchDescription);
        return false;
    } else {
        return true;
    }
}
 
Example 6
Source Project: cactoos   File: InputStreamOfTest.java    License: MIT License 5 votes vote down vote up
@Test
public void readsBytesArray() throws Exception {
    final String content = "Bytes array content";
    final byte[] bytes = new BytesOf(content).asBytes();
    new Assertion<>(
        "Can't read from byte array",
        new TextOf(new InputStreamOf(bytes)).asString(),
        Matchers.equalTo(content)
    );
}
 
Example 7
Source Project: cactoos   File: InputStreamOfTest.java    License: MIT License 5 votes vote down vote up
@Test
public void readsFromReaderWithCharsetWithMax() throws Exception {
    final String content = "Reading with charset and buffer size";
    new Assertion<>(
        "Can't read from reader with charset and buffer size",
        new TextOf(
            new InputStreamOf(
                new StringReader(content),
                StandardCharsets.UTF_8,
                1
            )
        ).asString(),
        Matchers.equalTo(content)
    );
}
 
Example 8
public static Matcher<TimeWindow> timeWindow(long start, long end) {
	return Matchers.equalTo(new TimeWindow(start, end));
}
 
Example 9
public static <T, W extends Window> Matcher<StreamRecord<? extends WindowedValue<? extends T, ? extends W>>> isWindowedValue(
	Matcher<? super T> valueMatcher, long timestamp) {
	return new WindowedValueMatcher<>(valueMatcher, Matchers.equalTo(timestamp), Matchers.anything());
}
 
Example 10
public static <T, W extends Window> Matcher<StreamRecord<? extends WindowedValue<? extends T, ? extends W>>> isWindowedValue(
	Matcher<? super T> valueMatcher, long timestamp, W window) {
	return new WindowedValueMatcher<>(valueMatcher, Matchers.equalTo(timestamp), Matchers.equalTo(window));
}
 
Example 11
public static <T, W extends Window> Matcher<StreamRecord<? extends WindowedValue<? extends T, ? extends W>>> isWindowedValue(
	Matcher<? super T> valueMatcher, long timestamp, Matcher<? super W> windowMatcher) {
	return new WindowedValueMatcher<>(valueMatcher, Matchers.equalTo(timestamp), windowMatcher);
}
 
Example 12
Source Project: flink   File: StreamRecordMatchers.java    License: Apache License 2.0 4 votes vote down vote up
public static Matcher<TimeWindow> timeWindow(long start, long end) {
	return Matchers.equalTo(new TimeWindow(start, end));
}
 
Example 13
Source Project: flink   File: StreamRecordMatchers.java    License: Apache License 2.0 4 votes vote down vote up
public static <T, W extends Window> Matcher<StreamRecord<? extends WindowedValue<? extends T, ? extends W>>> isWindowedValue(
	Matcher<? super T> valueMatcher, long timestamp, Matcher<? super W> windowMatcher) {
	return new WindowedValueMatcher<>(valueMatcher, Matchers.equalTo(timestamp), windowMatcher);
}
 
Example 14
public static Matcher<QueryPredicate> equivalentTo(@Nonnull QueryComponent component) {
    return Matchers.equalTo(component.normalizeForPlanner(BlankSource.INSTANCE));
}
 
Example 15
Source Project: fdb-record-layer   File: ElementMatcher.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
public ElementPredicateMatcher equalsValue(@Nonnull Object comparand) {
    return new ElementPredicateMatcher(this,
            Matchers.equalTo(new Comparisons.SimpleComparison(Comparisons.Type.EQUALS, comparand)));
}
 
Example 16
Source Project: fdb-record-layer   File: ElementMatcher.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
public ElementPredicateMatcher notEquals(@Nonnull Object comparand) {
    return new ElementPredicateMatcher(this,
            Matchers.equalTo(new Comparisons.SimpleComparison(Comparisons.Type.NOT_EQUALS, comparand)));
}
 
Example 17
Source Project: flink   File: StreamRecordMatchers.java    License: Apache License 2.0 4 votes vote down vote up
public static <T, W extends Window> Matcher<StreamRecord<? extends WindowedValue<? extends T, ? extends W>>> isWindowedValue(
	Matcher<? super T> valueMatcher, long timestamp, W window) {
	return new WindowedValueMatcher<>(valueMatcher, Matchers.equalTo(timestamp), Matchers.equalTo(window));
}
 
Example 18
Source Project: flink   File: StreamRecordMatchers.java    License: Apache License 2.0 4 votes vote down vote up
public static <T, W extends Window> Matcher<StreamRecord<? extends WindowedValue<? extends T, ? extends W>>> isWindowedValue(
	Matcher<? super T> valueMatcher, long timestamp, Matcher<? super W> windowMatcher) {
	return new WindowedValueMatcher<>(valueMatcher, Matchers.equalTo(timestamp), windowMatcher);
}
 
Example 19
Source Project: takes   File: HmRqTextBody.java    License: MIT License 2 votes vote down vote up
/**
 * Ctor with equalTo matcher and default charset.
 * @param expected String to test against
 */
public HmRqTextBody(final String expected) {
    this(Matchers.equalTo(expected));
}
 
Example 20
Source Project: takes   File: HmRsStatus.java    License: MIT License 2 votes vote down vote up
/**
 * Create matcher using HTTP code.
 * @param val HTTP code value
 * @since 0.17
 */
public HmRsStatus(final int val) {
    this(Matchers.equalTo(val));
}