Search in sources :

Example 76 with Given

use of io.cucumber.java.en.Given in project NoraUi by NoraUi.

the class HelloByeSteps method readBlog.

@RetryOnFailure(attempts = 3)
@Given("me any article, please. {string} of {string}.")
public void readBlog(String jsonArticles, String blog) throws FailureException {
    Articles articles = new Articles();
    articles.deserialize(jsonArticles);
    for (Article article : articles) {
        if ("anonymous".equals(article.getAuthor())) {
            new Result.Failure<>("anonymous", "anonymous is prohibited in demo blog!!", true, this.demoPage.getCallBack());
        } else {
            log.info("> " + blog);
            log.info("    > " + article.getTitle() + ": " + article.getText());
        }
    }
}
Also used : Articles(com.github.noraui.application.model.demo.Articles) Article(com.github.noraui.application.model.demo.Article) RetryOnFailure(com.github.noraui.cucumber.annotation.RetryOnFailure) Given(io.cucumber.java.en.Given) RetryOnFailure(com.github.noraui.cucumber.annotation.RetryOnFailure)

Example 77 with Given

use of io.cucumber.java.en.Given in project apm-agent-java by elastic.

the class OutcomeStepsDefinitions method httpTransactionWithStatus.

@Given("a HTTP call is received that returns {int}")
public void httpTransactionWithStatus(int code) {
    Transaction transaction = state.getTransaction();
    transaction.withName(String.format("HTTP transaction status = %d", code));
    transaction.withOutcome(ResultUtil.getOutcomeByHttpServerStatus(code));
}
Also used : Transaction(co.elastic.apm.agent.impl.transaction.Transaction) Given(io.cucumber.java.en.Given)

Example 78 with Given

use of io.cucumber.java.en.Given in project open-smart-grid-platform by OSGP.

the class WsCoreResponseDataSteps method aResponseDataRecord.

@Given("^a response data record in ws-core$")
@Transactional("txMgrWsCore")
public ResponseData aResponseDataRecord(final Map<String, String> settings) {
    final ResponseData responseData = this.responseDataRepository.save(new ResponseDataBuilder().fromSettings(settings).build());
    final Date creationTime = DateTimeHelper.getDateTime(settings.get(PlatformKeys.KEY_CREATION_TIME)).toDate();
    LOGGER.info("Creating response data record with correlationUid: {} and creationTime: {}", responseData.getCorrelationUid(), creationTime);
    ScenarioContext.current().put(PlatformKeys.KEY_CORRELATION_UID, responseData.getCorrelationUid());
    try {
        // (as it will be overridden on first save)
        if (settings.containsKey(PlatformKeys.KEY_CREATION_TIME)) {
            final Field fld = responseData.getClass().getSuperclass().getDeclaredField("creationTime");
            fld.setAccessible(true);
            fld.set(responseData, creationTime);
            this.responseDataRepository.saveAndFlush(responseData);
            LOGGER.info("Response data record saved with correlationUid: {} and creationTime: {}", responseData.getCorrelationUid(), creationTime);
        }
    } catch (final Exception e) {
        LOGGER.error("Exception", e);
        Assertions.fail("Failed to create response data record in ws-core.");
    }
    return responseData;
}
Also used : Field(java.lang.reflect.Field) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) ResponseDataBuilder(org.opensmartgridplatform.cucumber.platform.glue.steps.database.ws.ResponseDataBuilder) Date(java.util.Date) Given(io.cucumber.java.en.Given) Transactional(org.springframework.transaction.annotation.Transactional)

Example 79 with Given

use of io.cucumber.java.en.Given in project open-smart-grid-platform by OSGP.

the class GetKeys method anApplicationKeyIsConfigured.

@Given("^an application key is configured$")
public void anApplicationKeyIsConfigured(final Map<String, String> settings) throws Throwable {
    final ApplicationDataLookupKey applicationDataLookupKey = new ApplicationDataLookupKey(settings.get(PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION), this.applicationName);
    final ApplicationKeyConfiguration applicationKeyConfiguration = new ApplicationKeyConfiguration(applicationDataLookupKey, "/etc/osp/smartmetering/keys/application/smartmetering-rsa-public.key");
    this.applicationKeyConfigurationRepository.save(applicationKeyConfiguration);
}
Also used : ApplicationDataLookupKey(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey) ApplicationKeyConfiguration(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationKeyConfiguration) Given(io.cucumber.java.en.Given)

Example 80 with Given

use of io.cucumber.java.en.Given in project open-smart-grid-platform by OSGP.

the class GetDebugInformation method thereIsDebugInformationLoggedForTheDevice.

@Given("^there is debug information logged for the device$")
public void thereIsDebugInformationLoggedForTheDevice() throws Throwable {
    final DeviceLogItem deviceLogItem = this.deviceLogItemBuilder.withDeviceIdentification(ScenarioContext.current().get(PlatformKeys.KEY_DEVICE_IDENTIFICATION).toString()).build();
    this.logItemRepository.save(deviceLogItem);
}
Also used : DeviceLogItem(org.opensmartgridplatform.logging.domain.entities.DeviceLogItem) Given(io.cucumber.java.en.Given)

Aggregations

Given (io.cucumber.java.en.Given)125 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)27 ArrayList (java.util.ArrayList)11 Transactional (org.springframework.transaction.annotation.Transactional)11 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)8 Date (java.util.Date)7 DeviceOutputSetting (org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting)6 ActivityCalendar (org.opensmartgridplatform.cucumber.platform.smartmetering.support.ws.smartmetering.bundle.activitycalendar.ActivityCalendar)5 Device (org.opensmartgridplatform.domain.core.entities.Device)5 RelayType (org.opensmartgridplatform.domain.core.valueobjects.RelayType)5 ByteString (com.google.protobuf.ByteString)4 Account (io.syndesis.qe.account.Account)4 File (java.io.File)4 List (java.util.List)4 ElementsCollection (com.codeborne.selenide.ElementsCollection)3 Field (java.lang.reflect.Field)3 HashMap (java.util.HashMap)3 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)3 ResponseDataBuilder (org.opensmartgridplatform.cucumber.platform.glue.steps.database.ws.ResponseDataBuilder)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2