Changeset 25 for exampleparties/timedependentparty/src/test
- Timestamp:
- 10/08/20 10:17:25 (4 years ago)
- Location:
- exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty/TimeDependentPartyTest.java
r24 r25 17 17 import java.nio.file.Files; 18 18 import java.nio.file.Paths; 19 import java.util.LinkedList;20 import java.util.List;21 19 import java.util.logging.Level; 22 20 … … 29 27 30 28 import geniusweb.actions.Accept; 31 import geniusweb.actions.Action;32 29 import geniusweb.actions.EndNegotiation; 33 30 import geniusweb.actions.Offer; 34 31 import geniusweb.actions.PartyId; 35 32 import geniusweb.bidspace.AllBidsList; 36 import geniusweb.connection.ConnectionEnd;37 33 import geniusweb.inform.ActionDone; 38 34 import geniusweb.inform.Agreements; 39 35 import geniusweb.inform.Finished; 40 import geniusweb.inform.Inform;41 36 import geniusweb.inform.Settings; 42 37 import geniusweb.inform.YourTurn; … … 49 44 import geniusweb.references.ProfileRef; 50 45 import geniusweb.references.ProtocolRef; 51 import geniusweb.references.Reference;52 import tudelft.utilities.listener.DefaultListenable;53 46 import tudelft.utilities.logging.Reporter; 54 47 … … 62 55 private TimeDependentParty party; 63 56 private TestConnection connection = new TestConnection(); 64 private ProtocolRef protocol = mock(ProtocolRef.class);57 private ProtocolRef protocol = new ProtocolRef("SAOP"); 65 58 private ProgressRounds progress = mock(ProgressRounds.class); 66 59 private Parameters parameters = new Parameters(); … … 113 106 public void testInformConnection() { 114 107 party.connect(connection); 115 // agentshould not start acting just after an inform108 // Party should not start acting just after an inform 116 109 assertEquals(0, connection.getActions().size()); 117 110 } … … 143 136 144 137 @Test 145 public void test AgentHasFirstTurn() {138 public void testPartyHasFirstTurn() { 146 139 party.connect(connection); 147 140 party.notifyChange(settings); … … 153 146 154 147 @Test 155 public void test AgentAccepts() {148 public void testPartyAccepts() { 156 149 party.connect(connection); 157 150 party.notifyChange(settings); … … 166 159 167 160 @Test 168 public void test AgentLogsFinal() {161 public void testPartyLogsFinal() { 169 162 // this log output is optional, this is to show how to check log 170 163 Reporter reporter = mock(Reporter.class); … … 193 186 194 187 @Test 195 public void test AgentsUpdatesProgress() {188 public void testPartysUpdatesProgress() { 196 189 party.connect(connection); 197 190 party.notifyChange(settings); … … 204 197 public void testGetCapabilities() { 205 198 assertTrue(party.getCapabilities().getBehaviours().contains(SAOP)); 199 } 200 201 @Test 202 public void testUtilityTarget() { 203 TimeDependentParty tdp = new TimeDependentParty(); 204 BigDecimal N02 = new BigDecimal("0.2"); 205 BigDecimal N043 = new BigDecimal("0.42521212"); 206 BigDecimal goal = tdp.getUtilityGoal(0.1, 1.2, N02, N043); 207 assertTrue(goal.compareTo(N02) > 0); 208 assertTrue(goal.compareTo(N043) < 0); 206 209 } 207 210 … … 220 223 221 224 } 222 223 /**224 * A "real" connection object, because the party is going to subscribe etc, and225 * without a real connection we would have to do a lot of mocks that would make226 * the test very hard to read.227 *228 */229 class TestConnection extends DefaultListenable<Inform>230 implements ConnectionEnd<Inform, Action> {231 private List<Action> actions = new LinkedList<>();232 233 @Override234 public void send(Action action) throws IOException {235 actions.add(action);236 }237 238 @Override239 public Reference getReference() {240 return null;241 }242 243 @Override244 public URI getRemoteURI() {245 return null;246 }247 248 @Override249 public void close() {250 251 }252 253 @Override254 public Error getError() {255 return null;256 }257 258 public List<Action> getActions() {259 return actions;260 }261 262 }
Note:
See TracChangeset
for help on using the changeset viewer.