Ignore:
Timestamp:
10/08/20 10:17:25 (4 years ago)
Author:
bart
Message:

MOPAC support for timedependentparty, boulware, conceder, hardliner, linear

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  
    1717import java.nio.file.Files;
    1818import java.nio.file.Paths;
    19 import java.util.LinkedList;
    20 import java.util.List;
    2119import java.util.logging.Level;
    2220
     
    2927
    3028import geniusweb.actions.Accept;
    31 import geniusweb.actions.Action;
    3229import geniusweb.actions.EndNegotiation;
    3330import geniusweb.actions.Offer;
    3431import geniusweb.actions.PartyId;
    3532import geniusweb.bidspace.AllBidsList;
    36 import geniusweb.connection.ConnectionEnd;
    3733import geniusweb.inform.ActionDone;
    3834import geniusweb.inform.Agreements;
    3935import geniusweb.inform.Finished;
    40 import geniusweb.inform.Inform;
    4136import geniusweb.inform.Settings;
    4237import geniusweb.inform.YourTurn;
     
    4944import geniusweb.references.ProfileRef;
    5045import geniusweb.references.ProtocolRef;
    51 import geniusweb.references.Reference;
    52 import tudelft.utilities.listener.DefaultListenable;
    5346import tudelft.utilities.logging.Reporter;
    5447
     
    6255        private TimeDependentParty party;
    6356        private TestConnection connection = new TestConnection();
    64         private ProtocolRef protocol = mock(ProtocolRef.class);
     57        private ProtocolRef protocol = new ProtocolRef("SAOP");
    6558        private ProgressRounds progress = mock(ProgressRounds.class);
    6659        private Parameters parameters = new Parameters();
     
    113106        public void testInformConnection() {
    114107                party.connect(connection);
    115                 // agent should not start acting just after an inform
     108                // Party should not start acting just after an inform
    116109                assertEquals(0, connection.getActions().size());
    117110        }
     
    143136
    144137        @Test
    145         public void testAgentHasFirstTurn() {
     138        public void testPartyHasFirstTurn() {
    146139                party.connect(connection);
    147140                party.notifyChange(settings);
     
    153146
    154147        @Test
    155         public void testAgentAccepts() {
     148        public void testPartyAccepts() {
    156149                party.connect(connection);
    157150                party.notifyChange(settings);
     
    166159
    167160        @Test
    168         public void testAgentLogsFinal() {
     161        public void testPartyLogsFinal() {
    169162                // this log output is optional, this is to show how to check log
    170163                Reporter reporter = mock(Reporter.class);
     
    193186
    194187        @Test
    195         public void testAgentsUpdatesProgress() {
     188        public void testPartysUpdatesProgress() {
    196189                party.connect(connection);
    197190                party.notifyChange(settings);
     
    204197        public void testGetCapabilities() {
    205198                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);
    206209        }
    207210
     
    220223
    221224}
    222 
    223 /**
    224  * A "real" connection object, because the party is going to subscribe etc, and
    225  * without a real connection we would have to do a lot of mocks that would make
    226  * 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         @Override
    234         public void send(Action action) throws IOException {
    235                 actions.add(action);
    236         }
    237 
    238         @Override
    239         public Reference getReference() {
    240                 return null;
    241         }
    242 
    243         @Override
    244         public URI getRemoteURI() {
    245                 return null;
    246         }
    247 
    248         @Override
    249         public void close() {
    250 
    251         }
    252 
    253         @Override
    254         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.