source: protocol/src/test/java/geniusweb/protocol/session/TeamInfoTest.java@ 52

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

Fixed small issues in domaineditor.

File size: 2.1 KB
Line 
1package geniusweb.protocol.session;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.net.URISyntaxException;
7import java.util.Arrays;
8import java.util.Collections;
9import java.util.List;
10
11import org.junit.Before;
12import org.junit.Test;
13
14import com.fasterxml.jackson.core.JsonProcessingException;
15import com.fasterxml.jackson.databind.ObjectMapper;
16
17import geniusweb.references.Parameters;
18import geniusweb.references.PartyRef;
19import geniusweb.references.PartyWithParameters;
20import geniusweb.references.ProfileRef;
21import tudelft.utilities.junit.GeneralTests;
22
23public class TeamInfoTest extends GeneralTests<TeamInfo> {
24
25 private TeamInfo team1 = new TeamInfo(Collections.emptyList());
26 private TeamInfo team1a = new TeamInfo(Collections.emptyList());
27 private PartyRef partyref;
28 private Parameters parameters = new Parameters();;
29 private ProfileRef profileref;
30 private TeamInfo team2, team2a;
31 private String asString1 = "{\"TeamInfo\":{\"parties\":[{\"party\":{\"partyref\":\"party1\",\"parameters\":{}},\"profile\":\"profile1\"}]}}";
32
33 @Before
34 public void before() throws URISyntaxException {
35 partyref = new PartyRef("party1");
36 profileref = new ProfileRef("profile1");
37 team2 = new TeamInfo(new PartyWithParameters(partyref, parameters),
38 profileref);
39 team2a = new TeamInfo(new PartyWithParameters(partyref, parameters),
40 profileref);
41
42 }
43
44 @Override
45 public List<List<TeamInfo>> getGeneralTestData() {
46 return Arrays.asList(Arrays.asList(team1, team1a),
47 Arrays.asList(team2, team2a));
48 }
49
50 @Override
51 public List<String> getGeneralTestStrings() {
52 return Arrays.asList("TeamInfo.\\[\\].",
53 "TeamInfo.\\[PartyWithProfile.*party1.*profile1.*\\].*");
54 }
55
56 @Test
57 public void testSerialize() throws JsonProcessingException {
58
59 ObjectMapper jackson = new ObjectMapper();
60 System.out.println(jackson.writeValueAsString(team2));
61 assertEquals(asString1, jackson.writeValueAsString(team2));
62
63 }
64
65 @Test
66 public void testDeserialize() throws IOException {
67
68 ObjectMapper jackson = new ObjectMapper();
69 TeamInfo read = jackson.readValue(asString1, TeamInfo.class);
70 assertEquals(team2, read);
71 }
72
73}
Note: See TracBrowser for help on using the repository browser.