package geniusweb.actions; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.Arrays; 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 LearningDoneTest extends GeneralTests { private final ObjectMapper jackson = new ObjectMapper(); private final PartyId id = new PartyId("party1"); private final PartyId idb = new PartyId("party2"); private final LearningDone done = new LearningDone(id); private final LearningDone done1 = new LearningDone(id); private final LearningDone done2 = new LearningDone(idb); private final String endnegostring = "{\"LearningDone\":{\"actor\":\"party1\"}}"; @Override public List> getGeneralTestData() { return Arrays.asList(Arrays.asList(done, done1), Arrays.asList(done2)); } @Override public List getGeneralTestStrings() { return Arrays.asList("LearningDone\\[.*" + id + ".*\\]", "LearningDone\\[.*" + idb + ".*\\]"); } @Test public void serializeEndNegoTest() throws JsonProcessingException { System.out.println(jackson.writeValueAsString(done)); assertEquals(endnegostring, jackson.writeValueAsString(done)); } @Test public void deserializeEndNegoTest() throws IOException { Action act = jackson.readValue(endnegostring, Action.class); assertEquals(done, act); } }