Class ThingsBoardDeviceRegistryTest

java.lang.Object
de.iip_ecosphere.platform.deviceMgt.thingsboard.ThingsBoardDeviceRegistryTest

public class ThingsBoardDeviceRegistryTest extends Object
Tests the things board registry.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • ThingsBoardDeviceRegistryTest

      public ThingsBoardDeviceRegistryTest()
  • Method Details

    • setUp

      public void setUp()
      Configures the test before running.
    • getIds_withTwoDevices_shouldReturnListWithTwoIds

      public void getIds_withTwoDevices_shouldReturnListWithTwoIds()
      Cleans up after testing.
    • getManagedIds_withTwoDevices_shouldReturnListWithTwoIds

      public void getManagedIds_withTwoDevices_shouldReturnListWithTwoIds()
      Tests that requesting managed devices with two devices returns a list with two IDs.
    • getDevices_withTwoDevices_shouldReturnListWithTwoIds

      public void getDevices_withTwoDevices_shouldReturnListWithTwoIds()
      Tests that requesting devices with two devices returns a list with two IDs.
    • getDevice_withValidId_returnsDevice

      public void getDevice_withValidId_returnsDevice()
      Tests that requesting a device with valid ID returns the device.
    • getDevice_withInvalidId_returnsNull

      public void getDevice_withInvalidId_returnsNull()
      Tests that requesting a device with invalid ID returns null.
    • getDeviceByManagedId_withValidId_returnsDevice

      public void getDeviceByManagedId_withValidId_returnsDevice()
      Tests that requesting a managed device with valid ID returns the device.
    • getDeviceByManagedId_withInvalidId_returnsNull

      public void getDeviceByManagedId_withInvalidId_returnsNull()
      Tests that requesting a managed device with invalid ID returns null.
    • addDevice_withValidDevice_addsADevice

      public void addDevice_withValidDevice_addsADevice() throws com.fasterxml.jackson.core.JsonProcessingException
      Tests that adding a valid device causes adding the device.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if JSON processing problems occur, shall not happen
    • addDevice_withNoIp_wontAddDevice

      public void addDevice_withNoIp_wontAddDevice()
      Tests that adding a device with no IP does not cause adding the device.
    • addDevice_withNoDeviceIdentifier_wontAddDevice

      public void addDevice_withNoDeviceIdentifier_wontAddDevice()
      Tests that adding a device with no identifier does not cause adding the device.
    • addDevice_withAlreadyRegisteredDevice_updatesDevice

      public void addDevice_withAlreadyRegisteredDevice_updatesDevice()
      Tests that adding an already registered device updates the device.
    • removeDevice_withValidDevice_removesDevice

      public void removeDevice_withValidDevice_removesDevice()
      Tests that removing an valid device removes the device.
    • removeDevice_withInvalidDevice_wontRemoveDevice

      public void removeDevice_withInvalidDevice_wontRemoveDevice()
      Tests that removing an invalid device does not remove a device.
    • removeDevice_withNoDevice_wontRemoveDevice

      public void removeDevice_withNoDevice_wontRemoveDevice()
      Tests that removing an invalid device (no device information) does not remove a device.
    • sendTelemetry_withValidData_shouldSaveTelemetry

      public void sendTelemetry_withValidData_shouldSaveTelemetry() throws ExecutionException, com.fasterxml.jackson.core.JsonProcessingException
      Tests that sending valid telemetry leads to saved data.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - JSON processing shall not fail
      ExecutionException - AAS execution shall not fail
    • sendTelemetry_withInvalidData_shouldThrowException

      public void sendTelemetry_withInvalidData_shouldThrowException() throws ExecutionException
      Tests that sending invalid telemetry leads to an exception.
      Throws:
      ExecutionException - AAS execution shall not fail
    • imAlive_sendImAliveAsTelemetry

      public void imAlive_sendImAliveAsTelemetry() throws com.fasterxml.jackson.core.JsonProcessingException, ExecutionException
      Tests that heartbeats with a valid device leads to telemetry.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - JSON processing shall not fail
      ExecutionException - AAS execution shall not fail
    • imAlive_withUnknownDevice_shouldNotSendImAliveAsTelemetry

      public void imAlive_withUnknownDevice_shouldNotSendImAliveAsTelemetry() throws com.fasterxml.jackson.core.JsonProcessingException, ExecutionException
      Tests that heartbeats with unknown device does not lead to telemetry.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - JSON processing shall not fail
      ExecutionException - AAS execution shall not fail
    • mockDevice

      @NotNull private org.thingsboard.server.common.data.Device mockDevice()
      Mocks a device.
      Returns:
      the mocked device
    • getJsonNode

      private com.fasterxml.jackson.databind.JsonNode getJsonNode(String string) throws com.fasterxml.jackson.core.JsonProcessingException
      Returns a JSON note from the given string.
      Parameters:
      string - the string
      Returns:
      the JSON node
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - in case of failures