From c56f82497c26c2f35ca9ffe4cd8d9b4720d69993 Mon Sep 17 00:00:00 2001 From: dshvaika Date: Wed, 17 Sep 2025 17:48:15 +0300 Subject: [PATCH] Replaced required JSON data type for geozone arguments --- .../cf/ctx/state/geofencing/GeofencingArgumentEntry.java | 1 - .../service/cf/ctx/state/geofencing/GeofencingZoneState.java | 2 +- .../cf/ctx/state/GeofencingValueArgumentEntryTest.java | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingArgumentEntry.java b/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingArgumentEntry.java index d6b7aefed4..f526cc00ab 100644 --- a/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingArgumentEntry.java +++ b/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingArgumentEntry.java @@ -84,7 +84,6 @@ public class GeofencingArgumentEntry implements ArgumentEntry { private Map toZones(Map entityIdKvEntryMap) { return entityIdKvEntryMap.entrySet().stream() - .filter(entry -> entry.getValue().getJsonValue().isPresent()) .collect(Collectors.toMap(Map.Entry::getKey, entry -> new GeofencingZoneState(entry.getKey(), entry.getValue()))); } diff --git a/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingZoneState.java b/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingZoneState.java index 348c1ba9f1..c849f5d169 100644 --- a/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingZoneState.java +++ b/application/src/main/java/org/thingsboard/server/service/cf/ctx/state/geofencing/GeofencingZoneState.java @@ -50,7 +50,7 @@ public class GeofencingZoneState { } this.ts = attributeKvEntry.getLastUpdateTs(); this.version = attributeKvEntry.getVersion(); - this.perimeterDefinition = JacksonUtil.fromString(entry.getJsonValue().orElseThrow(), PerimeterDefinition.class); + this.perimeterDefinition = JacksonUtil.fromString(entry.getValueAsString(), PerimeterDefinition.class); } public GeofencingZoneState(GeofencingZoneProto proto) { diff --git a/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java b/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java index b3487f0e83..6da4bdc882 100644 --- a/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java +++ b/application/src/test/java/org/thingsboard/server/service/cf/ctx/state/GeofencingValueArgumentEntryTest.java @@ -168,8 +168,9 @@ public class GeofencingValueArgumentEntryTest { @Test void testInvalidKvEntryDataTypeForZoneResultInEmptyArgument() { BaseAttributeKvEntry invalidZoneEntry = new BaseAttributeKvEntry(new StringDataEntry("zone", "someString"), 363L, 155L); - GeofencingArgumentEntry geofencingArgumentEntry = new GeofencingArgumentEntry(Map.of(ZONE_1_ID, invalidZoneEntry)); - assertThat(geofencingArgumentEntry.isEmpty()).isTrue(); + assertThatThrownBy(() -> new GeofencingArgumentEntry(Map.of(ZONE_1_ID, invalidZoneEntry))) + .isExactlyInstanceOf(IllegalArgumentException.class) + .hasMessage("The given string value cannot be transformed to Json object: someString"); } @Test