1 | package actions;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 |
|
---|
5 | import java.io.IOException;
|
---|
6 | import java.util.Arrays;
|
---|
7 | import java.util.List;
|
---|
8 |
|
---|
9 | import org.junit.Test;
|
---|
10 |
|
---|
11 | import com.fasterxml.jackson.core.JsonProcessingException;
|
---|
12 | import com.fasterxml.jackson.databind.ObjectMapper;
|
---|
13 |
|
---|
14 | import geniusweb.actions.Action;
|
---|
15 | import geniusweb.actions.EndNegotiation;
|
---|
16 | import geniusweb.actions.PartyId;
|
---|
17 | import tudelft.utilities.junit.GeneralTests;
|
---|
18 |
|
---|
19 | public 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 | }
|
---|