[35] | 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 LearningDoneTest extends GeneralTests<LearningDone> {
|
---|
| 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 LearningDone done = new LearningDone(id);
|
---|
| 23 | private final LearningDone done1 = new LearningDone(id);
|
---|
| 24 | private final LearningDone done2 = new LearningDone(idb);
|
---|
| 25 |
|
---|
| 26 | private final String endnegostring = "{\"LearningDone\":{\"actor\":\"party1\"}}";
|
---|
| 27 |
|
---|
| 28 | @Override
|
---|
| 29 | public List<List<LearningDone>> getGeneralTestData() {
|
---|
| 30 | return Arrays.asList(Arrays.asList(done, done1),
|
---|
| 31 | Arrays.asList(done2));
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | @Override
|
---|
| 35 | public List<String> getGeneralTestStrings() {
|
---|
| 36 | return Arrays.asList("LearningDone\\[.*" + id + ".*\\]",
|
---|
| 37 | "LearningDone\\[.*" + idb + ".*\\]");
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | @Test
|
---|
| 41 | public void serializeEndNegoTest() throws JsonProcessingException {
|
---|
| 42 | System.out.println(jackson.writeValueAsString(done));
|
---|
| 43 | assertEquals(endnegostring, jackson.writeValueAsString(done));
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | @Test
|
---|
| 47 | public void deserializeEndNegoTest() throws IOException {
|
---|
| 48 | Action act = jackson.readValue(endnegostring, Action.class);
|
---|
| 49 | assertEquals(done, act);
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | }
|
---|