package io.bootique.jackson;

import org.junit.Ignore;
import org.junit.Test;

import java.time.LocalTime;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class LocalTimeDeserializerIT extends DeserializerIT {

    @Test
    public void testDeserialization_Quoted() throws Exception {
        LocalTime time = LocalTime.of(9, 22, 0, 57);
        Bean1 bean1 = readValue(Bean1.class, mapper, "a: \"x\"\n" +
                "c:\n" +
                "  localTime: \"" + time + "\"");
        assertEquals(time, bean1.c.localTime);
    }

    @Ignore("SnakeYaml 1.18 thinks that XX:XX:XX is a float, not a String and chooses the wrong parser")
    @Test
    public void testDeserialization_Unquoted() throws Exception {
        LocalTime time = LocalTime.of(22, 31, 5, 829837);
        Bean1 bean1 = readValue(Bean1.class, mapper, "a: \"x\"\n" +
                "c:\n" +
                "  localTime: " + time.toString());
        assertEquals(time, bean1.c.localTime);
    }

    @Test
    public void testDeserializationAsTimestamp03Nanoseconds() throws Exception {
        Bean1 bean1 = readValue(Bean1.class, mapper, "a: \"x\"\n" +
                "c:\n" +
                "  localTime: [9,22,0,57]");
        assertEquals(LocalTime.of(9, 22, 0, 57), bean1.c.localTime);
    }

    @Test
    public void testDeserializationAsTimestamp04Nanoseconds() throws Exception {
        Bean1 bean1 = readValue(Bean1.class, mapper, "a: \"x\"\n" +
                "c:\n" +
                "  localTime: [22,31,5,829837]");
        assertEquals(LocalTime.of(22, 31, 5, 829837), bean1.c.localTime);
    }

    @Test
    public void testDeserializationAsTimestamp01() throws Exception {
        Bean1 bean1 = readValue(Bean1.class, mapper, "a: \"x\"\n" +
                "c:\n" +
                "  localTime: [15,43]");
        assertTrue(bean1 instanceof Bean1);
        assertEquals("x", bean1.a);
        assertEquals(LocalTime.of(15, 43), bean1.c.localTime);
    }

    @Test
    public void testDeserializationAsTimestamp02() throws Exception {
        Bean1 bean1 = readValue(Bean1.class, mapper, "a: \"x\"\n" +
                "c:\n" +
                "  localTime: [9,22,57]");
        assertEquals(LocalTime.of(9, 22, 57), bean1.c.localTime);
    }

}

@@ -27,33 +27,8 @@
 n;%0A%0A
-import org.junit.Ignore;%0A
 impo
@@ -46,16 +46,16 @@
 t.Test;%0A
+
 %0Aimport 
@@ -277,15 +277,8 @@
 tion
-_Quoted
 () t
@@ -433,32 +433,32 @@
        %22c:%5Cn%22 +%0A
+
                 
@@ -549,446 +549,8 @@
  %7D%0A%0A
-    @Ignore(%22SnakeYaml 1.18 thinks that XX:XX:XX is a float, not a String and chooses the wrong parser%22)%0A    @Test%0A    public void testDeserialization_Unquoted() throws Exception %7B%0A        LocalTime time = LocalTime.of(22, 31, 5, 829837);%0A        Bean1 bean1 = readValue(Bean1.class, mapper, %22a: %5C%22x%5C%22%5Cn%22 +%0A                %22c:%5Cn%22 +%0A                %22  localTime: %22 + time.toString());%0A        assertEquals(time, bean1.c.localTime);%0A    %7D%0A%0A
     

Update Jackson to 2.9.5 #189