Search in sources :

Example 81 with Given

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

the class OslpDeviceSteps method theDeviceSendsAConfirmRegisterDeviceRequestToThePlatform.

@Given("^the device sends a confirm register device request to the platform over \"([^\"]*)\"$")
public void theDeviceSendsAConfirmRegisterDeviceRequestToThePlatform(final String protocol, final Map<String, String> settings) throws DeviceSimulatorException {
    try {
        final String deviceIdentification = getString(settings, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_DEVICE_IDENTIFICATION);
        final String deviceUid = getString(settings, PlatformPubliclightingKeys.KEY_DEVICE_UID, PlatformPubliclightingDefaults.DEVICE_UID);
        final OslpDevice oslpDevice = this.oslpDeviceRepository.findByDeviceIdentification(deviceIdentification);
        final int randomDevice = oslpDevice.getRandomDevice();
        final int randomPlatform = oslpDevice.getRandomPlatform();
        final Oslp.ConfirmRegisterDeviceRequest confirmRegisterDeviceRequest = Oslp.ConfirmRegisterDeviceRequest.newBuilder().setRandomDevice(randomDevice).setRandomPlatform(randomPlatform).build();
        final Message message = Message.newBuilder().setConfirmRegisterDeviceRequest(confirmRegisterDeviceRequest).build();
        this.oslpMockServer.incrementSequenceNumber(this.getDeviceUid(settings));
        final OslpEnvelope request = this.createEnvelopeBuilder(deviceUid, this.oslpMockServer.getSequenceNumber(this.getDeviceUid(settings))).withPayloadMessage(message).build();
        this.send(request, settings);
    } catch (final IOException | IllegalArgumentException e) {
        ScenarioContext.current().put("Error", e);
    }
}
Also used : Message(org.opensmartgridplatform.oslp.Oslp.Message) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) ByteString(com.google.protobuf.ByteString) IOException(java.io.IOException) Oslp(org.opensmartgridplatform.oslp.Oslp) OslpDevice(org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice) OslpEnvelope(org.opensmartgridplatform.oslp.OslpEnvelope) Given(io.cucumber.java.en.Given)

Example 82 with Given

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

the class OslpDeviceSteps method theDeviceReturnsAGetConfigurationStatusWithResultOverOslp.

/**
 * Setup method to set the configuration status which should be returned by the mock.
 *
 * @throws UnknownHostException
 */
@Given("^the device returns a get configuration status \"([^\"]*)\" over \"([^\"]*)\"$")
public void theDeviceReturnsAGetConfigurationStatusWithResultOverOslp(final String result, final String protocol, final Map<String, String> requestParameters) throws UnknownHostException {
    final String osgpIpAddress = getString(requestParameters, PlatformPubliclightingKeys.OSGP_IP_ADDRESS);
    final String osgpIpAddressMock;
    if (StringUtils.isEmpty(osgpIpAddress)) {
        osgpIpAddressMock = null;
    } else {
        osgpIpAddressMock = osgpIpAddress;
    }
    this.oslpMockServer.mockGetConfigurationResponse(this.getDeviceUid(requestParameters), Enum.valueOf(Status.class, result), getEnum(requestParameters, PlatformPubliclightingKeys.KEY_LIGHTTYPE, LightType.class, PlatformPubliclightingDefaults.DEFAULT_LIGHTTYPE), getString(requestParameters, PlatformPubliclightingKeys.DC_LIGHTS, PlatformPubliclightingDefaults.DC_LIGHTS), getString(requestParameters, PlatformPubliclightingKeys.DC_MAP, PlatformPubliclightingDefaults.DEFAULT_DC_MAP), getString(requestParameters, PlatformPubliclightingKeys.RELAY_CONF, PlatformPubliclightingDefaults.DEFAULT_RELAY_CONFIGURATION), getEnum(requestParameters, PlatformPubliclightingKeys.KEY_PREFERRED_LINKTYPE, LinkType.class, PlatformPubliclightingDefaults.DEFAULT_PREFERRED_LINKTYPE), osgpIpAddressMock, getInteger(requestParameters, PlatformPubliclightingKeys.OSGP_PORT, PlatformPubliclightingDefaults.DEFAULT_OSLP_PORT));
}
Also used : Status(org.opensmartgridplatform.oslp.Oslp.Status) LightType(org.opensmartgridplatform.oslp.Oslp.LightType) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) ByteString(com.google.protobuf.ByteString) LinkType(org.opensmartgridplatform.oslp.Oslp.LinkType) Given(io.cucumber.java.en.Given)

Example 83 with Given

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

the class OslpDeviceSteps method aPendingSetScheduleRequest.

@Given("^a pending set schedule request that expires within \"([^\"]*)\" minutes$")
public void aPendingSetScheduleRequest(final int expiresInMinutes, final Map<String, String> settings) {
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION);
    final String deviceUid = getString(settings, PlatformKeys.KEY_DEVICE_UID, PlatformDefaults.DEVICE_UID);
    final String organisationIdentification = getString(settings, PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION, PlatformDefaults.DEFAULT_ORGANIZATION_IDENTIFICATION);
    final Date expireDateTime = Date.from(ZonedDateTime.now().plusMinutes(expiresInMinutes).toInstant());
    // just add a dummy DeviceRequest and a dummy
    // ScheduleMessageDataContainerDto
    final PendingSetScheduleRequest pendingSetScheduleRequest = PendingSetScheduleRequest.builder().deviceIdentification(deviceIdentification).deviceUid(deviceUid).expiredAt(expireDateTime).deviceRequest(new DeviceRequest(organisationIdentification, deviceIdentification, null, 4)).scheduleMessageDataContainerDto(new ScheduleMessageDataContainerDto.Builder(null).build()).build();
    this.pendingSetScheduleRequestRepository.save(pendingSetScheduleRequest);
}
Also used : PendingSetScheduleRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.PendingSetScheduleRequest) ScheduleMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.ScheduleMessageDataContainerDto) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) DeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.DeviceRequest) Date(java.util.Date) Given(io.cucumber.java.en.Given)

Example 84 with Given

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

the class Iec60870DeviceSteps method aLightMeasurementDevice.

@Given("a light sensor")
public void aLightMeasurementDevice(final Map<String, String> deviceData) {
    final Iec60870Device device = Iec60870DeviceFactory.fromSettings(this.settingsWithDeviceType(deviceData, DeviceType.LIGHT_SENSOR));
    this.deviceIsKnownInTheRepository(device);
}
Also used : Iec60870Device(org.opensmartgridplatform.adapter.protocol.iec60870.domain.entities.Iec60870Device) Given(io.cucumber.java.en.Given)

Example 85 with Given

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

the class RetrieveReceivedEventNotifications method anEvent.

@Given("^(\\d+) events?$")
public void anEvent(final int amount, final Map<String, String> data) throws Exception {
    final String deviceIdentification = getString(data, PlatformKeys.KEY_DEVICE_IDENTIFICATION);
    for (int i = 0; i < amount; i++) {
        final Event event = new Event(deviceIdentification, getDateTime(getString(data, PlatformKeys.TIMESTAMP, PlatformDefaults.TIMESTAMP)).toDate(), getEnum(data, PlatformKeys.EVENT_TYPE, EventType.class, EventType.ALARM_NOTIFICATION), getString(data, PlatformKeys.KEY_DESCRIPTION, PlatformDefaults.DEFAULT_EVENT_DESCRIPTION), getInteger(data, PlatformKeys.KEY_INDEX, 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)

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