package simpleex.json;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import simpleex.core.LatLong;

public class LatLongJsonTest extends AbstractJsonTest {

  @Before
  @Override
  public void setUp() {
    super.setUp();
  }

  @Override
  protected ObjectMapper createObjectMapper() {
    return createObjectMapper(LatLong.class, new LatLongSerializer(), new LatLongDeserializer());
  }

  @Test
  public void testLatLongSerialization() throws Exception {
    assertWriteValue("{\"latitude\":63.1,\"longitude\":12.3}", new LatLong(63.1, 12.3));
  }

  @Test
  public void testLatLongObjectDeserialization() throws Exception {
    Assert.assertEquals(new LatLong(63.1, 12.3),
        readValue("{\"latitude\":63.1,\"longitude\":12.3}", LatLong.class));
  }

  @Test
  public void testLatLongArrayDeserialization() throws Exception {
    Assert.assertEquals(new LatLong(63.1, 12.3), readValue("[ 63.1, 12.3 ]", LatLong.class));
  }
}