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) {
 | 
			
		||||
        return entityIdKvEntryMap.entrySet().stream()
 | 
			
		||||
                .filter(entry -> entry.getValue().getJsonValue().isPresent())
 | 
			
		||||
                .collect(Collectors.toMap(Map.Entry::getKey,
 | 
			
		||||
                        entry -> new GeofencingZoneState(entry.getKey(), entry.getValue())));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user