Search in sources :

Example 91 with Given

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

the class OrganizationSteps method theOrganizationExists.

/**
 * Generic method to check if the organization exists in the database.
 *
 * @param expectedOrganization An organization which has to exist in the database
 * @throws Throwable
 */
@Given("^the organization exists$")
public void theOrganizationExists(final Map<String, String> expectedOrganization) {
    final Organisation entity = Wait.untilAndReturn(() -> {
        return this.organisationRepository.findByOrganisationIdentification(expectedOrganization.get(PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION));
    });
    assertThat(entity).isNotNull();
    if (expectedOrganization.containsKey(PlatformKeys.KEY_NAME)) {
        assertThat(entity.getName()).isEqualTo(getString(expectedOrganization, PlatformKeys.KEY_NAME));
    }
    if (expectedOrganization.containsKey(PlatformKeys.KEY_PLATFORM_FUNCTION_GROUP)) {
        assertThat(entity.getFunctionGroup()).isEqualTo(getEnum(expectedOrganization, PlatformKeys.KEY_PLATFORM_FUNCTION_GROUP, PlatformFunctionGroup.class));
    }
    if (expectedOrganization.containsKey(PlatformKeys.KEY_DOMAINS) && !expectedOrganization.get(PlatformKeys.KEY_DOMAINS).isEmpty()) {
        for (final String domain : expectedOrganization.get(PlatformKeys.KEY_DOMAINS).split(PlatformKeys.SEPARATOR_SEMICOLON)) {
            assertThat(entity.getDomains().contains(PlatformDomain.valueOf(domain))).isTrue();
        }
    }
}
Also used : Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) PlatformFunctionGroup(org.opensmartgridplatform.domain.core.valueobjects.PlatformFunctionGroup) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Given(io.cucumber.java.en.Given)

Example 92 with Given

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

the class DeviceOutputSettingsSteps method deviceOutputSettingsForLightValues.

@Given("^device output settings for lightvalues$")
public void deviceOutputSettingsForLightValues(final Map<String, String> settings) {
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION);
    final Ssld device = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
    final String[] lightValues = getString(settings, PlatformKeys.KEY_LIGHTVALUES, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION).split(PlatformKeys.SEPARATOR_SEMICOLON);
    final String[] deviceOutputSettings = getString(settings, PlatformKeys.DEVICE_OUTPUT_SETTINGS, "").split(PlatformKeys.SEPARATOR_SEMICOLON);
    final List<DeviceOutputSetting> outputSettings = new ArrayList<>();
    for (int i = 0; i < lightValues.length; i++) {
        final String[] lightValueParts = lightValues[i].split(PlatformKeys.SEPARATOR_COMMA);
        final String[] deviceOutputSettingsPart = deviceOutputSettings[i].split(PlatformKeys.SEPARATOR_COMMA);
        final DeviceOutputSetting deviceOutputSettingsForLightValue = new DeviceOutputSetting(Integer.parseInt(deviceOutputSettingsPart[0]), Integer.parseInt(lightValueParts[0]), Enum.valueOf(RelayType.class, deviceOutputSettingsPart[1]), deviceOutputSettingsPart[2]);
        outputSettings.add(deviceOutputSettingsForLightValue);
    }
    this.saveDeviceOutputSettingsAndRelayStatuses(outputSettings, device);
}
Also used : RelayType(org.opensmartgridplatform.domain.core.valueobjects.RelayType) ArrayList(java.util.ArrayList) DeviceOutputSetting(org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld) Given(io.cucumber.java.en.Given)

Example 93 with Given

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

the class DeviceOutputSettingsSteps method deviceOutputSettings.

@Given("^device output settings$")
public void deviceOutputSettings(final Map<String, String> settings) {
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION);
    final Ssld device = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
    final String[] deviceOutputSettings = getString(settings, PlatformKeys.DEVICE_OUTPUT_SETTINGS, "").split(PlatformKeys.SEPARATOR_SEMICOLON);
    final List<DeviceOutputSetting> outputSettings = new ArrayList<>();
    for (final String deviceOutputSetting : deviceOutputSettings) {
        final String[] deviceOutputSettingsPart = deviceOutputSetting.split(PlatformKeys.SEPARATOR_COMMA);
        final DeviceOutputSetting deviceOutputSettingsForLightValue = new DeviceOutputSetting(Integer.parseInt(deviceOutputSettingsPart[0]), Integer.parseInt(deviceOutputSettingsPart[1]), Enum.valueOf(RelayType.class, deviceOutputSettingsPart[2]), deviceOutputSettingsPart[3]);
        outputSettings.add(deviceOutputSettingsForLightValue);
    }
    this.saveDeviceOutputSettingsAndRelayStatuses(outputSettings, device);
}
Also used : RelayType(org.opensmartgridplatform.domain.core.valueobjects.RelayType) ArrayList(java.util.ArrayList) DeviceOutputSetting(org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld) Given(io.cucumber.java.en.Given)

Example 94 with Given

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

the class DeviceOutputSettingsSteps method aDeviceOutputSetting.

@Given("^a device output setting$")
public void aDeviceOutputSetting(final Map<String, String> settings) {
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION);
    final Ssld device = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
    final List<DeviceOutputSetting> outputSettings = new ArrayList<>();
    final DeviceOutputSetting deviceOutputSetting = new DeviceOutputSetting(getInteger(settings, PlatformKeys.KEY_INTERNALID, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_INTERNALID), getInteger(settings, PlatformKeys.KEY_EXTERNALID, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_EXTERNALID), getEnum(settings, PlatformKeys.KEY_RELAY_TYPE, RelayType.class, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_RELAY_TYPE), getString(settings, PlatformKeys.ALIAS, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_ALIAS));
    outputSettings.add(deviceOutputSetting);
    this.saveDeviceOutputSettingsAndRelayStatuses(outputSettings, device);
}
Also used : RelayType(org.opensmartgridplatform.domain.core.valueobjects.RelayType) ArrayList(java.util.ArrayList) DeviceOutputSetting(org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld) Given(io.cucumber.java.en.Given)

Example 95 with Given

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

the class EventSteps method anEvent.

@Given("^an event$")
public void anEvent(final Map<String, String> data) {
    final String deviceIdentification = getString(data, PlatformKeys.KEY_DEVICE_IDENTIFICATION);
    final Date date = getDateTime2(getString(data, PlatformKeys.DATE), DateTime.now()).toDate();
    final EventType eventType = getEnum(data, PlatformKeys.EVENT_TYPE, EventType.class, EventType.DIAG_EVENTS_GENERAL);
    final String description = getString(data, PlatformKeys.KEY_DESCRIPTION, "");
    final Integer index = getInteger(data, PlatformKeys.KEY_INDEX, PlatformDefaults.DEFAULT_INDEX);
    final Event event = new Event(deviceIdentification, date, eventType, description, index);
    this.eventRepository.save(event);
}
Also used : ReadSettingsHelper.getInteger(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getInteger) EventType(org.opensmartgridplatform.domain.core.valueobjects.EventType) Event(org.opensmartgridplatform.domain.core.entities.Event) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Date(java.util.Date) 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