use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method setsIpAddressFromMessageMetadataIfIpAddressIsStatic.
@Test
void setsIpAddressFromMessageMetadataIfIpAddressIsStatic() throws Exception {
final String ipAddress = IP_ADDRESS;
final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withIpAddress(null).withIpAddressStatic(true).build();
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withIpAddress(ipAddress).build();
this.domainHelperService.setIpAddressFromMessageMetadataOrSessionProvider(dlmsDevice, messageMetadata);
assertThat(dlmsDevice.getIpAddress()).isEqualTo(ipAddress);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutorTest method connectionProblemAlarmRegister1.
@Test
void connectionProblemAlarmRegister1() throws ProtocolAdapterException, IOException {
when(this.dlmsConnection.set(this.setParameterArgumentCaptor.capture())).thenThrow(new IOException());
final DlmsDevice dlmsDevice = new DlmsDevice("SMR 5.2 device");
this.setupAlarmRegister1(dlmsDevice);
final Throwable actual = catchThrowable(() -> this.executor.execute(this.connectionManager, dlmsDevice, this.dto, this.messageMetadata));
assertThat(actual).isInstanceOf(ConnectionException.class);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutorTest method connectionProblemAlarmRegister2.
@Test
void connectionProblemAlarmRegister2() throws ProtocolAdapterException, IOException {
when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS).thenThrow(new IOException());
final DlmsDevice dlmsDevice = new DlmsDevice("SMR 5.2 device");
this.setupAlarmRegister2(dlmsDevice);
final Throwable actual = catchThrowable(() -> this.executor.execute(this.connectionManager, dlmsDevice, this.dto, this.messageMetadata));
assertThat(actual).isInstanceOf(ConnectionException.class);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutorTest method nullResultAlarmRegister2.
@Test
void nullResultAlarmRegister2() throws ProtocolAdapterException, IOException {
when(this.dlmsConnection.set(this.setParameterArgumentCaptor.capture())).thenReturn(AccessResultCode.SUCCESS).thenReturn(null);
final DlmsDevice dlmsDevice = new DlmsDevice("SMR 5.2 device");
this.setupAlarmRegister2(dlmsDevice);
final Throwable actual = catchThrowable(() -> this.executor.execute(this.connectionManager, dlmsDevice, this.dto, this.messageMetadata));
assertThat(actual).isInstanceOf(ProtocolAdapterException.class);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutorTest method successRegister1AndResultAlarmRegister2.
@Test
void successRegister1AndResultAlarmRegister2() throws ProtocolAdapterException, IOException {
when(this.dlmsConnection.set(this.setParameterArgumentCaptor.capture())).thenReturn(AccessResultCode.SUCCESS).thenReturn(AccessResultCode.TEMPORARY_FAILURE);
final DlmsDevice dlmsDevice = new DlmsDevice("SMR 5.2 device");
this.setupAlarmRegister2(dlmsDevice);
final AccessResultCode accessResultCode = this.executor.execute(this.connectionManager, dlmsDevice, this.dto, this.messageMetadata);
assertThat(accessResultCode).isEqualTo(AccessResultCode.TEMPORARY_FAILURE);
}
Aggregations