use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class DlmsConnectionFactoryTest method createsConnectionManagerForLls0Device.
@Test
void createsConnectionManagerForLls0Device() throws Exception {
final DlmsDevice device = new DlmsDeviceBuilder().withLls1Active(false).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
when(this.lls0Connector.connect(this.messageMetadata, device, listener)).thenReturn(this.connection);
final DlmsConnectionManager expected = this.newConnectionManager(device, listener, this.lls0Connector);
this.factory.createAndHandleConnection(this.messageMetadata, device, listener, this.task);
this.assertConnectionManagerForDevice(expected);
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class DlmsConnectionFactoryTest method createAndHandleConnectionThrowsForHls3Device.
@Test
void createAndHandleConnectionThrowsForHls3Device() {
final DlmsDevice device = new DlmsDeviceBuilder().withHls3Active(true).build();
final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener();
assertThatExceptionOfType(FunctionalException.class).isThrownBy(() -> this.factory.createAndHandleConnection(this.messageMetadata, device, listener, this.task));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class DomainHelperServiceTest method setsIpAddressFromSessionProviderIfIpAddressIsNotStatic.
@Test
void setsIpAddressFromSessionProviderIfIpAddressIsNotStatic() 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().withIpAddressStatic(false).withCommunicationProvider(communicationProvider).setIccId(iccId).build();
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withIpAddress(null).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 SystemEventServiceTest method verifyMaxValueNotReachedEvent.
@Test
void verifyMaxValueNotReachedEvent() {
final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(this.invocationCounterEventThreshold - 1).build();
final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
verifyNoInteractions(this.correlationIdProviderService);
verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
use of org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder in project open-smart-grid-platform by OSGP.
the class SystemEventServiceTest method verifyInvocationCounterIsNull.
@Test
void verifyInvocationCounterIsNull() {
final DlmsDevice device = new DlmsDeviceBuilder().withInvocationCounter(null).build();
final MessageMetadata messageMetadata = new Builder().withOrganisationIdentification("org-id").build();
this.service.verifySystemEventThresholdReachedEvent(device, messageMetadata);
verifyNoInteractions(this.correlationIdProviderService);
verify(this.osgpRequestMessageSender, never()).send(any(RequestMessage.class), eq(MessageType.SYSTEM_EVENT.name()), any(MessageMetadata.class));
}
Aggregations