source: src/test/java/negotiator/DomainImplTest.java@ 127

Last change on this file since 127 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 3.8 KB
Line 
1package negotiator;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertTrue;
7
8import org.junit.Test;
9
10import genius.core.Bid;
11import genius.core.Domain;
12import genius.core.DomainImpl;
13
14public class DomainImplTest {
15
16 private static final String DISCRETEDOMAIN = "src/test/resources/partydomain/party_domain.xml";
17 private static final String INTEGERDOMAIN = "src/test/resources/IntegerDomain/IntegerDomain.xml";
18 private static final String REALDOMAIN = "src/test/resources/2nd_hand_car/car_domain.xml";
19 private static final String NONLINEARDOMAIN = "src/test/resources/S-1NIKFRT-1/S-1NIKFRT-1-domain.xml";
20
21 private static final String[] testNames = new String[] { DISCRETEDOMAIN, INTEGERDOMAIN, NONLINEARDOMAIN,
22 REALDOMAIN };
23
24 @Test
25 public void testDefaultConstructor() {
26 Domain domain = new DomainImpl();
27
28 assertNotNull(domain.getName());
29 assertTrue(domain.getIssues().isEmpty());
30 assertNotNull(domain.getObjectivesRoot());
31 assertEquals(0, domain.getNumberOfPossibleBids());
32 assertEquals(1, domain.getObjectives().size());
33 Bid bid = domain.getRandomBid(null);
34 assertTrue(bid.getIssues().isEmpty());
35 assertTrue(bid.getValues().isEmpty());
36 }
37
38 @Test
39 public void testLoadFileDiscreteDomain() throws Exception {
40 Domain domain = new DomainImpl(DISCRETEDOMAIN);
41 assertEquals(DISCRETEDOMAIN, domain.getName());
42 assertEquals(6, domain.getIssues().size());
43 assertNotNull(domain.getObjectivesRoot());
44 assertEquals(3072, domain.getNumberOfPossibleBids());
45 // root objective adds 1 to the number of issues.
46 assertEquals(7, domain.getObjectives().size());
47 Bid bid = domain.getRandomBid(null);
48 assertEquals(6, bid.getIssues().size());
49 assertEquals(6, bid.getValues().size());
50
51 }
52
53 @Test
54 public void testLoadFileIntegerDomain() throws Exception {
55 Domain domain = new DomainImpl(INTEGERDOMAIN);
56 assertEquals(INTEGERDOMAIN, domain.getName());
57 assertEquals(2, domain.getIssues().size());
58 assertNotNull(domain.getObjectivesRoot());
59 assertEquals(121, domain.getNumberOfPossibleBids());
60 // root objective adds 1 to the number of issues.
61 assertEquals(3, domain.getObjectives().size());
62 Bid bid = domain.getRandomBid(null);
63 assertEquals(2, bid.getIssues().size());
64 assertEquals(2, bid.getValues().size());
65
66 }
67
68 @Test
69 public void testLoadFileRealDomain() throws Exception {
70 Domain domain = new DomainImpl(REALDOMAIN);
71 assertEquals(REALDOMAIN, domain.getName());
72 assertEquals(5, domain.getIssues().size());
73 assertNotNull(domain.getObjectivesRoot());
74 assertEquals(13125, domain.getNumberOfPossibleBids());
75 // root objective adds 1 to the number of issues.
76 assertEquals(6, domain.getObjectives().size());
77 Bid bid = domain.getRandomBid(null);
78 assertEquals(5, bid.getIssues().size());
79 assertEquals(5, bid.getValues().size());
80
81 }
82
83 @Test
84 public void testLoadFileNonlinearDomain() throws Exception {
85 Domain domain = new DomainImpl(NONLINEARDOMAIN);
86 assertEquals(NONLINEARDOMAIN, domain.getName());
87 assertEquals(10, domain.getIssues().size());
88 assertNotNull(domain.getObjectivesRoot());
89 assertEquals(10000000000l, domain.getNumberOfPossibleBids());
90 // root objective adds 1 to the number of issues.
91 assertEquals(11, domain.getObjectives().size());
92 Bid bid = domain.getRandomBid(null);
93 assertEquals(10, bid.getIssues().size());
94 assertEquals(10, bid.getValues().size());
95
96 }
97
98 @Test
99 public void testEquals() throws Exception {
100 DomainImpl emptydomain = new DomainImpl();
101 for (String filename : testNames) {
102 Domain domain = new DomainImpl(filename);
103 Domain domain2 = new DomainImpl(filename);
104 assertEquals(domain, domain);
105 assertEquals(domain, domain2);
106 assertFalse(domain.equals(null));
107 assertFalse(domain.equals(1));
108 assertFalse(domain.equals(emptydomain));
109 }
110
111 }
112
113}
Note: See TracBrowser for help on using the repository browser.