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