Ignore:
Timestamp:
09/22/20 08:52:04 (4 years ago)
Author:
bart
Message:

Version 1.5.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • exampleparties/randomparty/src/test/java/geniusweb/exampleparties/randomparty/RandomPartyTest.java

    r10 r21  
    1616import java.nio.file.Files;
    1717import java.nio.file.Paths;
     18import java.util.Arrays;
     19import java.util.Collections;
    1820import java.util.LinkedList;
    1921import java.util.List;
     
    3234import geniusweb.actions.Offer;
    3335import geniusweb.actions.PartyId;
     36import geniusweb.actions.Votes;
    3437import geniusweb.bidspace.AllBidsList;
    3538import geniusweb.connection.ConnectionEnd;
     39import geniusweb.inform.ActionDone;
     40import geniusweb.inform.Finished;
     41import geniusweb.inform.Inform;
     42import geniusweb.inform.Settings;
     43import geniusweb.inform.Voting;
     44import geniusweb.inform.YourTurn;
    3645import geniusweb.issuevalue.Bid;
    3746import geniusweb.party.Capabilities;
    38 import geniusweb.party.inform.ActionDone;
    39 import geniusweb.party.inform.Finished;
    40 import geniusweb.party.inform.Inform;
    41 import geniusweb.party.inform.Settings;
    42 import geniusweb.party.inform.YourTurn;
    4347import geniusweb.profile.Profile;
    4448import geniusweb.profile.utilityspace.LinearAdditive;
     
    5357public class RandomPartyTest {
    5458
     59        private static final PartyId PARTY1 = new PartyId("party1");
    5560        private static final String SAOP = "SAOP";
    5661        private static final PartyId otherparty = new PartyId("other");
     
    6065        private RandomParty party;
    6166        private final TestConnection connection = new TestConnection();
    62         private final ProtocolRef protocol = mock(ProtocolRef.class);
     67        private final ProtocolRef protocol = new ProtocolRef(SAOP);
    6368        private final ProgressRounds progress = mock(ProgressRounds.class);
    6469        private Settings settings;
     
    7075                        IOException, URISyntaxException {
    7176                party = new RandomParty();
    72                 settings = new Settings(new PartyId("party1"),
     77                settings = new Settings(PARTY1,
    7378                                new ProfileRef(new URI("file:" + PROFILE)), protocol, progress,
    7479                                parameters);
     
    189194        }
    190195
     196        @Test
     197        public void testVoting() {
     198                party.connect(connection);
     199                party.notifyChange(settings);
     200
     201                Bid bid = findGoodBid();
     202                party.notifyChange(new Voting(Arrays.asList(bid),
     203                                Collections.singletonMap(PARTY1, 1)));
     204                assertEquals(1, connection.getActions().size());
     205                Action action = connection.getActions().get(0);
     206                assertTrue(action instanceof Votes);
     207                assertEquals(1, ((Votes) action).getVotes().size());
     208                assertEquals(bid, ((Votes) action).getVotes().get(0).getBid());
     209        }
     210
    191211}
    192212
Note: See TracChangeset for help on using the changeset viewer.