Search in sources :

Example 1 with ImageSectionWidget

use of uk.nhs.digital.ps.test.acceptance.pages.widgets.ImageSectionWidget in project hippo by NHS-digital-website.

the class ImagePairSection method getMatcher.

public Matcher<? super SectionWidget> getMatcher() {
    return new TypeSafeDiagnosingMatcher<SectionWidget>(ImagePairSectionWidget.class) {

        @Override
        protected boolean matchesSafely(SectionWidget item, Description desc) {
            ImagePairSectionWidget widget = (ImagePairSectionWidget) item;
            List<ImageSectionWidget> imageSectionWidgets = widget.getImageSectionWidgets();
            // pad with nulls for the 2 slots we could have had images in
            while (imageSectionWidgets.size() < 2) {
                imageSectionWidgets.add(null);
            }
            return compare(first.getMatcher(), imageSectionWidgets.get(0), desc) && compare(second == null ? nullValue() : second.getMatcher(), imageSectionWidgets.get(1), desc);
        }

        @Override
        public void describeTo(Description description) {
            description.appendValue(ImagePairSection.this);
        }
    };
}
Also used : ImagePairSectionWidget(uk.nhs.digital.ps.test.acceptance.pages.widgets.ImagePairSectionWidget) Description(org.hamcrest.Description) ImageSectionWidget(uk.nhs.digital.ps.test.acceptance.pages.widgets.ImageSectionWidget) ImagePairSectionWidget(uk.nhs.digital.ps.test.acceptance.pages.widgets.ImagePairSectionWidget) SectionWidget(uk.nhs.digital.ps.test.acceptance.pages.widgets.SectionWidget) TypeSafeDiagnosingMatcher(org.hamcrest.TypeSafeDiagnosingMatcher) ImageSectionWidget(uk.nhs.digital.ps.test.acceptance.pages.widgets.ImageSectionWidget)

Aggregations

Description (org.hamcrest.Description)1 TypeSafeDiagnosingMatcher (org.hamcrest.TypeSafeDiagnosingMatcher)1 ImagePairSectionWidget (uk.nhs.digital.ps.test.acceptance.pages.widgets.ImagePairSectionWidget)1 ImageSectionWidget (uk.nhs.digital.ps.test.acceptance.pages.widgets.ImageSectionWidget)1 SectionWidget (uk.nhs.digital.ps.test.acceptance.pages.widgets.SectionWidget)1