use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceType in project open-smart-grid-platform by OSGP.
the class ConnectionSteps method whenIConnectToIEC60870Device.
@When("I connect to IEC60870 device {string}")
public void whenIConnectToIEC60870Device(final String deviceIdentification) throws Exception {
LOGGER.debug("When I connect to IEC60870 device {}", deviceIdentification);
final Iec60870Device device = this.iec60870DeviceSteps.getDevice(deviceIdentification).orElseThrow(() -> new Exception("Device not found"));
final DeviceType deviceType = device.getDeviceType();
final String connectionDeviceIdentification = device.getConnectionDeviceIdentification();
this.connectionParameters = this.initConnectionParameters(connectionDeviceIdentification);
this.connectionEventListener = new ClientConnectionEventListener.Builder().withDeviceIdentification(connectionDeviceIdentification).withClientAsduHandlerRegistry(this.clientAsduHandlerRegistry).withClientConnectionCache(this.connectionCacheSpy).withLoggingService(this.loggingService).withLogItemFactory(this.logItemFactory).withResponseMetadata(this.initResponseMetadata(deviceIdentification, deviceType)).withResponseMetadataFactory(this.responseMetadataFactory).build();
when(this.clientMock.connect(any(ConnectionParameters.class), any(ConnectionEventListener.class))).thenReturn(new DeviceConnection(this.connection, this.connectionParameters));
}
use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceType in project open-smart-grid-platform by OSGP.
the class ConnectionSteps method initResponseMetadata.
private ResponseMetadata initResponseMetadata(final String deviceIdentification, final DeviceType deviceType) throws Exception {
final DomainInfo domainInfo = DomainInfoFactory.forDeviceType(deviceType);
// Make sure the connection event listener works as expected
final ResponseMetadata responseMetadata = new ResponseMetadata.Builder().withDeviceIdentification(deviceIdentification).withDeviceType(deviceType).withOrganisationIdentification(DEFAULT_ORGANISATION_IDENTIFICATION).withDomainInfo(domainInfo).withMessageType(DEFAULT_MESSAGE_TYPE).build();
return responseMetadata;
}
use of org.opensmartgridplatform.adapter.protocol.iec60870.domain.valueobjects.DeviceType in project open-smart-grid-platform by OSGP.
the class ConnectionSteps method givenIec60870DeviceIsConnected.
@Given("an existing connection with IEC60870 device {string} of type {deviceType}")
public void givenIec60870DeviceIsConnected(final String deviceIdentification, final DeviceType deviceType) throws Exception {
LOGGER.debug("Given an existing connection with IEC60870 device {} of type {}", deviceIdentification, deviceType);
// Make sure the connection event listener works as expected
this.connectionParameters = this.initConnectionParameters(deviceIdentification);
final ResponseMetadata responseMetadata = this.initResponseMetadata(deviceIdentification, deviceType);
this.connectionEventListener = new ClientConnectionEventListener.Builder().withDeviceIdentification(deviceIdentification).withClientAsduHandlerRegistry(this.clientAsduHandlerRegistry).withClientConnectionCache(this.connectionCacheSpy).withLoggingService(this.loggingService).withLogItemFactory(this.logItemFactory).withResponseMetadata(responseMetadata).withResponseMetadataFactory(this.responseMetadataFactory).build();
// Make sure a connection could be retrieved from the cache
// Only needed for scenarios sending requests to a device
// final Connection connection = mock(Connection.class);
this.connectionCacheSpy.addConnection(deviceIdentification, new DeviceConnection(this.connection, this.connectionParameters));
}
Aggregations