com.nitorcreations.matchers.FormComponentMatchers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wicket-matchers Show documentation
Show all versions of wicket-matchers Show documentation
Useful Hamcrest 1.3 matchers for Wicket 6 projects
The newest version!
package com.nitorcreations.matchers;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.apache.wicket.markup.html.form.FormComponent;
import static org.hamcrest.Matchers.is;
public final class FormComponentMatchers {
private FormComponentMatchers() {}
@Factory
public static > Matcher hasLabel(final Matcher label) {
return new TypeSafeDiagnosingMatcher() {
@Override
protected boolean matchesSafely(T item, Description mismatchDescription) {
String labelText = item.getLabel().getObject();
label.describeMismatch(labelText, mismatchDescription);
return label.matches(labelText);
}
@Override
public void describeTo(Description description) {
description.appendText("with label ").appendDescriptionOf(label);
}
};
}
@Factory
public static Matcher> hasLabel(String label) {
return hasLabel(is(label));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy