Search in sources :

Example 1 with SectionWidget

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

the class PublicationSteps method iCanSeeTheSectionedPublicationBody.

@Then("^I can see the sectioned publication body$")
public void iCanSeeTheSectionedPublicationBody() throws Throwable {
    Publication publication = testDataRepo.getCurrentPublication();
    List<Matcher<? super SectionWidget>> matchers = publication.getBodySections().stream().map(BodySection::getMatcher).collect(Collectors.toList());
    assertThat("Body sections are as expected", publicationPage.getBodySections(), contains(matchers));
}
Also used : Matcher(org.hamcrest.Matcher) Publication(uk.nhs.digital.ps.test.acceptance.models.Publication) SectionWidget(uk.nhs.digital.ps.test.acceptance.pages.widgets.SectionWidget) Then(cucumber.api.java.en.Then)

Example 2 with SectionWidget

use of uk.nhs.digital.ps.test.acceptance.pages.widgets.SectionWidget 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

SectionWidget (uk.nhs.digital.ps.test.acceptance.pages.widgets.SectionWidget)2 Then (cucumber.api.java.en.Then)1 Description (org.hamcrest.Description)1 Matcher (org.hamcrest.Matcher)1 TypeSafeDiagnosingMatcher (org.hamcrest.TypeSafeDiagnosingMatcher)1 Publication (uk.nhs.digital.ps.test.acceptance.models.Publication)1 ImagePairSectionWidget (uk.nhs.digital.ps.test.acceptance.pages.widgets.ImagePairSectionWidget)1 ImageSectionWidget (uk.nhs.digital.ps.test.acceptance.pages.widgets.ImageSectionWidget)1