All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.matchers.ReportedErrorMessages Maven / Gradle / Ivy

There is a newer version: 4.2.9
Show newest version
package net.serenitybdd.screenplay.matchers;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.TypeSafeDiagnosingMatcher;

import java.util.ArrayList;

public class ReportedErrorMessages {
    public static  Matcher> reportsErrors(final E expected) {
        return new TypeSafeDiagnosingMatcher>() {
            @Override
            public void describeTo(Description description) {
                description.appendValue(expected).appendText(" should be displayed");
            }

            @Override
            protected boolean matchesSafely(Iterable items, Description mismatchDescription) {
                mismatchDescription.appendText(" the visible error messages were ").appendValue(items);
                if (expected instanceof ArrayList) {
                    return Matchers.hasItems(((ArrayList) expected).toArray()).matches(items);
                }
                return Matchers.hasItems(expected).matches(items);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy