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();
}
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations