package com.proxerme.library.api;

import org.junit.Before;
import org.junit.Test;

import java.text.ParseException;
import java.util.Date;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/**
 * TODO: Describe class
 *
 * @author Ruben Gees
 */
public class DateAdapterTest {

    private DateAdapter adapter;

    @Before
    public void setUp() throws Exception {
        adapter = new DateAdapter();
    }

    @Test
    public void testFromJsonTimestamp() throws Exception {
        assertThat(adapter.fromJson("12345")).isEqualTo(new Date(12345 * 1000));
    }

    @Test
    public void testFromJsonIso() throws Exception {
        assertThat(adapter.fromJson("2010-01-01 23:12:10")).isEqualTo(new Date(1262383930L * 1000));
    }

    @Test
    public void testFromJsonMalformed() throws Exception {
        assertThatExceptionOfType(ParseException.class).isThrownBy(() -> adapter.fromJson("malformed"));
    }

    @Test
    public void testToJson() throws Exception {
        assertThat(adapter.toJson(new Date(123))).isEqualTo(123);
    }
}

@@ -110,16 +110,51 @@
 eption;%0A
+import java.text.SimpleDateFormat;%0A
 import j
@@ -168,16 +168,16 @@
 l.Date;%0A
-
 %0Aimport 
@@ -390,16 +390,118 @@
 Test %7B%0A%0A
+    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(%22yyyy-MM-dd hh:mm:ss%22);%0A%0A
     priv
@@ -908,46 +908,75 @@
 0%22))
-.isEqualTo(new Date(1262383930L * 1000
+%0A                .isEqualTo(DATE_FORMAT.parse(%222010-01-01 23:12:10%22
 ));%0A

Fix DateAdapter test