Class ThingsBoardDeviceRegistryTest
java.lang.Object
de.iip_ecosphere.platform.deviceMgt.thingsboard.ThingsBoardDeviceRegistryTest
Tests the things board registry.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidTests that adding an already registered device updates the device.voidTests that adding a device with no identifier does not cause adding the device.voidTests that adding a device with no IP does not cause adding the device.voidTests that adding a valid device causes adding the device.voidTests that requesting a device with invalid ID returns null.voidTests that requesting a device with valid ID returns the device.voidTests that requesting a managed device with invalid ID returns null.voidTests that requesting a managed device with valid ID returns the device.voidTests that requesting devices with two devices returns a list with two IDs.voidCleans up after testing.private com.fasterxml.jackson.databind.JsonNodegetJsonNode(String string) Returns a JSON note from the givenstring.voidTests that requesting managed devices with two devices returns a list with two IDs.voidTests that heartbeats with a valid device leads to telemetry.voidTests that heartbeats with unknown device does not lead to telemetry.private org.thingsboard.server.common.data.DeviceMocks a device.voidTests that removing an invalid device does not remove a device.voidTests that removing an invalid device (no device information) does not remove a device.voidTests that removing an valid device removes the device.voidTests that sending invalid telemetry leads to an exception.voidTests that sending valid telemetry leads to saved data.voidsetUp()Configures the test before running.
-
Field Details
-
AN_IP
- See Also:
-
ANOTHER_IP
- See Also:
-
ANOTHER_DEVICE
- See Also:
-
A_DEVICE
- See Also:
-
deviceRegistry
private de.iip_ecosphere.platform.deviceMgt.thingsboard.ThingsBoardDeviceRegistry deviceRegistry -
thingsBoardMock
private org.thingsboard.rest.client.RestClient thingsBoardMock
-
-
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.JsonProcessingExceptionTests 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.JsonProcessingExceptionTests that sending valid telemetry leads to saved data.- Throws:
com.fasterxml.jackson.core.JsonProcessingException- JSON processing shall not failExecutionException- AAS execution shall not fail
-
sendTelemetry_withInvalidData_shouldThrowException
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, ExecutionExceptionTests that heartbeats with a valid device leads to telemetry.- Throws:
com.fasterxml.jackson.core.JsonProcessingException- JSON processing shall not failExecutionException- AAS execution shall not fail
-
imAlive_withUnknownDevice_shouldNotSendImAliveAsTelemetry
public void imAlive_withUnknownDevice_shouldNotSendImAliveAsTelemetry() throws com.fasterxml.jackson.core.JsonProcessingException, ExecutionExceptionTests that heartbeats with unknown device does not lead to telemetry.- Throws:
com.fasterxml.jackson.core.JsonProcessingException- JSON processing shall not failExecutionException- 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 givenstring.- Parameters:
string- the string- Returns:
- the JSON node
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- in case of failures
-