source: java2python/src/test/java/testcode/actions/ActionsTest.java@ 383

Last change on this file since 383 was 381, checked in by wouter, 2 years ago

#116 various fixes, to support multi-file zips

File size: 1.7 KB
Line 
1package testcode.actions;
2
3/**
4 * Derived from AcceptTest in GeniusWeb.
5 */
6import static org.junit.Assert.assertEquals;
7
8import java.io.IOException;
9
10import org.junit.Before;
11import org.junit.Test;
12
13import com.fasterxml.jackson.core.JsonProcessingException;
14import com.fasterxml.jackson.databind.ObjectMapper;
15
16public class ActionsTest {
17 private final ObjectMapper jackson = new ObjectMapper();
18
19 private static final PartyId id = new PartyId("party1");
20 private static final PartyId id2 = new PartyId("party2");
21 private static Bid bid;
22 private static Bid bidb;
23 // issue 2 is NUMBER and thus serializes with leading '='
24 private final String acceptstring = "{\"Accept\":{\"actor\":\"party1\",\"bid\":\"issuevalues\"}}";
25
26 private static Accept accept, accept1, accept2, acceptb;
27
28 @Before
29 public void before() {
30 bid = new Bid("issuevalues");
31 accept = new Accept(id, bid);
32 accept1 = new Accept(id, bid);
33
34 accept2 = new Accept(id2, bid);
35
36 // values swapped, so different issuevalues.
37 bidb = new Bid("issuevaluesb");
38 acceptb = new Accept(id, bidb);
39
40 }
41
42 @Test
43 public void serializeAcceptTest() throws JsonProcessingException {
44 System.out.println("serializeAcceptTest");
45 System.out.println(jackson.writeValueAsString(accept));
46 assertEquals(acceptstring, jackson.writeValueAsString(accept));
47 }
48
49 @Test
50 public void deserializeAcceptTest() throws IOException {
51 System.out.println("deserializeAcceptTest");
52 Action act = jackson.readValue(acceptstring, Action.class);
53 System.out.println(act);
54 assertEquals(accept, act);
55 }
56
57 public static void main(String[] args) throws IOException {
58 ActionsTest a = new ActionsTest();
59 a.before();
60 a.serializeAcceptTest();
61 a = new ActionsTest();
62 a.before();
63 a.deserializeAcceptTest();
64 }
65}
Note: See TracBrowser for help on using the repository browser.