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

The following examples show how to use org.hamcrest.Matchers#equalTo() . 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: InputStreamOfTest.java    From cactoos with 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 2
Source File: InputStreamOfTest.java    From cactoos with 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 3
Source File: InputStreamOfTest.java    From cactoos with 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 4
Source File: DeepReflectionMatcher.java    From java-mammoth with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 5
Source File: InputStreamOfTest.java    From cactoos with 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 6
Source File: InputStreamOfTest.java    From cactoos with 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 7
Source File: HeliosClientTest.java    From helios with 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 8
Source File: ElementMatcher.java    From fdb-record-layer with 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 9
Source File: StreamRecordMatchers.java    From flink with 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 10
Source File: StreamRecordMatchers.java    From flink with 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 11
Source File: ElementMatcher.java    From fdb-record-layer with 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 12
Source File: StreamRecordMatchers.java    From Flink-CEPplus with 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 File: PredicateMatchers.java    From fdb-record-layer with Apache License 2.0 4 votes vote down vote up
public static Matcher<QueryPredicate> equivalentTo(@Nonnull QueryComponent component) {
    return Matchers.equalTo(component.normalizeForPlanner(BlankSource.INSTANCE));
}
 
Example 14
Source File: StreamRecordMatchers.java    From flink with 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 15
Source File: StreamRecordMatchers.java    From flink with 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 16
Source File: StreamRecordMatchers.java    From Flink-CEPplus with 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 17
Source File: StreamRecordMatchers.java    From Flink-CEPplus with 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 File: StreamRecordMatchers.java    From Flink-CEPplus with 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) {
	return new WindowedValueMatcher<>(valueMatcher, Matchers.equalTo(timestamp), Matchers.anything());
}
 
Example 19
Source File: HmRsStatus.java    From takes with 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));
}
 
Example 20
Source File: HmRqTextBody.java    From takes with 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));
}