summaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble/mammoth/tests/ResultMatchers.java
blob: a5b9585d0edcb219cd5a67df70c50f608dcb3478 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package org.zwobble.mammoth.tests;

import com.google.common.collect.ImmutableSet;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.zwobble.mammoth.Result;

import static org.hamcrest.Matchers.hasProperty;
import static org.zwobble.mammoth.tests.DeepReflectionMatcher.deepEquals;

public class ResultMatchers {
    public static Matcher<Result<?>> isResult(Matcher<?> valueMatcher, Iterable<String> warnings) {
        return Matchers.allOf(
            hasProperty("value", valueMatcher),
            hasWarnings(warnings));
    }

    public static Matcher<Result<?>> hasWarnings(Iterable<String> warnings) {
        return hasProperty("warnings", deepEquals(ImmutableSet.copyOf(warnings)));
    }
}