Replaced required JSON data type for geozone arguments
This commit is contained in:
parent
995ca2e4a8
commit
c56f82497c
@ -84,7 +84,6 @@ public class GeofencingArgumentEntry implements ArgumentEntry {
|
|||||||
|
|
||||||
private Map<EntityId, GeofencingZoneState> toZones(Map<EntityId, KvEntry> entityIdKvEntryMap) {
|
private Map<EntityId, GeofencingZoneState> toZones(Map<EntityId, KvEntry> entityIdKvEntryMap) {
|
||||||
return entityIdKvEntryMap.entrySet().stream()
|
return entityIdKvEntryMap.entrySet().stream()
|
||||||
.filter(entry -> entry.getValue().getJsonValue().isPresent())
|
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey,
|
.collect(Collectors.toMap(Map.Entry::getKey,
|
||||||
entry -> new GeofencingZoneState(entry.getKey(), entry.getValue())));
|
entry -> new GeofencingZoneState(entry.getKey(), entry.getValue())));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ public class GeofencingZoneState {
|
|||||||
}
|
}
|
||||||
this.ts = attributeKvEntry.getLastUpdateTs();
|
this.ts = attributeKvEntry.getLastUpdateTs();
|
||||||
this.version = attributeKvEntry.getVersion();
|
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) {
|
public GeofencingZoneState(GeofencingZoneProto proto) {
|
||||||
|
|||||||
@ -168,8 +168,9 @@ public class GeofencingValueArgumentEntryTest {
|
|||||||
@Test
|
@Test
|
||||||
void testInvalidKvEntryDataTypeForZoneResultInEmptyArgument() {
|
void testInvalidKvEntryDataTypeForZoneResultInEmptyArgument() {
|
||||||
BaseAttributeKvEntry invalidZoneEntry = new BaseAttributeKvEntry(new StringDataEntry("zone", "someString"), 363L, 155L);
|
BaseAttributeKvEntry invalidZoneEntry = new BaseAttributeKvEntry(new StringDataEntry("zone", "someString"), 363L, 155L);
|
||||||
GeofencingArgumentEntry geofencingArgumentEntry = new GeofencingArgumentEntry(Map.of(ZONE_1_ID, invalidZoneEntry));
|
assertThatThrownBy(() -> new GeofencingArgumentEntry(Map.of(ZONE_1_ID, invalidZoneEntry)))
|
||||||
assertThat(geofencingArgumentEntry.isEmpty()).isTrue();
|
.isExactlyInstanceOf(IllegalArgumentException.class)
|
||||||
|
.hasMessage("The given string value cannot be transformed to Json object: someString");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user