Search in sources :

Example 1 with After

use of cucumber.api.java.After 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 2 with After

use of cucumber.api.java.After in project cucumber-jvm by cucumber.

the class JavaHookTest method hook_order_gets_registered.

@Test
public void hook_order_gets_registered() {
    objectFactory.setInstance(new HasHooks());
    backend.buildWorld();
    backend.addHook(AFTER.getAnnotation(After.class), AFTER);
    HookDefinition hookDef = glue.getAfterHooks().get(0);
    assertEquals(1, hookDef.getOrder());
}
Also used : After(cucumber.api.java.After) HookDefinition(cucumber.runtime.HookDefinition) Test(org.junit.Test)

Aggregations

After (cucumber.api.java.After)2 HookDefinition (cucumber.runtime.HookDefinition)1 Test (org.junit.Test)1 Dataset (uk.nhs.digital.ps.test.acceptance.models.Dataset)1 Publication (uk.nhs.digital.ps.test.acceptance.models.Publication)1 PublicationArchive (uk.nhs.digital.ps.test.acceptance.models.PublicationArchive)1 PublicationSeries (uk.nhs.digital.ps.test.acceptance.models.PublicationSeries)1