source: exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty/ExtendedUtilSpaceTest.java@ 52

Last change on this file since 52 was 52, checked in by ruud, 14 months ago

Fixed small issues in domaineditor.

File size: 1.8 KB
Line 
1package geniusweb.exampleparties.timedependentparty;
2
3import static org.junit.Assert.assertTrue;
4
5import java.io.IOException;
6import java.math.BigDecimal;
7import java.nio.file.Files;
8import java.nio.file.Paths;
9import java.util.Arrays;
10import java.util.Collection;
11
12import org.junit.Before;
13import org.junit.Test;
14import org.junit.runner.RunWith;
15import org.junit.runners.Parameterized;
16import org.junit.runners.Parameterized.Parameters;
17
18import com.fasterxml.jackson.databind.ObjectMapper;
19
20import geniusweb.profile.Profile;
21import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
22
23@RunWith(Parameterized.class)
24public 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}
Note: See TracBrowser for help on using the repository browser.