--- /dev/null
+package net.pterodactylus.fcp.test;
+
+import net.pterodactylus.fcp.ARK;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+
+public class ArkMatchers {
+
+ public static Matcher<ARK> isArk(Matcher<? super String> publicUri, Matcher<? super String> privateUri, Matcher<? super Integer> number) {
+ return new TypeSafeDiagnosingMatcher<ARK>() {
+ @Override
+ protected boolean matchesSafely(ARK ark, Description mismatchDescription) {
+ if (!publicUri.matches(ark.getPublicURI())) {
+ mismatchDescription.appendText("public URI is ").appendValue(ark.getPublicURI());
+ return false;
+ }
+ if (!privateUri.matches(ark.getPrivateURI())) {
+ mismatchDescription.appendText("private URI is ").appendValue(ark.getPrivateURI());
+ return false;
+ }
+ if (!number.matches(ark.getNumber())) {
+ mismatchDescription.appendText("number is ").appendValue(ark.getNumber());
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("is ARK with public URI ").appendDescriptionOf(publicUri);
+ description.appendText(", private URI ").appendDescriptionOf(privateUri);
+ description.appendText(", and number ").appendDescriptionOf(number);
+ }
+ };
+ }
+
+}
--- /dev/null
+package net.pterodactylus.fcp.test;
+
+import net.pterodactylus.fcp.DSAGroup;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+
+public class DsaGroupMatchers {
+
+ public static Matcher<DSAGroup> isDsaGroup(Matcher<? super String> base, Matcher<? super String> prime, Matcher<? super String> subprime) {
+ return new TypeSafeDiagnosingMatcher<DSAGroup>() {
+ @Override
+ protected boolean matchesSafely(DSAGroup dsaGroup, Description mismatchDescription) {
+ if (!base.matches(dsaGroup.getBase())) {
+ mismatchDescription.appendText("base is ").appendValue(dsaGroup.getBase());
+ return false;
+ }
+ if (!prime.matches(dsaGroup.getPrime())) {
+ mismatchDescription.appendText("prime is ").appendValue(dsaGroup.getPrime());
+ return false;
+ }
+ if (!subprime.matches(dsaGroup.getSubprime())) {
+ mismatchDescription.appendText("subprime is ").appendValue(dsaGroup.getSubprime());
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("is dsa group with base ").appendDescriptionOf(base);
+ description.appendText(", prime ").appendDescriptionOf(prime);
+ description.appendText(", and subprime ").appendDescriptionOf(subprime);
+ }
+ };
+ }
+
+}
--- /dev/null
+package net.pterodactylus.fcp.test;
+
+import net.pterodactylus.fcp.Version;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+
+public class VersionMatchers {
+
+ public static Matcher<Version> isVersion(Matcher<? super String> nodeName, Matcher<? super String> treeVersion, Matcher<? super String> protocolVersion, Matcher<? super Integer> buildNumber) {
+ return new TypeSafeDiagnosingMatcher<Version>() {
+ @Override
+ protected boolean matchesSafely(Version version, Description mismatchDescription) {
+ if (!nodeName.matches(version.getNodeName())) {
+ mismatchDescription.appendText("node name is ").appendValue(version.getNodeName());
+ return false;
+ }
+ if (!treeVersion.matches(version.getTreeVersion())) {
+ mismatchDescription.appendText("tree version is ").appendValue(version.getTreeVersion());
+ return false;
+ }
+ if (!protocolVersion.matches(version.getProtocolVersion())) {
+ mismatchDescription.appendText("protocol version is ").appendValue(version.getProtocolVersion());
+ return false;
+ }
+ if (!buildNumber.matches(version.getBuildNumber())) {
+ mismatchDescription.appendText("build number is ").appendValue(version.getBuildNumber());
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("is version with node name ").appendDescriptionOf(nodeName);
+ description.appendText(", tree version ").appendDescriptionOf(treeVersion);
+ description.appendText(", protocol version ").appendDescriptionOf(protocolVersion);
+ description.appendText(", and build number ").appendDescriptionOf(buildNumber);
+ }
+ };
+ }
+
+}