|
17 | 17 |
|
18 | 18 | package org.openqa.selenium.json; |
19 | 19 |
|
20 | | -import static java.util.logging.Level.ALL; |
21 | | -import static java.util.logging.Level.FINE; |
22 | | -import static java.util.logging.Level.OFF; |
23 | | -import static java.util.logging.Level.WARNING; |
24 | | -import static org.assertj.core.api.Assertions.assertThat; |
25 | | -import static org.assertj.core.api.Assertions.byLessThan; |
26 | | -import static org.openqa.selenium.Proxy.ProxyType.PAC; |
27 | | -import static org.openqa.selenium.json.Json.MAP_TYPE; |
28 | | -import static org.openqa.selenium.logging.LogType.BROWSER; |
29 | | -import static org.openqa.selenium.logging.LogType.CLIENT; |
30 | | -import static org.openqa.selenium.logging.LogType.DRIVER; |
31 | | -import static org.openqa.selenium.logging.LogType.SERVER; |
32 | | - |
33 | 20 | import com.google.common.collect.ImmutableMap; |
34 | 21 | import com.google.common.reflect.TypeToken; |
35 | | - |
36 | 22 | import org.junit.Test; |
37 | 23 | import org.openqa.selenium.Capabilities; |
38 | 24 | import org.openqa.selenium.Cookie; |
|
50 | 36 | import org.openqa.selenium.remote.SessionId; |
51 | 37 |
|
52 | 38 | import java.io.StringReader; |
| 39 | +import java.time.Instant; |
53 | 40 | import java.util.Arrays; |
54 | 41 | import java.util.Collections; |
55 | 42 | import java.util.Date; |
56 | 43 | import java.util.List; |
57 | 44 | import java.util.Map; |
58 | 45 | import java.util.concurrent.TimeUnit; |
59 | 46 |
|
| 47 | +import static java.util.logging.Level.ALL; |
| 48 | +import static java.util.logging.Level.FINE; |
| 49 | +import static java.util.logging.Level.OFF; |
| 50 | +import static java.util.logging.Level.WARNING; |
| 51 | +import static org.assertj.core.api.Assertions.assertThat; |
| 52 | +import static org.assertj.core.api.Assertions.byLessThan; |
| 53 | +import static org.openqa.selenium.Proxy.ProxyType.PAC; |
| 54 | +import static org.openqa.selenium.json.Json.MAP_TYPE; |
| 55 | +import static org.openqa.selenium.logging.LogType.BROWSER; |
| 56 | +import static org.openqa.selenium.logging.LogType.CLIENT; |
| 57 | +import static org.openqa.selenium.logging.LogType.DRIVER; |
| 58 | +import static org.openqa.selenium.logging.LogType.SERVER; |
| 59 | + |
60 | 60 | public class JsonTest { |
61 | 61 |
|
62 | 62 | @Test |
@@ -216,6 +216,17 @@ public void shouldSetPrimitiveValuesToo() { |
216 | 216 | assertThat(map.get("magicNumber")).isEqualTo(3L); |
217 | 217 | } |
218 | 218 |
|
| 219 | + @Test |
| 220 | + public void shouldBeAbleToReadAnInstant() { |
| 221 | + // We will lose the nanoseconds |
| 222 | + Instant now = Instant.ofEpochMilli(System.currentTimeMillis()); |
| 223 | + String raw = String.valueOf(now.toEpochMilli()); |
| 224 | + |
| 225 | + Instant instant = new Json().toType(raw, Instant.class); |
| 226 | + |
| 227 | + assertThat(instant).isEqualTo(now); |
| 228 | + } |
| 229 | + |
219 | 230 | @Test |
220 | 231 | public void shouldPopulateFieldsOnNestedBeans() { |
221 | 232 | String raw = "{\"name\": \"frank\", \"bean\": {\"value\": \"lots\"}}"; |
|
0 commit comments