1 | package tudelft.utilities.j2p;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.nio.file.Paths;
|
---|
6 | import java.util.Arrays;
|
---|
7 |
|
---|
8 | import org.junit.Test;
|
---|
9 |
|
---|
10 | import tudelft.utilities.j2p.t.TranslationException;
|
---|
11 | import tudelft.utilities.logging.Reporter;
|
---|
12 | import tudelft.utilities.logging.SavingReporter;
|
---|
13 | import tudelft.utilities.pyrunner.PythonError;
|
---|
14 | import tudelft.utilities.pyrunner.PythonVenv;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * The EndNegotiation.java file is not compiling as intended because Caused by:
|
---|
18 | * tudelft.utilities.j2p.t.TranslationException: parameter 'id' must equal the
|
---|
19 | * property name but found 'actor' at @JsonProperty("actor") PartyId id (line
|
---|
20 | * 13,col 24)-(line 13,col 56) *
|
---|
21 | */
|
---|
22 | public class EndNegoTest {
|
---|
23 |
|
---|
24 | @Test
|
---|
25 | public void test()
|
---|
26 | throws IOException, ClassNotFoundException, TranslationException {
|
---|
27 | PyProgram program = PyProgram.fromDirectories(
|
---|
28 | Arrays.asList((Paths.get("src/test/endnego"))));
|
---|
29 | System.out.println(program);
|
---|
30 | }
|
---|
31 |
|
---|
32 | // expecting error: constructor id should be "actor".
|
---|
33 | @Test(expected = TranslationException.class)
|
---|
34 | public void test2()
|
---|
35 | throws IOException, ClassNotFoundException, TranslationException {
|
---|
36 | PyProgram program = PyProgram.fromDirectories(
|
---|
37 | Arrays.asList((Paths.get("src/test/endnego2"))));
|
---|
38 | System.out.println(program);
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Test
|
---|
42 | public void test3() throws IOException, ClassNotFoundException,
|
---|
43 | TranslationException, InterruptedException, PythonError {
|
---|
44 | PyProgram program = PyProgram.fromDirectories(
|
---|
45 | Arrays.asList((Paths.get("src/test/endnego3"))));
|
---|
46 | System.out.println(program);
|
---|
47 |
|
---|
48 | Reporter reporter = new SavingReporter("test");
|
---|
49 | File zipfile = program.getZip();
|
---|
50 | PythonVenv venv = new PythonVenv(zipfile, reporter);
|
---|
51 | String res = venv.call(Arrays.asList("-m", "testcode.EndNegotiation3"),
|
---|
52 | 10000);
|
---|
53 |
|
---|
54 | }
|
---|
55 | } |
---|