Search in sources :

Example 56 with Given

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

the class ManufacturerSteps method aManufacturer.

/**
 * Generic method which adds a manufacturer using the settings.
 *
 * @param settings The settings for the manufacturer to be used.
 * @throws Throwable
 */
@Given("^a manufacturer$")
public void aManufacturer(final Map<String, String> settings) throws Throwable {
    final Manufacturer manufacturer = new ManufacturerBuilder().withSettings(settings).build();
    this.manufacturerRepository.save(manufacturer);
}
Also used : ManufacturerBuilder(org.opensmartgridplatform.cucumber.platform.core.builders.ManufacturerBuilder) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) Given(io.cucumber.java.en.Given)

Example 57 with Given

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

the class DeviceLogItemSteps method iHaveADeviceLogItem.

@Given("^I have a device log item$")
@Transactional("txMgrLogging")
public void iHaveADeviceLogItem(final Map<String, String> settings) {
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION);
    final String deviceUid = getString(settings, PlatformKeys.KEY_DEVICE_UID, PlatformDefaults.DEVICE_UID);
    final String decodedMessage = "O S L P";
    final String encodedMessage = "0x4F 0x53 0x4C 0x50";
    final boolean incoming = true;
    final String organisationIdentification = getString(settings, PlatformKeys.KEY_ORGANIZATION, PlatformDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION);
    final Integer payloadMessageSerializedSize = 4;
    final boolean valid = true;
    final DeviceLogItem deviceLogItem = new DeviceLogItem.Builder().withDeviceIdentification(deviceIdentification).withDeviceUid(deviceUid).withDecodedMessage(decodedMessage).withEncodedMessage(encodedMessage).withIncoming(incoming).withOrganisationIdentification(organisationIdentification).withPayloadMessageSerializedSize(payloadMessageSerializedSize).withValid(valid).build();
    final DeviceLogItem savedDeviceLogItem = this.deviceLogItemRepository.save(deviceLogItem);
    final String modificationTimeString = getString(settings, PlatformKeys.KEY_MODIFICATION_TIME);
    if (modificationTimeString != null) {
        final ZonedDateTime modificationTime = ZonedDateTime.parse(modificationTimeString);
        this.updateModificationTime(savedDeviceLogItem.getId(), modificationTime);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) DeviceLogItem(org.opensmartgridplatform.logging.domain.entities.DeviceLogItem) Given(io.cucumber.java.en.Given) Transactional(org.springframework.transaction.annotation.Transactional)

Example 58 with Given

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

the class GetFirmwareVersionSteps method receivingAGetFirmwareVersionRequest.

/**
 * Sends a Get Firmware Version request to the platform for a given device identification.
 *
 * @param requestParameters The table with the request parameters.
 * @throws Throwable
 */
@Given("^receiving a get firmware version request$")
public void receivingAGetFirmwareVersionRequest(final Map<String, String> requestParameters) throws Throwable {
    final GetFirmwareVersionRequest request = new GetFirmwareVersionRequest();
    request.setDeviceIdentification(getString(requestParameters, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    try {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.getFirmwareVersion(request));
    } catch (final SoapFaultClientException ex) {
        ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
    }
}
Also used : GetFirmwareVersionRequest(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.GetFirmwareVersionRequest) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) Given(io.cucumber.java.en.Given)

Example 59 with Given

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

the class RetrieveReceivedEventNotifications method allEvents.

/**
 * There are 47 events enumerated by {@link
 * org.opensmartgridplatform.domain.core.valueobjects.EventType}. This step will create an event
 * record for every event type.
 */
@Given("^all events are present for device$")
public void allEvents(final Map<String, String> data) {
    final String deviceIdentification = getString(data, PlatformKeys.KEY_DEVICE_IDENTIFICATION);
    for (final EventType eventType : EventType.values()) {
        final Event event = new Event(deviceIdentification, getDateTime(PlatformDefaults.TIMESTAMP).toDate(), eventType, PlatformDefaults.DEFAULT_EVENT_DESCRIPTION, PlatformDefaults.DEFAULT_INDEX);
        this.eventRepository.save(event);
    }
}
Also used : EventType(org.opensmartgridplatform.domain.core.valueobjects.EventType) Event(org.opensmartgridplatform.domain.core.entities.Event) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Given(io.cucumber.java.en.Given)

Example 60 with Given

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

the class ConnectionSteps method givenIec60870DeviceIsNotConnected.

@Given("the IEC60870 device is not connected")
public void givenIec60870DeviceIsNotConnected() throws ConnectionFailureException {
    LOGGER.debug("Given IEC60870 device is not connected");
    // Make sure the client connect works as expected
    final DeviceConnection deviceConnection = new DeviceConnection(mock(Connection.class), this.connectionParameters);
    when(this.clientMock.connect(eq(this.connectionParameters), any(ClientConnectionEventListener.class))).thenReturn(deviceConnection);
}
Also used : DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection) DeviceConnection(org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceConnection) Connection(org.openmuc.j60870.Connection) ClientConnectionEventListener(org.opensmartgridplatform.adapter.protocol.iec60870.domain.services.ClientConnectionEventListener) 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