From 5eac1b799a24d4d1ec6802f728d08b01cb8a8af7 Mon Sep 17 00:00:00 2001 From: Felipe Lima Date: Tue, 11 Jun 2024 09:56:58 -0700 Subject: [PATCH] move more android tests --- src/test/java/cloud/eppo/UtilsTest.java | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/java/cloud/eppo/UtilsTest.java diff --git a/src/test/java/cloud/eppo/UtilsTest.java b/src/test/java/cloud/eppo/UtilsTest.java new file mode 100644 index 0000000..ab0d019 --- /dev/null +++ b/src/test/java/cloud/eppo/UtilsTest.java @@ -0,0 +1,27 @@ +package cloud.eppo; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +import java.util.Date; + +import static cloud.eppo.Utils.parseUtcISODateElement; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +public class UtilsTest { + @Test + public void testParseUtcISODateElement() throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode jsonNode = mapper.readTree("\"2024-05-01T16:13:26.651Z\""); + Date parsedDate = parseUtcISODateElement(jsonNode); + Date expectedDate = new Date(1714580006651L); + assertEquals(expectedDate, parsedDate); + jsonNode = mapper.readTree("null"); + parsedDate = parseUtcISODateElement(jsonNode); + assertNull(parsedDate); + assertNull(parseUtcISODateElement(null)); + } +}