source: events/src/test/java/geniusweb/inform/YourTurnTest.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.6 KB
Line 
1package geniusweb.inform;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.net.URISyntaxException;
7import java.util.Arrays;
8import java.util.List;
9
10import org.junit.Before;
11import org.junit.Test;
12
13import com.fasterxml.jackson.core.JsonParseException;
14import com.fasterxml.jackson.core.JsonProcessingException;
15import com.fasterxml.jackson.databind.JsonMappingException;
16import com.fasterxml.jackson.databind.ObjectMapper;
17
18import tudelft.utilities.junit.GeneralTests;
19
20public class YourTurnTest extends GeneralTests<YourTurn> {
21
22 private YourTurn yourturn1, yourturn1b;
23
24 private String asJson = "{\"YourTurn\":{}}";
25
26 private YourTurn yourturnb;
27
28 @Before
29 public void before() throws URISyntaxException {
30
31 yourturn1 = new YourTurn();
32 yourturn1b = new YourTurn();
33 yourturnb = new YourTurn() {
34 @Override
35 public int hashCode() {
36 return 2;
37 }
38 };
39 }
40
41 @Override
42 public List<List<YourTurn>> getGeneralTestData() {
43 return Arrays.asList(Arrays.asList(yourturn1, yourturn1b),
44 Arrays.asList(yourturnb));
45 }
46
47 @Override
48 public List<String> getGeneralTestStrings() {
49 return Arrays.asList("YourTurn*", "YourTurn*");
50 }
51
52 @Test
53 public void testSerialize() throws JsonProcessingException {
54 ObjectMapper jackson = new ObjectMapper();
55
56 String json = jackson.writeValueAsString(yourturn1);
57 System.out.println(json);
58 assertEquals(asJson, json);
59 }
60
61 @Test
62 public void testDeserialize()
63 throws JsonParseException, JsonMappingException, IOException {
64 ObjectMapper jackson = new ObjectMapper();
65 YourTurn p = (YourTurn) jackson.readValue(asJson, Inform.class);
66 System.out.println(p);
67 assertEquals(yourturn1, p);
68 }
69
70}
Note: See TracBrowser for help on using the repository browser.