Search in sources :

Example 6 with Publication

use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.

the class TestDataSteps method discardEditedDocument.

/**
 * <p>
 * Closes the current publication discarding current changes.
 * </p><p>
 * Only applicable to scenarios that leave the document in editable state; implemented as an {@linkplain After}
 * hook rather than a step because this is really a test cleanup/tear-down activity that doesn't warrant expressing
 * explicitly as a scenario step.
 * </p><p>
 * To ensure that this method gets called at the end of your scenario, tag the scenario with
 * {@code @DiscardAfter}.
 * </p>
 */
@After(value = "@DiscardAfter", order = 500)
public void discardEditedDocument() throws Throwable {
    Publication currentPublication = testDataRepo.getCurrentPublication();
    if (currentPublication != null) {
        final String currentPublicationName = currentPublication.getName();
        log.debug("Discarding and closing current publication: {}.", currentPublicationName);
        contentPage.discardUnsavedChanges(currentPublicationName);
    }
    Dataset dataset = testDataRepo.getDataset();
    if (dataset != null) {
        String datasetName = dataset.getName();
        log.debug("Discarding and closing current dataset: {}.", datasetName);
        contentPage.discardUnsavedChanges(datasetName);
    }
    PublicationSeries series = testDataRepo.getPublicationSeries();
    if (series != null) {
        final String currentSeriesName = series.getName();
        log.debug("Discarding and closing current series: {}.", currentSeriesName);
        contentPage.discardUnsavedChanges(currentSeriesName);
    }
    PublicationArchive archive = testDataRepo.getPublicationArchive();
    if (archive != null) {
        final String currentArchiveName = archive.getName();
        log.debug("Discarding and closing current archive: {}.", currentArchiveName);
        contentPage.discardUnsavedChanges(currentArchiveName);
    }
}
Also used : PublicationSeries(uk.nhs.digital.ps.test.acceptance.models.PublicationSeries) PublicationArchive(uk.nhs.digital.ps.test.acceptance.models.PublicationArchive) Dataset(uk.nhs.digital.ps.test.acceptance.models.Dataset) Publication(uk.nhs.digital.ps.test.acceptance.models.Publication) After(cucumber.api.java.After)

Example 7 with Publication

use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.

the class CmsSteps method givenIHaveAPublicationOpenForEditing.

@Given("^I have a publication opened for editing$")
public void givenIHaveAPublicationOpenForEditing() throws Throwable {
    final Publication publication = TestDataFactory.createBareMinimumPublication().build();
    testDataRepo.setPublication(publication);
    createPublicationInEditableState(publication);
    // Since previous step created a new document which was not saved, immediately after a login,
    // the edit document screen is displayed (instead of dashboard)
    assertTrue("Publication edit screen is displayed", contentPage.isDocumentEditScreenOpen());
}
Also used : Publication(uk.nhs.digital.ps.test.acceptance.models.Publication) Given(cucumber.api.java.en.Given)

Example 8 with Publication

use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.

the class CmsSteps method givenIHaveAPublishedPublicationWithNominalDateFallingAfterWeeksFromNow.

@Given("^I have a published publication with nominal date falling after (\\d+) weeks from now$")
public void givenIHaveAPublishedPublicationWithNominalDateFallingAfterWeeksFromNow(final int weeksFromNow) throws Throwable {
    final Publication publicationWithNominalDateBeforeCutOff = TestDataFactory.createBareMinimumPublication().withNominalDate(Instant.now().plus(DAYS_IN_WEEK * weeksFromNow, ChronoUnit.DAYS).plus(1, ChronoUnit.DAYS)).build();
    testDataRepo.setPublication(publicationWithNominalDateBeforeCutOff);
    createPublishedPublication(publicationWithNominalDateBeforeCutOff);
}
Also used : Publication(uk.nhs.digital.ps.test.acceptance.models.Publication) Given(cucumber.api.java.en.Given)

Example 9 with Publication

use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.

the class CmsSteps method nominalPublicationDateIsDisplayedUsingFormat.

@Then("^Publication Date is displayed using format \"([^\"]*)\"$")
public void nominalPublicationDateIsDisplayedUsingFormat(final String dateFormat) throws Throwable {
    final Publication.NominalPublicationDate nominalPublicationDate = testDataRepo.getCurrentPublication().getNominalPublicationDate();
    final String expectedDate = nominalPublicationDate.inFormat(dateFormat);
    assertThat("Publication Date is formatted in a way consistent with pattern '" + dateFormat + "'", publicationPage.getNominalPublicationDate(), is(expectedDate));
}
Also used : Publication(uk.nhs.digital.ps.test.acceptance.models.Publication) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Then(cucumber.api.java.en.Then)

Example 10 with Publication

use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.

the class CmsSteps method givenIHaveAPublishedPublicationWithNominalDateFallingThis.

@Given("^I have a published publication with nominal date falling this (week|month|year)$")
public void givenIHaveAPublishedPublicationWithNominalDateFallingThis(String unit) throws Throwable {
    LocalDateTime date;
    if (unit.equals("week")) {
        // we want a day that is this week but not today or yesterday
        date = getDateRelativeToToday(DAY_OF_WEEK, 1);
    } else if (unit.equals("month")) {
        // we want a date that is this month but not this week, so don't pick a date 7 days either side or today
        date = getDateRelativeToToday(DAY_OF_MONTH, DAYS_IN_WEEK);
    } else {
        // we want a date that is this year but not this week or month, so don't pick a date one month either side
        date = getDateRelativeToToday(MONTH_OF_YEAR, 1);
    }
    final Publication publication = TestDataFactory.createBareMinimumPublication().withNominalDate(date.toInstant(ZoneOffset.UTC)).build();
    testDataRepo.setPublication(publication);
    createPublishedPublication(publication);
}
Also used : LocalDateTime(java.time.LocalDateTime) Publication(uk.nhs.digital.ps.test.acceptance.models.Publication) Given(cucumber.api.java.en.Given)

Aggregations

Publication (uk.nhs.digital.ps.test.acceptance.models.Publication)11 Given (cucumber.api.java.en.Given)5 Then (cucumber.api.java.en.Then)3 When (cucumber.api.java.en.When)2 After (cucumber.api.java.After)1 LocalDateTime (java.time.LocalDateTime)1 ChronoUnit (java.time.temporal.ChronoUnit)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matcher (org.hamcrest.Matcher)1 Dataset (uk.nhs.digital.ps.test.acceptance.models.Dataset)1 PublicationArchive (uk.nhs.digital.ps.test.acceptance.models.PublicationArchive)1 PublicationSeries (uk.nhs.digital.ps.test.acceptance.models.PublicationSeries)1 SectionWidget (uk.nhs.digital.ps.test.acceptance.pages.widgets.SectionWidget)1