1 | package genius.gui.boaparties;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 |
|
---|
5 | import java.util.ArrayList;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | import org.junit.Test;
|
---|
9 |
|
---|
10 | import genius.core.boaframework.BOAparameter;
|
---|
11 | import genius.core.repository.boa.ParameterList;
|
---|
12 |
|
---|
13 | public class BoaParametersModelTest {
|
---|
14 | /**
|
---|
15 | * Check that if we provide empty parameters, we get 1 resulting empty
|
---|
16 | * parameterlist.
|
---|
17 | */
|
---|
18 | @Test
|
---|
19 | public void test() {
|
---|
20 | List<BOAparameter> params = new ArrayList<>();
|
---|
21 | List<ParameterList> res = BoaParametersModel.getSettings(params);
|
---|
22 | assertEquals(1, res.size());
|
---|
23 | assertEquals(new ParameterList(), res.get(0));
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Check that if we provide 1 parameter, we get all possible values.
|
---|
28 | */
|
---|
29 | @Test
|
---|
30 | public void test1Value() {
|
---|
31 | List<BOAparameter> params = new ArrayList<>();
|
---|
32 | params.add(new BOAparameter("v1", 0., 3., 1., "bla"));
|
---|
33 | List<ParameterList> res = BoaParametersModel.getSettings(params);
|
---|
34 | assertEquals(4, res.size());
|
---|
35 |
|
---|
36 | for (int n = 0; n < 4; n++) {
|
---|
37 | assertEquals(1, res.get(n).size());
|
---|
38 | assertEquals((Double) (double) n, res.get(n).get(0).getValue());
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Check that if we provide 2 parameters, we get all possible permutations.
|
---|
44 | */
|
---|
45 | @Test
|
---|
46 | public void test2Value() {
|
---|
47 | List<BOAparameter> params = new ArrayList<>();
|
---|
48 | params.add(new BOAparameter("v1", 0., 2., 1., "bla")); // 3
|
---|
49 | params.add(new BOAparameter("v2", 10., 11., 1., "bla")); // 2
|
---|
50 | List<ParameterList> res = BoaParametersModel.getSettings(params);
|
---|
51 | assertEquals(6, res.size());
|
---|
52 |
|
---|
53 | for (int v1 = 0; v1 < 3; v1++) {
|
---|
54 | for (int v2 = 0; v2 < 2; v2++) {
|
---|
55 | int n = v1 * 2 + v2;
|
---|
56 | assertEquals(2, res.get(n).size());
|
---|
57 | System.out.println(res.get(n));
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | }
|
---|