source: events/src/test/java/geniusweb/actions/LearningDoneTest.java@ 53

Last change on this file since 53 was 52, checked in by ruud, 21 months ago

Fixed small issues in domaineditor.

File size: 1.5 KB
RevLine 
[52]1package geniusweb.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 tudelft.utilities.junit.GeneralTests;
15
16public 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}
Note: See TracBrowser for help on using the repository browser.