Changeset 53 for exampleparties/timedependentparty/src/test
- Timestamp:
- 12/18/24 13:28:59 (4 days ago)
- Location:
- exampleparties/timedependentparty/src/test
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty/ExtendedUtilSpaceTest.java
r52 r53 1 1 package geniusweb.exampleparties.timedependentparty; 2 2 3 import static org.junit.Assert.assert True;3 import static org.junit.Assert.assertEquals; 4 4 5 5 import java.io.IOException; 6 import java.math.BigDecimal;7 6 import java.nio.file.Files; 8 7 import java.nio.file.Paths; … … 19 18 20 19 import geniusweb.profile.Profile; 21 import geniusweb.profile.utilityspace. LinearAdditiveUtilitySpace;20 import geniusweb.profile.utilityspace.UtilitySpace; 22 21 23 22 @RunWith(Parameterized.class) 24 23 public class ExtendedUtilSpaceTest { 25 24 private final static ObjectMapper jackson = new ObjectMapper(); 26 private final static BigDecimal SMALL = new BigDecimal("0.0001");25 private final static double SMALL = 0.0001; 27 26 28 27 @Parameters … … 31 30 { "src/test/resources/jobs/jobs1.json", 0.02 }, 32 31 { "src/test/resources/7issues/7issues1.json", 0.0055 }, 33 { "src/test/resources/9issues/9issues1.json", 0.0013 } }); 32 { "src/test/resources/9issues/9issues1.json", 0.0013 }, 33 // tolerance in computerbuy is quite small because approximation 34 // scales the space 35 { "src/test/resources/computer/computerbuy.json", 0.0016 } }); 34 36 } 35 37 36 38 private String filename; 37 private BigDecimalexpectedTolerance;39 private double expectedTolerance; 38 40 private ExtendedUtilSpace space; 39 41 40 42 public ExtendedUtilSpaceTest(String filename, double expectedTolerance) { 41 43 this.filename = filename; 42 this.expectedTolerance = BigDecimal.valueOf(expectedTolerance);44 this.expectedTolerance = expectedTolerance; 43 45 } 44 46 … … 46 48 public void before() throws IOException { 47 49 String file = new String(Files.readAllBytes(Paths.get(filename))); 48 LinearAdditiveUtilitySpace profile = (LinearAdditiveUtilitySpace) jackson49 .readValue(file,Profile.class);50 UtilitySpace profile = (UtilitySpace) jackson.readValue(file, 51 Profile.class); 50 52 space = new ExtendedUtilSpace(profile); 51 53 } … … 58 60 @Test 59 61 public void testTolerance() { 60 assert True(space.computeTolerance().subtract(expectedTolerance).abs()61 .compareTo(SMALL) < 0);62 assertEquals(expectedTolerance, space.computeTolerance().doubleValue(), 63 SMALL); 62 64 } 63 65 }
Note:
See TracChangeset
for help on using the changeset viewer.