source: events/src/test/java/geniusweb/inform/FinishedTest.java@ 38

Last change on this file since 38 was 35, checked in by bart, 3 years ago

Fixed windows time-out.

File size: 2.2 KB
Line 
1package geniusweb.inform;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.util.Arrays;
7import java.util.Collections;
8import java.util.List;
9
10import org.junit.Before;
11import org.junit.Test;
12
13import com.fasterxml.jackson.core.JsonProcessingException;
14import com.fasterxml.jackson.databind.ObjectMapper;
15
16import geniusweb.actions.PartyId;
17import geniusweb.issuevalue.Bid;
18import geniusweb.issuevalue.DiscreteValue;
19import geniusweb.issuevalue.Value;
20import tudelft.utilities.junit.GeneralTests;
21
22public class FinishedTest extends GeneralTests<Finished> {
23 private final ObjectMapper jackson = new ObjectMapper();
24
25 private static final PartyId id = new PartyId("party1");
26 private static final PartyId id2 = new PartyId("party2");
27 private final static Value VALUE1 = new DiscreteValue("value1");
28 private static Bid bid = new Bid(
29 Collections.singletonMap("issue1", VALUE1));
30
31 private final String finishedstring = "{\"Finished\":{\"agreements\":{\"party1\":{\"issuevalues\":{\"issue1\":\"value1\"}}}}}";
32
33 private final static Agreements agrees1 = new Agreements(
34 Collections.singletonMap(id, bid));
35 private final static Agreements agrees2 = new Agreements(
36 Collections.singletonMap(id2, bid));
37
38 private final static Finished finished1 = new Finished(agrees1);
39 private final static Finished finished1a = new Finished(agrees1);
40 private final static Finished finished2 = new Finished(agrees2);
41
42 @Override
43 public List<List<Finished>> getGeneralTestData() {
44 return Arrays.asList(Arrays.asList(finished1, finished1a),
45 Arrays.asList(finished2));
46 }
47
48 @Override
49 public List<String> getGeneralTestStrings() {
50 return Arrays.asList("Finished.*party1.*Bid.*",
51 "Finished.*party2.*Bid.*");
52 }
53
54 @Before
55 public void before() {
56
57 }
58
59 @Test
60 public void serializeAcceptTest() throws JsonProcessingException {
61 System.out.println(jackson.writeValueAsString(finished1));
62 assertEquals(finishedstring, jackson.writeValueAsString(finished1));
63 }
64
65 @Test
66 public void deserializeAcceptTest() throws IOException {
67 Inform act = jackson.readValue(finishedstring, Inform.class);
68 assertEquals(finished1, act);
69 }
70
71 @Test(expected = NullPointerException.class)
72 public void testNull() {
73 new Finished(null);
74 }
75
76}
Note: See TracBrowser for help on using the repository browser.