[52] | 1 | package geniusweb.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 tudelft.utilities.junit.GeneralTests;
|
---|
| 15 |
|
---|
| 16 | public class EndNegoTest extends GeneralTests<EndNegotiation> {
|
---|
| 17 | private final ObjectMapper jackson = new ObjectMapper();
|
---|
| 18 |
|
---|
| 19 | private final PartyId id = new PartyId("party1");
|
---|
| 20 | private final PartyId idb = new PartyId("party2");
|
---|
| 21 |
|
---|
| 22 | private final EndNegotiation endnego = new EndNegotiation(id);
|
---|
| 23 | private final EndNegotiation endnego1 = new EndNegotiation(id);
|
---|
| 24 | private final EndNegotiation endnegob = new EndNegotiation(idb);
|
---|
| 25 |
|
---|
| 26 | private final String endnegostring = "{\"EndNegotiation\":{\"actor\":\"party1\"}}";
|
---|
| 27 |
|
---|
| 28 | @Override
|
---|
| 29 | public List<List<EndNegotiation>> getGeneralTestData() {
|
---|
| 30 | return Arrays.asList(Arrays.asList(endnego, endnego1),
|
---|
| 31 | Arrays.asList(endnegob));
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | @Override
|
---|
| 35 | public List<String> getGeneralTestStrings() {
|
---|
| 36 | return Arrays.asList("EndNegotiation\\[.*" + id + ".*\\]",
|
---|
| 37 | "EndNegotiation\\[.*" + idb + ".*\\]");
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | @Test
|
---|
| 41 | public void serializeEndNegoTest() throws JsonProcessingException {
|
---|
| 42 | System.out.println(jackson.writeValueAsString(endnego));
|
---|
| 43 | assertEquals(endnegostring, jackson.writeValueAsString(endnego));
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | @Test
|
---|
| 47 | public void deserializeEndNegoTest() throws IOException {
|
---|
| 48 | Action act = jackson.readValue(endnegostring, Action.class);
|
---|
| 49 | assertEquals(endnego, act);
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | }
|
---|