use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method getDeviceIpAddressFromSessionProviderReturnsAddressFromProviderIfDeviceIsInSession.
@Test
void getDeviceIpAddressFromSessionProviderReturnsAddressFromProviderIfDeviceIsInSession() throws Exception {
final String communicationProvider = "comm-prov";
final String iccId = "icc-id";
final String ipAddress = IP_ADDRESS;
this.whenSessionProviderReturnsIpAddress(communicationProvider, iccId, ipAddress);
final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withCommunicationProvider(communicationProvider).setIccId(iccId).build();
final String actualIpAddress = this.domainHelperService.getDeviceIpAddressFromSessionProvider(dlmsDevice);
assertThat(actualIpAddress).isEqualTo(ipAddress);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method getDeviceIpAddressFromSessionProviderReturnsIpAddressOnlyAfterWakeUp.
@Test
void getDeviceIpAddressFromSessionProviderReturnsIpAddressOnlyAfterWakeUp() throws Exception {
final String communicationProvider = "comm-prov";
final String iccId = "icc-id";
final String ipAddress = IP_ADDRESS;
this.whenSessionProviderReturnsIpAddressAfterWakeUp(communicationProvider, iccId, ipAddress);
final DlmsDevice dlmsDevice = new DlmsDeviceBuilder().withCommunicationProvider(communicationProvider).setIccId(iccId).build();
final String actualIpAddress = this.domainHelperService.getDeviceIpAddressFromSessionProvider(dlmsDevice);
assertThat(actualIpAddress).isEqualTo(ipAddress);
verify(this.jasperWirelessSmsClient).sendWakeUpSMS(iccId);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder 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.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class InvocationCounterManagerTest method initializesInvocationCounterForDevice.
@Test
void initializesInvocationCounterForDevice() throws Exception {
final long invocationCounterValueOnDevice = 123;
final DlmsConnectionManager connectionManager = mock(DlmsConnectionManager.class);
final DataObject dataObject = DataObject.newUInteger32Data(invocationCounterValueOnDevice);
when(this.dlmsHelper.getAttributeValue(eq(connectionManager), refEq(ATTRIBUTE_ADDRESS_INVOCATION_COUNTER_VALUE))).thenReturn(dataObject);
when(this.deviceRepository.save(this.device)).thenReturn(new DlmsDeviceBuilder().withDeviceIdentification(this.device.getDeviceIdentification()).withInvocationCounter(this.device.getInvocationCounter()).withVersion(this.device.getVersion() + 1).build());
this.manager.initializeWithInvocationCounterStoredOnDeviceTask(this.device, connectionManager);
verify(this.deviceRepository).save(this.device);
verify(this.deviceRepository).save(this.device);
assertThat(this.device.getVersion()).isGreaterThan(this.initialDeviceVersion);
assertThat(this.device.getInvocationCounter()).isEqualTo(invocationCounterValueOnDevice);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareRequestMessageProcessorTest method setup.
@BeforeEach
void setup() throws OsgpException {
this.device = new DlmsDeviceBuilder().withHls5Active(true).build();
when(this.domainHelperService.findDlmsDevice(any(MessageMetadata.class))).thenReturn(this.device);
when(this.dlmsConnectionManagerMock.getDlmsMessageListener()).thenReturn(this.messageListenerMock);
when(this.throttlingClientConfig.clientEnabled()).thenReturn(false);
doNothing().when(this.connectionHelper).createAndHandleConnectionForDevice(any(MessageMetadata.class), same(this.device), nullable(DlmsMessageListener.class), any(Consumer.class));
}
Aggregations