Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Remove unused deviceMeasurementId in integration tests
Browse files Browse the repository at this point in the history
The variable "deviceMeasurementId" that was previously generated and unused in both `DroneDeviceMeasurementIntegrationServiceIT` and `DeviceMeasurementIntegrationServiceIT` has been deleted. Tests are now using "deviceId" directly, simplifying the readability and efficiency of the code. Also, the warning suppression annotation was added to `StatusService` and `SubscriptionService` classes.
  • Loading branch information
saschadoemer committed Feb 20, 2024
1 parent 85c3d7f commit ac72e59
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/main/java/de/app/fivegla/fiware/StatusService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.net.http.HttpResponse;

@Slf4j
@SuppressWarnings("unused")
public class StatusService extends AbstractIntegrationService<Version> {
public StatusService(String contextBrokerUrl, String tenant) {
super(contextBrokerUrl, tenant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @see AbstractIntegrationService
*/
@Slf4j
@SuppressWarnings("unused")
public class SubscriptionService extends AbstractIntegrationService<Subscription> {
private final List<String> notificationUrls;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.UUID;

class DeviceMeasurementIntegrationServiceIT extends AbstractIT {

Expand All @@ -28,12 +27,11 @@ void givenAlreadyExistingDeviceWhenCreatingNewDevicesTheServiceShouldNotThrowAnE
var manufacturerSpecificId = FiwareIdGenerator.id();
var deviceId = "integration-test:" + manufacturerSpecificId;
var location = Location.builder().coordinates(List.of(1.0, 2.0)).build();
String deviceMeasurementId = "integration-test:" + UUID.randomUUID();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceId).numValue(2.4).location(location).build();
deviceMeasurementIntegrationService.persist(deviceMeasurement);
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceMeasurementId));
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceId));
deviceMeasurementIntegrationService.persist(deviceMeasurement);
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceMeasurementId));
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceId));
}

@Test
Expand All @@ -42,18 +40,17 @@ void givenAlreadyExistingDeviceWhenUpdatingTheDeviceTheServiceShouldUpdateTheVal
var manufacturerSpecificId = FiwareIdGenerator.id();
var deviceId = "integration-test:" + manufacturerSpecificId;
var location = Location.builder().coordinates(List.of(1.0, 2.0)).build();
String deviceMeasurementId = "integration-test:" + UUID.randomUUID();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceMeasurementId).numValue(2.4).location(location).build();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceId).numValue(2.4).location(location).build();
deviceMeasurementIntegrationService.persist(deviceMeasurement);
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceMeasurementId));
var persistedDeviceMeasurement = deviceMeasurementIntegrationService.read(deviceMeasurementId);
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceId));
var persistedDeviceMeasurement = deviceMeasurementIntegrationService.read(deviceId);
Assertions.assertTrue(persistedDeviceMeasurement.isPresent());
Assertions.assertEquals(2.4, persistedDeviceMeasurement.get().getNumValue());

deviceMeasurement.setNumValue(8.16);
deviceMeasurementIntegrationService.persist(deviceMeasurement);
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceMeasurementId));
persistedDeviceMeasurement = deviceMeasurementIntegrationService.read(deviceMeasurementId);
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceId));
persistedDeviceMeasurement = deviceMeasurementIntegrationService.read(deviceId);
Assertions.assertTrue(persistedDeviceMeasurement.isPresent());
Assertions.assertEquals(8.16, persistedDeviceMeasurement.get().getNumValue());
}
Expand All @@ -64,10 +61,9 @@ void givenExistingDeviceWhenCheckingIfTheDeviceDoesExistTheServiceShouldReturnTr
var manufacturerSpecificId = FiwareIdGenerator.id();
var deviceId = "integration-test:" + manufacturerSpecificId;
var location = Location.builder().coordinates(List.of(1.0, 2.0)).build();
String deviceMeasurementId = "integration-test:" + UUID.randomUUID();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceMeasurementId).numValue(2.4).location(location).build();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceId).numValue(2.4).location(location).build();
deviceMeasurementIntegrationService.persist(deviceMeasurement);
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceMeasurementId));
Assertions.assertTrue(deviceMeasurementIntegrationService.exists(deviceId));
Assertions.assertFalse(deviceMeasurementIntegrationService.exists("integration-test:does-not-exist"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void givenAlreadyExistingDeviceWhenCreatingNewDevicesTheServiceShouldNotThrowAnE
var manufacturerSpecificId = FiwareIdGenerator.id();
var deviceId = "integration-test:" + manufacturerSpecificId;
var location = Location.builder().coordinates(List.of(1.0, 2.0)).build();
var deviceMeasurementId = "integration-test:" + UUID.randomUUID();
var droneDeviceMeasurementId = "integration-test:" + UUID.randomUUID();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceId).numValue(2.4).location(location).build();
var droneDeviceMeasurement = DroneDeviceMeasurement.builder().id(droneDeviceMeasurementId).deviceMeasurement(deviceMeasurement).channel("red").imagePath("http://localhost:8080/images/" + UUID.randomUUID()).build();
Expand All @@ -46,7 +45,6 @@ void givenAlreadyExistingDeviceWhenUpdatingTheDeviceTheServiceShouldUpdateTheVal
var manufacturerSpecificId = FiwareIdGenerator.id();
var deviceId = "integration-test:" + manufacturerSpecificId;
var location = Location.builder().coordinates(List.of(1.0, 2.0)).build();
var deviceMeasurementId = "integration-test:" + UUID.randomUUID();
var droneDeviceMeasurementId = "integration-test:" + UUID.randomUUID();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceId).numValue(2.4).location(location).build();
var droneDeviceMeasurement = DroneDeviceMeasurement.builder().id(droneDeviceMeasurementId).deviceMeasurement(deviceMeasurement).channel("red").imagePath("http://localhost:8080/images/" + UUID.randomUUID()).build();
Expand All @@ -68,7 +66,6 @@ void givenExistingDeviceWhenCheckingIfTheDeviceDoesExistTheServiceShouldReturnTr
var manufacturerSpecificId = FiwareIdGenerator.id();
var deviceId = "integration-test:" + manufacturerSpecificId;
var location = Location.builder().coordinates(List.of(1.0, 2.0)).build();
String deviceMeasurementId = "integration-test:" + UUID.randomUUID();
var droneDeviceMeasurementId = "integration-test:" + UUID.randomUUID();
var deviceMeasurement = DeviceMeasurement.builder().id(deviceId).numValue(2.4).location(location).build();
var droneDeviceMeasurement = DroneDeviceMeasurement.builder().id(droneDeviceMeasurementId).deviceMeasurement(deviceMeasurement).channel("red").imagePath("http://localhost:8080/images/" + UUID.randomUUID()).build();
Expand Down

0 comments on commit ac72e59

Please sign in to comment.