@Test public void duplicateAddressesAreClearedWhenUpdatingRegistrationData() throws Exception { final String deviceIdentification = "test-device"; final String ipAddress = "127.0.0.1"; final String deviceType = "DeviceType"; final boolean hasSchedule = false; when(this.deviceRepository.findByDeviceIdentification(deviceIdentification)) .thenReturn(new Device(deviceIdentification)); this.deviceRegistrationMessageService.updateRegistrationData(deviceIdentification, ipAddress, deviceType, hasSchedule); verify(this.deviceNetworkAddressCleanupService).clearDuplicateAddresses(deviceIdentification, ipAddress); }
@Transactional(value = "transactionManager") public Device updateRegistrationData(final String deviceIdentification, final String ipAddress, final String deviceType, final boolean hasSchedule) throws UnknownHostException { LOGGER.info("updateRegistrationData called for device: {} ipAddress: {}, deviceType: {} hasSchedule: {}.", deviceIdentification, ipAddress, deviceType, hasSchedule); this.deviceNetworkAddressCleanupService.clearDuplicateAddresses(deviceIdentification, ipAddress); Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); if (device == null) { device = this.createNewDevice(deviceIdentification, deviceType); } final InetAddress inetAddress = InetAddress.getByName(ipAddress); device.updateRegistrationData(inetAddress, deviceType); device.updateConnectionDetailsToSuccess(); return this.deviceRepository.save(device); }
DeviceRegistrationMessageService { @Transactional(value = "transactionManager") public Device updateRegistrationData(final String deviceIdentification, final String ipAddress, final String deviceType, final boolean hasSchedule) throws UnknownHostException { LOGGER.info("updateRegistrationData called for device: {} ipAddress: {}, deviceType: {} hasSchedule: {}.", deviceIdentification, ipAddress, deviceType, hasSchedule); this.deviceNetworkAddressCleanupService.clearDuplicateAddresses(deviceIdentification, ipAddress); Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); if (device == null) { device = this.createNewDevice(deviceIdentification, deviceType); } final InetAddress inetAddress = InetAddress.getByName(ipAddress); device.updateRegistrationData(inetAddress, deviceType); device.updateConnectionDetailsToSuccess(); return this.deviceRepository.save(device); } }
DeviceRegistrationMessageService { @Transactional(value = "transactionManager") public Device updateRegistrationData(final String deviceIdentification, final String ipAddress, final String deviceType, final boolean hasSchedule) throws UnknownHostException { LOGGER.info("updateRegistrationData called for device: {} ipAddress: {}, deviceType: {} hasSchedule: {}.", deviceIdentification, ipAddress, deviceType, hasSchedule); this.deviceNetworkAddressCleanupService.clearDuplicateAddresses(deviceIdentification, ipAddress); Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); if (device == null) { device = this.createNewDevice(deviceIdentification, deviceType); } final InetAddress inetAddress = InetAddress.getByName(ipAddress); device.updateRegistrationData(inetAddress, deviceType); device.updateConnectionDetailsToSuccess(); return this.deviceRepository.save(device); }  }
DeviceRegistrationMessageService { @Transactional(value = "transactionManager") public Device updateRegistrationData(final String deviceIdentification, final String ipAddress, final String deviceType, final boolean hasSchedule) throws UnknownHostException { LOGGER.info("updateRegistrationData called for device: {} ipAddress: {}, deviceType: {} hasSchedule: {}.", deviceIdentification, ipAddress, deviceType, hasSchedule); this.deviceNetworkAddressCleanupService.clearDuplicateAddresses(deviceIdentification, ipAddress); Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); if (device == null) { device = this.createNewDevice(deviceIdentification, deviceType); } final InetAddress inetAddress = InetAddress.getByName(ipAddress); device.updateRegistrationData(inetAddress, deviceType); device.updateConnectionDetailsToSuccess(); return this.deviceRepository.save(device); }  @Transactional(value = "transactionManager") Device updateRegistrationData(final String deviceIdentification, final String ipAddress,
            final String deviceType, final boolean hasSchedule); void sendRequestMessageToDomainCore(final String deviceIdentification,
            final String organisationIdentification, final String correlationUid, final MessageType messageType); }
DeviceRegistrationMessageService { @Transactional(value = "transactionManager") public Device updateRegistrationData(final String deviceIdentification, final String ipAddress, final String deviceType, final boolean hasSchedule) throws UnknownHostException { LOGGER.info("updateRegistrationData called for device: {} ipAddress: {}, deviceType: {} hasSchedule: {}.", deviceIdentification, ipAddress, deviceType, hasSchedule); this.deviceNetworkAddressCleanupService.clearDuplicateAddresses(deviceIdentification, ipAddress); Device device = this.deviceRepository.findByDeviceIdentification(deviceIdentification); if (device == null) { device = this.createNewDevice(deviceIdentification, deviceType); } final InetAddress inetAddress = InetAddress.getByName(ipAddress); device.updateRegistrationData(inetAddress, deviceType); device.updateConnectionDetailsToSuccess(); return this.deviceRepository.save(device); }  @Transactional(value = "transactionManager") Device updateRegistrationData(final String deviceIdentification, final String ipAddress,
            final String deviceType, final boolean hasSchedule); void sendRequestMessageToDomainCore(final String deviceIdentification,
            final String organisationIdentification, final String correlationUid, final MessageType messageType);  }