1 | package geniusweb.exampleparties.timedependentparty;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertTrue;
|
---|
4 |
|
---|
5 | import java.io.IOException;
|
---|
6 | import java.math.BigDecimal;
|
---|
7 | import java.nio.file.Files;
|
---|
8 | import java.nio.file.Paths;
|
---|
9 | import java.util.Arrays;
|
---|
10 | import java.util.Collection;
|
---|
11 |
|
---|
12 | import org.junit.Before;
|
---|
13 | import org.junit.Test;
|
---|
14 | import org.junit.runner.RunWith;
|
---|
15 | import org.junit.runners.Parameterized;
|
---|
16 | import org.junit.runners.Parameterized.Parameters;
|
---|
17 |
|
---|
18 | import com.fasterxml.jackson.databind.ObjectMapper;
|
---|
19 |
|
---|
20 | import geniusweb.profile.Profile;
|
---|
21 | import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
|
---|
22 |
|
---|
23 | @RunWith(Parameterized.class)
|
---|
24 | public class ExtendedUtilSpaceTest {
|
---|
25 | private final static ObjectMapper jackson = new ObjectMapper();
|
---|
26 | private final static BigDecimal SMALL = new BigDecimal("0.0001");
|
---|
27 |
|
---|
28 | @Parameters
|
---|
29 | public static Collection<Object[]> data() {
|
---|
30 | return Arrays.asList(new Object[][] {
|
---|
31 | { "src/test/resources/jobs/jobs1.json", 0.02 },
|
---|
32 | { "src/test/resources/7issues/7issues1.json", 0.0055 },
|
---|
33 | { "src/test/resources/9issues/9issues1.json", 0.0013 } });
|
---|
34 | }
|
---|
35 |
|
---|
36 | private String filename;
|
---|
37 | private BigDecimal expectedTolerance;
|
---|
38 | private ExtendedUtilSpace space;
|
---|
39 |
|
---|
40 | public ExtendedUtilSpaceTest(String filename, double expectedTolerance) {
|
---|
41 | this.filename = filename;
|
---|
42 | this.expectedTolerance = BigDecimal.valueOf(expectedTolerance);
|
---|
43 | }
|
---|
44 |
|
---|
45 | @Before
|
---|
46 | public void before() throws IOException {
|
---|
47 | String file = new String(Files.readAllBytes(Paths.get(filename)));
|
---|
48 | LinearAdditiveUtilitySpace profile = (LinearAdditiveUtilitySpace) jackson
|
---|
49 | .readValue(file, Profile.class);
|
---|
50 | space = new ExtendedUtilSpace(profile);
|
---|
51 | }
|
---|
52 |
|
---|
53 | @Test
|
---|
54 | public void smokeTest() {
|
---|
55 |
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Test
|
---|
59 | public void testTolerance() {
|
---|
60 | assertTrue(space.computeTolerance().subtract(expectedTolerance).abs()
|
---|
61 | .compareTo(SMALL) < 0);
|
---|
62 | }
|
---|
63 | }
|
---|