source: events/src/test/java/actions/EndNegoTest.java@ 14

Last change on this file since 14 was 1, checked in by bart, 5 years ago

Initial Release

File size: 1.6 KB
Line 
1package actions;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.util.Arrays;
7import java.util.List;
8
9import org.junit.Test;
10
11import com.fasterxml.jackson.core.JsonProcessingException;
12import com.fasterxml.jackson.databind.ObjectMapper;
13
14import geniusweb.actions.Action;
15import geniusweb.actions.EndNegotiation;
16import geniusweb.actions.PartyId;
17import tudelft.utilities.junit.GeneralTests;
18
19public class EndNegoTest extends GeneralTests<EndNegotiation> {
20 private final ObjectMapper jackson = new ObjectMapper();
21
22 private final PartyId id = new PartyId("party1");
23 private final PartyId idb = new PartyId("party2");
24
25 private final EndNegotiation endnego = new EndNegotiation(id);
26 private final EndNegotiation endnego1 = new EndNegotiation(id);
27 private final EndNegotiation endnegob = new EndNegotiation(idb);
28
29 private final String endnegostring = "{\"endnegotiation\":{\"actor\":\"party1\"}}";
30
31 @Override
32 public List<List<EndNegotiation>> getGeneralTestData() {
33 return Arrays.asList(Arrays.asList(endnego, endnego1), Arrays.asList(endnegob));
34 }
35
36 @Override
37 public List<String> getGeneralTestStrings() {
38 return Arrays.asList("EndNegotiation\\[.*" + id + ".*\\]", "EndNegotiation\\[.*" + idb + ".*\\]");
39 }
40
41 @Test
42 public void serializeEndNegoTest() throws JsonProcessingException {
43 System.out.println(jackson.writeValueAsString(endnego));
44 assertEquals(endnegostring, jackson.writeValueAsString(endnego));
45 }
46
47 @Test
48 public void deserializeEndNegoTest() throws IOException {
49 Action act = jackson.readValue(endnegostring, Action.class);
50 assertEquals(endnego, act);
51 }
52
53}
Note: See TracBrowser for help on using the repository browser.