package geniusweb.inform; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.Arrays; import java.util.List; import org.junit.Before; 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 ActionDoneTest extends GeneralTests { private final ObjectMapper jackson = new ObjectMapper(); private static final PartyId id = new PartyId("party1"); private static final PartyId id2 = new PartyId("party2"); private final String actiondonestr = "{\"ActionDone\":{\"action\":{\"EndNegotiation\":{\"actor\":\"party1\"}}}}"; private final static Action act1 = new EndNegotiation(id); private final static Action act2 = new EndNegotiation(id2); private final static ActionDone done1 = new ActionDone(act1); private final static ActionDone done1a = new ActionDone(act1); private final static ActionDone done2 = new ActionDone(act2); @Override public List> getGeneralTestData() { return Arrays.asList(Arrays.asList(done1, done1a), Arrays.asList(done2)); } @Override public List getGeneralTestStrings() { return Arrays.asList("ActionDone.*EndNegotiation.*party1.*", "ActionDone.*EndNegotiation.*party2.*"); } @Before public void before() { } @Test public void serializeAcceptTest() throws JsonProcessingException { System.out.println(jackson.writeValueAsString(done1)); assertEquals(actiondonestr, jackson.writeValueAsString(done1)); } @Test public void deserializeAcceptTest() throws IOException { Inform act = jackson.readValue(actiondonestr, Inform.class); assertEquals(done1, act); } @Test public void testGet() { assertEquals(act1, done1.getAction()); } }