mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 13:28:08 +01:00
Deserialize null capabilities in Device entities as empty sets
This commit is contained in:
@@ -6,11 +6,15 @@
|
||||
package org.whispersystems.textsecuregcm.storage;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.whispersystems.textsecuregcm.util.SystemMapper;
|
||||
|
||||
class DeviceTest {
|
||||
|
||||
@@ -42,4 +46,25 @@ class DeviceTest {
|
||||
assertEquals(expectExpired, device.isExpired());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deserializeCapabilities() throws JsonProcessingException {
|
||||
{
|
||||
final Device device = SystemMapper.jsonMapper().readValue("""
|
||||
{
|
||||
"capabilities": null
|
||||
}
|
||||
""", Device.class);
|
||||
|
||||
assertNotNull(device.getCapabilities(),
|
||||
"Device deserialization should populate null capabilities with an empty set");
|
||||
}
|
||||
|
||||
{
|
||||
final Device device = SystemMapper.jsonMapper().readValue("{}", Device.class);
|
||||
|
||||
assertNotNull(device.getCapabilities(),
|
||||
"Device deserialization should populate null capabilities with an empty set");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user