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

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

Fixed windows time-out.

File size: 1.9 KB
Line 
1package geniusweb.inform;
2
3import static org.junit.Assert.assertEquals;
4
5import java.io.IOException;
6import java.util.Arrays;
7import java.util.List;
8
9import org.junit.Before;
10import org.junit.Test;
11
12import com.fasterxml.jackson.core.JsonProcessingException;
13import com.fasterxml.jackson.databind.ObjectMapper;
14
15import geniusweb.actions.Action;
16import geniusweb.actions.EndNegotiation;
17import geniusweb.actions.PartyId;
18import tudelft.utilities.junit.GeneralTests;
19
20public class ActionDoneTest extends GeneralTests<ActionDone> {
21 private final ObjectMapper jackson = new ObjectMapper();
22
23 private static final PartyId id = new PartyId("party1");
24 private static final PartyId id2 = new PartyId("party2");
25
26 private final String actiondonestr = "{\"ActionDone\":{\"action\":{\"EndNegotiation\":{\"actor\":\"party1\"}}}}";
27
28 private final static Action act1 = new EndNegotiation(id);
29 private final static Action act2 = new EndNegotiation(id2);
30
31 private final static ActionDone done1 = new ActionDone(act1);
32 private final static ActionDone done1a = new ActionDone(act1);
33 private final static ActionDone done2 = new ActionDone(act2);
34
35 @Override
36 public List<List<ActionDone>> getGeneralTestData() {
37 return Arrays.asList(Arrays.asList(done1, done1a),
38 Arrays.asList(done2));
39 }
40
41 @Override
42 public List<String> getGeneralTestStrings() {
43 return Arrays.asList("ActionDone.*EndNegotiation.*party1.*",
44 "ActionDone.*EndNegotiation.*party2.*");
45 }
46
47 @Before
48 public void before() {
49
50 }
51
52 @Test
53 public void serializeAcceptTest() throws JsonProcessingException {
54 System.out.println(jackson.writeValueAsString(done1));
55 assertEquals(actiondonestr, jackson.writeValueAsString(done1));
56 }
57
58 @Test
59 public void deserializeAcceptTest() throws IOException {
60 Inform act = jackson.readValue(actiondonestr, Inform.class);
61 assertEquals(done1, act);
62 }
63
64 @Test
65 public void testGet() {
66 assertEquals(act1, done1.getAction());
67 }
68
69}
Note: See TracBrowser for help on using the repository browser.