-
Notifications
You must be signed in to change notification settings - Fork 2
/
IsIsomorphic.java
36 lines (28 loc) · 963 Bytes
/
IsIsomorphic.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cz.cvut.kbss.jsonld.environment;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.util.Models;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import java.util.Objects;
/**
* Matches two {@link Model}s if they are isomorphic.
*
* That is, they contain the same statements (including some blank node magic).
*/
public class IsIsomorphic extends TypeSafeMatcher<Model> {
private final Model expected;
public IsIsomorphic(Model expected) {
this.expected = Objects.requireNonNull(expected);
}
@Override
protected boolean matchesSafely(Model actual) {
return actual != null && Models.isomorphic(expected, actual);
}
@Override
public void describeTo(Description description) {
description.appendValueList("[", ", ", "]", expected);
}
public static IsIsomorphic isIsomorphic(Model expected) {
return new IsIsomorphic(expected);
}
}