package 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 geniusweb.actions.Action; import geniusweb.actions.EndNegotiation; import geniusweb.actions.PartyId; import tudelft.utilities.junit.GeneralTests; public class EndNegoTest extends GeneralTests { private final ObjectMapper jackson = new ObjectMapper(); private final PartyId id = new PartyId("party1"); private final PartyId idb = new PartyId("party2"); private final EndNegotiation endnego = new EndNegotiation(id); private final EndNegotiation endnego1 = new EndNegotiation(id); private final EndNegotiation endnegob = new EndNegotiation(idb); private final String endnegostring = "{\"endnegotiation\":{\"actor\":\"party1\"}}"; @Override public List> getGeneralTestData() { return Arrays.asList(Arrays.asList(endnego, endnego1), Arrays.asList(endnegob)); } @Override public List getGeneralTestStrings() { return Arrays.asList("EndNegotiation\\[.*" + id + ".*\\]", "EndNegotiation\\[.*" + idb + ".*\\]"); } @Test public void serializeEndNegoTest() throws JsonProcessingException { System.out.println(jackson.writeValueAsString(endnego)); assertEquals(endnegostring, jackson.writeValueAsString(endnego)); } @Test public void deserializeEndNegoTest() throws IOException { Action act = jackson.readValue(endnegostring, Action.class); assertEquals(endnego, act); } }