@Test public void initializesInvocationCounterForDeviceThatNeedsInvocationCounterWithInvocationCounterUninitialized() throws Exception { final DlmsDevice device = new DlmsDeviceBuilder().withHls5Active(true) .withProtocol("SMR") .withInvocationCounter(null) .build(); final DlmsMessageListener listener = new InvocationCountingDlmsMessageListener(); final DlmsConnectionManager connectionManager = mock(DlmsConnectionManager.class); when(this.connectionFactory.getConnection(device, listener)).thenReturn(connectionManager); this.helper.createConnectionForDevice(device, listener); verify(this.invocationCounterManager).initializeInvocationCounter(device); }
public DlmsConnectionManager createConnectionForDevice(final DlmsDevice device, final DlmsMessageListener messageListener) throws OsgpException { if (device.needsInvocationCounter() && !device.isInvocationCounterInitialized()) { this.invocationCounterManager.initializeInvocationCounter(device); } try { return this.connectionFactory.getConnection(device, messageListener); } catch (final ConnectionException e) { if (device.needsInvocationCounter() && this.indicatesInvocationCounterOutOfSync(e)) { this.resetInvocationCounter(device); } throw e; } }
DlmsConnectionHelper { public DlmsConnectionManager createConnectionForDevice(final DlmsDevice device, final DlmsMessageListener messageListener) throws OsgpException { if (device.needsInvocationCounter() && !device.isInvocationCounterInitialized()) { this.invocationCounterManager.initializeInvocationCounter(device); } try { return this.connectionFactory.getConnection(device, messageListener); } catch (final ConnectionException e) { if (device.needsInvocationCounter() && this.indicatesInvocationCounterOutOfSync(e)) { this.resetInvocationCounter(device); } throw e; } } }
DlmsConnectionHelper { public DlmsConnectionManager createConnectionForDevice(final DlmsDevice device, final DlmsMessageListener messageListener) throws OsgpException { if (device.needsInvocationCounter() && !device.isInvocationCounterInitialized()) { this.invocationCounterManager.initializeInvocationCounter(device); } try { return this.connectionFactory.getConnection(device, messageListener); } catch (final ConnectionException e) { if (device.needsInvocationCounter() && this.indicatesInvocationCounterOutOfSync(e)) { this.resetInvocationCounter(device); } throw e; } } @Autowired  DlmsConnectionHelper(final InvocationCounterManager invocationCounterManager,
            final DlmsConnectionFactory connectionFactory); }
DlmsConnectionHelper { public DlmsConnectionManager createConnectionForDevice(final DlmsDevice device, final DlmsMessageListener messageListener) throws OsgpException { if (device.needsInvocationCounter() && !device.isInvocationCounterInitialized()) { this.invocationCounterManager.initializeInvocationCounter(device); } try { return this.connectionFactory.getConnection(device, messageListener); } catch (final ConnectionException e) { if (device.needsInvocationCounter() && this.indicatesInvocationCounterOutOfSync(e)) { this.resetInvocationCounter(device); } throw e; } } @Autowired  DlmsConnectionHelper(final InvocationCounterManager invocationCounterManager,
            final DlmsConnectionFactory connectionFactory); DlmsConnectionManager createConnectionForDevice(final DlmsDevice device,
            final DlmsMessageListener messageListener); }
DlmsConnectionHelper { public DlmsConnectionManager createConnectionForDevice(final DlmsDevice device, final DlmsMessageListener messageListener) throws OsgpException { if (device.needsInvocationCounter() && !device.isInvocationCounterInitialized()) { this.invocationCounterManager.initializeInvocationCounter(device); } try { return this.connectionFactory.getConnection(device, messageListener); } catch (final ConnectionException e) { if (device.needsInvocationCounter() && this.indicatesInvocationCounterOutOfSync(e)) { this.resetInvocationCounter(device); } throw e; } } @Autowired  DlmsConnectionHelper(final InvocationCounterManager invocationCounterManager,
            final DlmsConnectionFactory connectionFactory); DlmsConnectionManager createConnectionForDevice(final DlmsDevice device,
            final DlmsMessageListener messageListener);  }