package geniusweb.issuevalue; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import org.junit.Test; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import tudelft.utilities.junit.GeneralTests; public class DiscreteValueTest extends GeneralTests { private final DiscreteValue value = new DiscreteValue("a"); private final DiscreteValue value1 = new DiscreteValue("a"); private final DiscreteValue valueb = new DiscreteValue("b"); private final String serialized = "\"a\""; private static final ObjectMapper jackson = new ObjectMapper(); @Test public void testSerialize() throws JsonProcessingException { assertEquals(serialized, jackson.writeValueAsString(value)); } @Test public void testDeserialize() throws IOException { assertEquals(value, jackson.readValue(serialized, DiscreteValue.class)); } @Test public void testDeserializeFromValue() throws IOException { assertEquals(value, jackson.readValue(serialized, Value.class)); } @Override public List> getGeneralTestData() { List> testlist = new LinkedList<>(); testlist.add(Arrays.asList(value, value1)); testlist.add(Arrays.asList(valueb)); return testlist; } @Override public List getGeneralTestStrings() { return Arrays.asList(serialized, "\"b\""); } }