package com.bbn.bue.common.serialization.jackson;

import com.bbn.bue.common.evaluation.FMeasureCounts;

import com.google.common.collect.ImmutableMap;

import junit.framework.TestCase;

import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.Map;

public class TestSerialization extends TestCase {

  private final JacksonSerializer serializer = JacksonSerializer.forNormalJSON();

  @Test
  public void testFMeasureCounts() throws IOException {
    final Map<String, FMeasureCounts> foo = ImmutableMap.of("Hello",
        FMeasureCounts.from(1, 2, 3));
    final File tmp = File.createTempFile("foo", "bar");
    tmp.deleteOnExit();

    assertEquals(foo, JacksonTestUtils.roundTripThroughSerializer(foo, serializer));
  }

}

@@ -753,10 +753,345 @@
 );%0A  %7D%0A%0A
+  @Test%0A  public void testSerializingFromString() throws IOException %7B%0A    final Map%3CString, FMeasureCounts%3E foo = ImmutableMap.of(%22Hello%22,%0A        FMeasureCounts.from(1, 2, 3));%0A    final String serialized = serializer.writeValueAsString(foo);%0A    assertEquals(foo, serializer.deserializeFromString(serialized, foo.getClass()));%0A  %7D%0A%0A
 %7D%0A

add method to test serialization to and from strings