Changeset 21 for protocol/src


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

Version 1.5.

Location:
protocol/src
Files:
28 added
28 edited

Legend:

Unmodified
Added
Removed
  • protocol/src/main/java/geniusweb/protocol/NegoProtocol.java

    r9 r21  
    88
    99import geniusweb.connection.ConnectionFactory;
     10import geniusweb.deadline.Deadline;
    1011import geniusweb.events.CurrentState;
    1112import geniusweb.events.ProtocolEvent;
     
    2627 * {@link #getDescription()}. A protocol reports the progress through its
    2728 * {@link Listenable} interface. <br>
    28  * <p>
     29 * <h2>General information</h2>
    2930 *
    3031 * A protocol is mutable because the incoming connections cause state changes.
     
    3334 * Because a protocol contains an internal state, it can be used only once.
    3435 * <p>
    35  * The protocol also needs to keep an eye on the deadline and take appropriate
    36  * actions when the deadline is reached. <br>
    37  * <p>
    38  * A protocol should emit a {@link SessionEnded} or {@link TournamentEnded}
    39  * event when it is finished.
    4036 * <p>
    4137 * The protocol can emit a {@link CurrentState} event at any time. It should do
     
    4844 * {@link #start(SessionSettings, ConnectionFactory)}.
    4945 *
     46 * <h2>Ensure time deadline</h2>
     47 *
     48 * The protocol also needs to keep an eye on the deadline and take appropriate
     49 * actions when the deadline is reached. <br>
     50 * A protocol should emit a {@link SessionEnded} or {@link TournamentEnded}
     51 * event when it is finished.
     52 * <p>
     53 * All protocol implementations must ensure that the deadline is kept and that
     54 * the session ends at the agreed time {@link Deadline#getDuration()}. This is
     55 * to ensure that the negotiation ends and resources are freed up at or before
     56 * some known time.
     57 *
    5058 */
    5159@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
    5260@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
    53 @JsonSubTypes({ @Type(value = SessionProtocol.class), @Type(value = TournamentProtocol.class) })
     61@JsonSubTypes({ @Type(value = SessionProtocol.class),
     62                @Type(value = TournamentProtocol.class) })
    5463
    5564public interface NegoProtocol extends Listenable<ProtocolEvent> {
     
    6473         * <p>
    6574         *
    66          * All errors are to be handled through {@link SessionState#getError()} except
    67          * for plain {@link IllegalArgumentException}s. <br>
    68          * The protocol usually uses the incoming connections to keep running. It does
    69          * not need to run in a separate thread or so.
     75         * All errors are to be handled through {@link SessionState#getError()}
     76         * except for plain {@link IllegalArgumentException}s. <br>
     77         * The protocol usually uses the incoming connections to keep running. It
     78         * does not need to run in a separate thread or so.
    7079         *
    7180         *
    72          * @param connectionfactory the {@link ProtocolToPartyConnFactory} that allows
    73          *                          the protocol to connect with the {@link Reference}s
    74          *                          in the settings
     81         * @param connectionfactory the {@link ProtocolToPartyConnFactory} that
     82         *                          allows the protocol to connect with the
     83         *                          {@link Reference}s in the settings
    7584         */
    7685        void start(ProtocolToPartyConnFactory connectionfactory);
     
    7887        /**
    7988         *
    80          * @return a complete description of how this protocol behaves. Presented to the
    81          *         end users who should know negotiation basics but not all technical
    82          *         terms.
     89         * @return a complete description of how this protocol behaves. Presented to
     90         *         the end users who should know negotiation basics but not all
     91         *         technical terms.
    8392         */
    8493        String getDescription();
     
    8695        /**
    8796         * @return current state: the results of all sessions run so far and how to
    88          *         continue from that point. Changes over time as the session proceeds.
    89          *         Errors are also stored in the state.
     97         *         continue from that point. Changes over time as the session
     98         *         proceeds. Errors are also stored in the state.
    9099         */
    91100        NegoState getState();
     
    98107
    99108        /**
    100          * Add a party after the protocol has started. Only some protocols can handle
    101          * this call. Usual protocols take the settings with their constructor.
     109         * Add a party after the protocol has started. Only some protocols can
     110         * handle this call. Usual protocols take the settings with their
     111         * constructor.
    102112         *
    103113         * @param party the {@link PartyWithProfile} to be added.
  • protocol/src/main/java/geniusweb/protocol/NegoState.java

    r1 r21  
    55import com.fasterxml.jackson.annotation.JsonSubTypes;
    66import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
     7import com.fasterxml.jackson.annotation.JsonTypeInfo;
    78
    89import geniusweb.protocol.session.SessionState;
    910import geniusweb.protocol.tournament.TournamentState;
    1011
    11 import com.fasterxml.jackson.annotation.JsonTypeInfo;
    12 
    1312/**
    14  * The current state of the tournament. Must be serializabl;e so that it can be
    15  * restarted if a crash occurs.
     13 * The current state of the session/tournament. Must be serializabl;e so that it
     14 * can be restarted if a crash occurs.
    1615 */
    1716@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE)
     
    3635        boolean isFinal(long currentTimeMs);
    3736
    38         /**
    39          *
    40          * @return a fatal error occured during the tournament. returns null if no
    41          *         errors occured.
    42          */
    43         ProtocolException getError();
    4437}
  • protocol/src/main/java/geniusweb/protocol/ProtocolException.java

    r4 r21  
    22
    33import geniusweb.actions.PartyId;
    4 import geniusweb.party.Party;
    54import geniusweb.references.PartyRef;
    65
     
    109 */
    1110public class ProtocolException extends Exception {
    12         private String party; // the failing party
     11        private static final long serialVersionUID = 4618901784366523980L;
     12        private PartyId party; // the failing party
    1313
    1414        /**
     
    1717         *                {@link PartyRef}
    1818         */
    19         public ProtocolException(String message, String party) {
     19        public ProtocolException(String message, PartyId party) {
    2020                this(message, party, null);
    2121        }
     
    3030         *
    3131         * @param message the error message
    32          * @param party   offending party, either the {@link PartyId} or a
    33          *                {@link PartyRef}
     32         * @param party   offending {@link PartyId}
    3433         * @param e       the cause of the error
    3534         */
    36         public ProtocolException(String message, String party, Throwable e) {
     35        public ProtocolException(String message, PartyId party, Throwable e) {
    3736                super(party + ":" + message, e, true, false);
    3837                this.party = party;
     
    4342         * @return offending party, either the {@link PartyId} or a {@link PartyRef}
    4443         */
    45         public String getParty() {
     44        public PartyId getParty() {
    4645                return party;
    4746        }
  • protocol/src/main/java/geniusweb/protocol/partyconnection/ProtocolToPartyConn.java

    r9 r21  
    44import geniusweb.actions.PartyId;
    55import geniusweb.connection.ConnectionEnd;
    6 import geniusweb.party.inform.Inform;
     6import geniusweb.inform.Inform;
    77
    88/**
     
    1414        /**
    1515         *
    16          * @return the partyId of the party that this connects to
     16         * @return the partyId of the party that this connects to.
    1717         */
    1818        PartyId getParty();
  • protocol/src/main/java/geniusweb/protocol/partyconnection/ProtocolToPartyConnFactory.java

    r9 r21  
    66import geniusweb.actions.Action;
    77import geniusweb.connection.ConnectionFactory;
    8 import geniusweb.party.inform.Inform;
     8import geniusweb.inform.Inform;
    99import geniusweb.references.Reference;
    1010import tudelft.utilities.repository.NoResourcesNowException;
  • protocol/src/main/java/geniusweb/protocol/partyconnection/ProtocolToPartyConnections.java

    r9 r21  
    99
    1010import geniusweb.actions.PartyId;
    11 import geniusweb.party.inform.Inform;
     11import geniusweb.inform.Inform;
    1212
    1313/**
    1414 * Contains all parties with their connections. immutable
    1515 */
    16 public class ProtocolToPartyConnections implements Iterable<ProtocolToPartyConn> {
     16public class ProtocolToPartyConnections
     17                implements Iterable<ProtocolToPartyConn> {
    1718        private List<ProtocolToPartyConn> connections;
    1819
  • protocol/src/main/java/geniusweb/protocol/session/DefaultSessionState.java

    r10 r21  
    5757         *                      {@link ProtocolException}s. All errors in our own
    5858         *                      code are bugs (not ProtocolExceptions) and should
    59          *                      result in a throw.
     59         *                      result in a throw and terminate the session.
    6060         */
    6161        public DefaultSessionState(List<Action> actions,
     
    130130        }
    131131
    132         @Override
    133132        public ProtocolException getError() {
    134133                return error;
  • protocol/src/main/java/geniusweb/protocol/session/SessionResult.java

    r20 r21  
    1010import com.fasterxml.jackson.annotation.JsonTypeInfo;
    1111
    12 import geniusweb.issuevalue.Bid;
     12import geniusweb.inform.Agreements;
    1313import geniusweb.references.PartyWithProfile;
    1414
     
    2020public class SessionResult {
    2121        private final List<PartyWithProfile> participants;
    22         private final Bid agreement;
     22        private final Agreements agreements;
    2323        private final List<Double> penalties;
    2424
     
    3333         *                     never be null. Some of them may have entered later of
    3434         *                     left early. This list should contain them all.
    35          * @param agreement    the final agreement {@link Bid} of the session. Null
    36          *                     if no agreement was reached.
     35         * @param agreements   the final Agreements.
    3736         * @param penalties    the penalties in [0,1] for each participant, same
    3837         *                     order as the participants list.
     
    4847        public SessionResult(
    4948                        @JsonProperty("participants") List<PartyWithProfile> participants,
    50                         @JsonProperty("agreement") Bid agreement,
     49                        @JsonProperty("agreements") Agreements agreements,
    5150                        @JsonProperty("penalties") List<Double> penalties,
    5251                        @JsonProperty("error") Throwable error) {
    5352                this.participants = participants;
    54                 this.agreement = agreement;
     53                this.agreements = agreements;
    5554                this.penalties = penalties;
    5655                this.error = error;
     
    6968
    7069        /**
    71          * 8return the final agreement {@link Bid} of the session. Null if no
    72          * agreement was reached.
     70         * 8return the final {@link Agreements} of the session. May be empty, not
     71         * null
    7372         */
    74         public Bid getAgreement() {
    75                 return agreement;
     73        public Agreements getAgreements() {
     74                return agreements;
    7675        };
    7776
     
    9998        @Override
    10099        public String toString() {
    101                 return "SessionResult[" + participants + "," + agreement + ","
     100                return "SessionResult[" + participants + "," + agreements + ","
    102101                                + penalties + "," + error + "]";
    103102        }
     
    108107                int result = 1;
    109108                result = prime * result
    110                                 + ((agreement == null) ? 0 : agreement.hashCode());
     109                                + ((agreements == null) ? 0 : agreements.hashCode());
    111110                result = prime * result + ((error == null) ? 0 : error.hashCode());
    112111                result = prime * result
     
    126125                        return false;
    127126                SessionResult other = (SessionResult) obj;
    128                 if (agreement == null) {
    129                         if (other.agreement != null)
     127                if (agreements == null) {
     128                        if (other.agreements != null)
    130129                                return false;
    131                 } else if (!agreement.equals(other.agreement))
     130                } else if (!agreements.equals(other.agreements))
    132131                        return false;
    133132                if (error == null) {
  • protocol/src/main/java/geniusweb/protocol/session/SessionSettings.java

    r10 r21  
    66
    77import geniusweb.protocol.NegoSettings;
     8import geniusweb.protocol.session.amop.AMOPSettings;
     9import geniusweb.protocol.session.mopac.MOPACSettings;
    810import geniusweb.protocol.session.saop.SAOPSettings;
    911import geniusweb.protocol.session.shaop.SHAOPSettings;
     
    1517 */
    1618@JsonSubTypes({ @JsonSubTypes.Type(value = SAOPSettings.class),
    17                 @JsonSubTypes.Type(value = SHAOPSettings.class) })
     19                @JsonSubTypes.Type(value = SHAOPSettings.class),
     20                @JsonSubTypes.Type(value = AMOPSettings.class),
     21                @JsonSubTypes.Type(value = MOPACSettings.class) })
    1822public interface SessionSettings extends NegoSettings {
    1923
  • protocol/src/main/java/geniusweb/protocol/session/SessionState.java

    r20 r21  
    66
    77import geniusweb.actions.Action;
    8 import geniusweb.issuevalue.Bid;
     8import geniusweb.inform.Agreements;
    99import geniusweb.progress.Progress;
    1010import geniusweb.protocol.NegoState;
     11import geniusweb.protocol.session.amop.AMOPState;
     12import geniusweb.protocol.session.mopac.MOPACState;
    1113import geniusweb.protocol.session.saop.SAOPState;
    1214import geniusweb.protocol.session.shaop.SHAOPState;
     
    3537 */
    3638@JsonSubTypes({ @JsonSubTypes.Type(value = SAOPState.class),
    37                 @JsonSubTypes.Type(value = SHAOPState.class) })
    38 
     39                @JsonSubTypes.Type(value = SHAOPState.class),
     40                @JsonSubTypes.Type(value = AMOPState.class),
     41                @JsonSubTypes.Type(value = MOPACState.class) })
    3942public interface SessionState extends NegoState {
    4043
     
    4548         *
    4649         * @return unmodifyable list of actions done so far, in the order in which
    47          *         they arrived.
     50         *         they arrived. List of list allows implementations to add some
     51         *         extra structure to the actions, eg one list per phase
    4852         */
    4953        List<Action> getActions();
     
    6468         *         {@link #isFinal()}.
    6569         */
    66         Bid getAgreement();
     70        Agreements getAgreements();
    6771
    6872        /**
  • protocol/src/main/java/geniusweb/protocol/session/TeamOfPartiesAndProfiles.java

    r10 r21  
    77import com.fasterxml.jackson.annotation.JsonSubTypes;
    88
    9 import geniusweb.protocol.session.saop.SaopPartyWithProfile;
    109import geniusweb.protocol.session.shaop.ShaopTeam;
    1110import geniusweb.references.PartyWithProfile;
     
    2322// and do not (de)serialize individual TeamOfPartiesAndProfiles.
    2423//@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
    25 @JsonSubTypes({ @JsonSubTypes.Type(value = SaopPartyWithProfile.class),
     24@JsonSubTypes({ @JsonSubTypes.Type(value = OnePartyTeam.class),
    2625                @JsonSubTypes.Type(value = ShaopTeam.class) })
    2726public interface TeamOfPartiesAndProfiles {
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOP.java

    r10 r21  
    1515import geniusweb.deadline.Deadline;
    1616import geniusweb.events.ProtocolEvent;
    17 import geniusweb.party.inform.ActionDone;
    18 import geniusweb.party.inform.Finished;
    19 import geniusweb.party.inform.Inform;
    20 import geniusweb.party.inform.Settings;
    21 import geniusweb.party.inform.YourTurn;
     17import geniusweb.inform.ActionDone;
     18import geniusweb.inform.Finished;
     19import geniusweb.inform.Inform;
     20import geniusweb.inform.Settings;
     21import geniusweb.inform.YourTurn;
    2222import geniusweb.progress.ProgressFactory;
    2323import geniusweb.protocol.CurrentNegoState;
     
    227227                        } catch (IOException e) {
    228228                                throw new ProtocolException("Failed to initialize",
    229                                                 connection.getParty().getName(), e);
     229                                                connection.getParty(), e);
    230230                        }
    231231                }
     
    257257         * Synchronized so that we always handle only 1 action at a time.
    258258         *
    259          * @param partyconn the connection on which the action came in
     259         * @param partyconn the connection on which the action came in.
    260260         * @param action    the {@link Action} taken by some party
    261261         */
     
    266266                        if (err == null) {
    267267                                err = new ProtocolException("Party sent a null action",
    268                                                 partyconn.getParty().getName());
    269                         }
    270                         handleError(partyconn + "Protocol error",
    271                                         partyconn.getParty().getName(), err);
     268                                                partyconn.getParty());
     269                        }
     270                        handleError(partyconn + "Protocol error", partyconn.getParty(),
     271                                        err);
    272272                        return;
    273273                }
     
    278278                                throw new ProtocolException(
    279279                                                "Party acts without having the turn",
    280                                                 partyconn.getParty().getName());
     280                                                partyconn.getParty());
    281281                        }
    282282                        state.getConnections().broadcast(new ActionDone(action));
     
    286286                } catch (Throwable e) {
    287287                        handleError("failed to handle action " + action,
    288                                         partyconn.getParty().getName(), e);
     288                                        partyconn.getParty(), e);
    289289                }
    290290
     
    301301                        state.getConnections().get(party).send(new YourTurn());
    302302                } catch (IOException e) {
    303                         handleError("failed to send YourTurn", party.getName(), e);
     303                        handleError("failed to send YourTurn", party, e);
    304304                }
    305305        }
     
    313313         */
    314314        private synchronized void handleError(final String message,
    315                         final String party, final Throwable e) {
     315                        final PartyId party, final Throwable e) {
    316316                if (e instanceof ProtocolException) {
    317317                        setState(state.with((ProtocolException) e));
     
    353353                if (!isFinishedInfoSent.compareAndSet(false, true))
    354354                        return;
    355                 Inform finished = new Finished(state.getAgreement());
     355                Inform finished = new Finished(state.getAgreements());
    356356                for (ProtocolToPartyConn conn : state.getConnections()) {
    357357                        sendFinish(conn, finished);
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOPSettings.java

    r10 r21  
    1010
    1111import geniusweb.deadline.Deadline;
     12import geniusweb.protocol.session.OnePartyTeam;
    1213import geniusweb.protocol.session.SessionProtocol;
    1314import geniusweb.protocol.session.SessionSettings;
     
    1718
    1819public class SAOPSettings implements SessionSettings {
    19         private final List<SaopPartyWithProfile> participants;
     20        private final List<OnePartyTeam> participants;
    2021        private final Deadline deadline;
    2122
     
    3031        @JsonCreator
    3132        public SAOPSettings(
    32                         @JsonProperty("participants") List<SaopPartyWithProfile> participants,
     33                        @JsonProperty("participants") List<OnePartyTeam> participants,
    3334                        @JsonProperty("deadline") Deadline deadline) {
    3435                this.participants = participants;
     
    111112        @Override
    112113        public SessionSettings with(TeamOfPartiesAndProfiles party) {
    113                 if (!(party instanceof SaopPartyWithProfile))
     114                if (!(party instanceof OnePartyTeam))
    114115                        throw new IllegalArgumentException(
    115                                         "Added party must be SaopPartyWithProfile but got "
    116                                                         + party);
    117                 List<SaopPartyWithProfile> newparts = new LinkedList<>(participants);
    118                 newparts.add((SaopPartyWithProfile) party);
     116                                        "Added party must be OnePartyTeam but got " + party);
     117                List<OnePartyTeam> newparts = new LinkedList<>(participants);
     118                newparts.add((OnePartyTeam) party);
    119119                return new SAOPSettings(newparts, deadline);
    120120        }
  • protocol/src/main/java/geniusweb/protocol/session/saop/SAOPState.java

    r20 r21  
    66import java.util.List;
    77import java.util.Map;
     8import java.util.Set;
     9import java.util.stream.Collectors;
    810
    911import geniusweb.actions.Accept;
     
    1214import geniusweb.actions.Offer;
    1315import geniusweb.actions.PartyId;
     16import geniusweb.inform.Agreements;
    1417import geniusweb.issuevalue.Bid;
    1518import geniusweb.progress.Progress;
     
    113116
    114117        @Override
    115         public Bid getAgreement() {
     118        public Agreements getAgreements() {
     119                Agreements agree = new Agreements();
    116120                List<Action> acts = getActions();
    117121                int nparticipants = getConnections().size();
    118122                if (nparticipants < 2 || acts.size() < nparticipants) {
    119                         return null;
     123                        return agree;
    120124                }
    121125                Action offer = acts.get(acts.size() - nparticipants);
    122126                if (!(offer instanceof Offer))
    123                         return null;
     127                        return agree;
    124128                Bid bid = ((Offer) offer).getBid();
    125129
     
    128132                                .allMatch(act -> act instanceof Accept
    129133                                                && bid.equals(((Accept) act).getBid()));
    130                 return allaccept ? bid : null;
     134                if (allaccept)
     135                        agree = agree.with(bid, getParties());
     136                return agree;
     137        }
     138
     139        /**
     140         *
     141         * @return all currently connected parties.
     142         */
     143        private Set<PartyId> getParties() {
     144                return getConnections().stream().map(conn -> conn.getParty())
     145                                .collect(Collectors.toSet());
    131146        }
    132147
     
    134149        public boolean isFinal(long currentTimeMs) {
    135150                List<Action> acts = getActions();
    136                 return super.isFinal(currentTimeMs) || getAgreement() != null
    137                                 || (!acts.isEmpty()
     151                return super.isFinal(currentTimeMs)
     152                                || !getAgreements().getMap().isEmpty() || (!acts.isEmpty()
    138153                                                && acts.get(acts.size() - 1) instanceof EndNegotiation);
    139154        }
     
    254269                for (int n = 0; n < getConnections().size(); n++)
    255270                        emptylist.add(0d);
    256                 return new SessionResult(getSettings().getAllParties(), getAgreement(),
     271                return new SessionResult(getSettings().getAllParties(), getAgreements(),
    257272                                emptylist, getError());
    258273        }
  • protocol/src/main/java/geniusweb/protocol/session/shaop/BareSHAOPState.java

    r20 r21  
    158158        }
    159159
    160         @Override
    161160        public ProtocolException getError() {
    162161                return error;
     
    182181                        penalties[partyNumbers.get(party)] = spent;
    183182                }
    184                 return new SessionResult(getSettings().getAllParties(), getAgreement(),
     183                return new SessionResult(getSettings().getAllParties(), getAgreements(),
    185184                                Arrays.asList(penalties), getError());
    186185
  • protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOP.java

    r18 r21  
    2121import geniusweb.deadline.Deadline;
    2222import geniusweb.events.ProtocolEvent;
    23 import geniusweb.party.inform.ActionDone;
    24 import geniusweb.party.inform.Finished;
    25 import geniusweb.party.inform.Inform;
    26 import geniusweb.party.inform.Settings;
    27 import geniusweb.party.inform.YourTurn;
     23import geniusweb.inform.ActionDone;
     24import geniusweb.inform.Finished;
     25import geniusweb.inform.Inform;
     26import geniusweb.inform.Settings;
     27import geniusweb.inform.YourTurn;
    2828import geniusweb.progress.ProgressFactory;
    2929import geniusweb.protocol.CurrentNegoState;
     
    238238                        } catch (IOException e) {
    239239                                throw new ProtocolException("Failed to initialize",
    240                                                 connection.getParty().getName(), e);
     240                                                connection.getParty(), e);
    241241                        }
    242242                }
     
    276276                } catch (Throwable e) {
    277277                        handleError("failed to handle action " + action,
    278                                         partyconn.getParty().getName(), e);
     278                                        partyconn.getParty(), e);
    279279                }
    280280        }
     
    289289
    290290                if (action == null)
    291                         throw new ProtocolException("Party sent a null action",
    292                                         partyid.getName());
     291                        throw new ProtocolException("Party sent a null action", partyid);
    293292
    294293                // check if action allowed
     
    296295                        if (!ALLOWED_ACTIONS.contains(action.getClass())) {
    297296                                throw new ProtocolException(
    298                                                 "Illegal action for SHAOP Party:" + action,
    299                                                 partyid.getName());
     297                                                "Illegal action for SHAOP Party:" + action, partyid);
    300298                        }
    301299                } else {
    302300                        if (!(action instanceof Comparison))
    303301                                throw new ProtocolException(
    304                                                 "Illegal action for COB Party:" + action,
    305                                                 partyid.getName());
     302                                                "Illegal action for COB Party:" + action, partyid);
    306303                }
    307304
     
    316313                        if (!partyconn.getParty().equals(state.getCurrentTeam()))
    317314                                throw new ProtocolException(
    318                                                 "Party acts without having the turn",
    319                                                 partyid.getName());
     315                                                "Party acts without having the turn", partyid);
    320316                        setState(state.with(partyconn.getParty(), action));
    321317                        state.connections.broadcast(new ActionDone(action));
     
    336332                        state.getConnections().get(party).send(new YourTurn());
    337333                } catch (IOException e) {
    338                         handleError("failed to send YourTurn", party.getName(), e);
     334                        handleError("failed to send YourTurn", party, e);
    339335                }
    340336        }
     
    348344         */
    349345        private synchronized void handleError(final String message,
    350                         final String party, final Throwable e) {
     346                        final PartyId party, final Throwable e) {
    351347                log.log(Level.WARNING, "SHAOP protocol intercepted error due to party "
    352348                                + party + ": " + message, e);
     
    388384                if (!isFinishedInfoSent.compareAndSet(false, true))
    389385                        return;
    390                 Inform finished = new Finished(state.getAgreement());
     386                Inform finished = new Finished(state.getAgreements());
    391387                state.connections.stream().forEach(conn -> sendFinish(conn, finished));
    392388                notifyListeners(new CurrentNegoState(state));
  • protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOPState.java

    r18 r21  
    66import java.util.List;
    77import java.util.Map;
     8import java.util.Set;
     9import java.util.stream.Collectors;
    810
    911import com.fasterxml.jackson.annotation.JsonCreator;
     
    1719import geniusweb.actions.Offer;
    1820import geniusweb.actions.PartyId;
     21import geniusweb.inform.Agreements;
    1922import geniusweb.issuevalue.Bid;
    2023import geniusweb.progress.Progress;
     
    7881        /**
    7982         *
     83         * @return the team leader {@link PartyId}s.
     84         */
     85        private Set<PartyId> getLeaders() {
     86                return partyNumbers.keySet().stream().filter(id -> isShaopParty(id))
     87                                .collect(Collectors.toSet());
     88        }
     89
     90        /**
     91         *
    8092         * @param party a Party Id
    8193         * @return the PartyId of the party (COB and SHAOP are partners)
     
    88100        public boolean isFinal(long currentTimeMs) {
    89101                List<Action> acts = getActions();
    90                 return super.isFinal(currentTimeMs) || getAgreement() != null
    91                                 || (!acts.isEmpty()
     102                return super.isFinal(currentTimeMs)
     103                                || !getAgreements().getMap().isEmpty() || (!acts.isEmpty()
    92104                                                && acts.get(acts.size() - 1) instanceof EndNegotiation);
    93105        }
     
    166178
    167179        @Override
    168         public Bid getAgreement() {
     180        public Agreements getAgreements() {
     181                Agreements agrees = new Agreements();
    169182                List<Action> acts = getActions();
    170183                if (acts.isEmpty())
    171                         return null;
     184                        return agrees;
    172185
    173186                int requiredaccepts = getSettings().getTeams().size() - 1;
     
    179192                                continue;
    180193                        if (requiredaccepts == 0 && act instanceof Offer)
    181                                 return ((Offer) act).getBid();
     194                                return agrees.with(((Offer) act).getBid(), getLeaders());
    182195                        if (!(act instanceof Accept))
    183                                 return null;
     196                                return agrees;
    184197                        requiredaccepts--;
    185198                }
    186                 return null;
     199                return agrees;
    187200        }
    188201
  • protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettings.java

    r18 r21  
    99import com.fasterxml.jackson.annotation.JsonProperty;
    1010
     11import geniusweb.protocol.session.OnePartyTeam;
    1112import geniusweb.protocol.session.SessionSettings;
    1213import geniusweb.protocol.session.TeamOfPartiesAndProfiles;
     14import geniusweb.protocol.session.amop.AMOPSettings;
     15import geniusweb.protocol.session.mopac.MOPACSettings;
    1316import geniusweb.protocol.session.saop.SAOPSettings;
    14 import geniusweb.protocol.session.saop.SaopPartyWithProfile;
    1517import geniusweb.protocol.session.shaop.SHAOPSettings;
    1618import geniusweb.protocol.session.shaop.ShaopTeam;
     
    106108                        throw new IllegalArgumentException("nTournaments must be >0");
    107109                int teamsize;
    108                 if (sesettings instanceof SAOPSettings)
     110                if (sesettings instanceof SAOPSettings
     111                                || sesettings instanceof MOPACSettings
     112                                || sesettings instanceof AMOPSettings)
    109113                        teamsize = 1;
    110114                else if (sesettings instanceof SHAOPSettings)
     
    283287                        public TeamOfPartiesAndProfiles apply(Team team,
    284288                                        ProfileList profilelist) {
    285                                 if (sessionsettings instanceof SAOPSettings)
    286                                         return new SaopPartyWithProfile(team.getParties().get(0),
     289                                if (sessionsettings instanceof SAOPSettings
     290                                                || sessionsettings instanceof AMOPSettings
     291                                                || sessionsettings instanceof MOPACSettings)
     292                                        return new OnePartyTeam(team.getParties().get(0),
    287293                                                        profilelist.getProfiles().get(0));
    288294                                else if (sessionsettings instanceof SHAOPSettings) {
  • protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsState.java

    r20 r21  
    55import java.util.List;
    66
    7 import geniusweb.protocol.ProtocolException;
    87import geniusweb.protocol.session.SessionResult;
    98import geniusweb.protocol.session.SessionSettings;
     
    6564        }
    6665
    67         @Override
    68         public ProtocolException getError() {
    69                 return null;
    70         }
    71 
    7266        /**
    7367         *
  • protocol/src/test/java/geniusweb/protocol/session/DefaultSessionStateTest.java

    r20 r21  
    2323import geniusweb.actions.PartyId;
    2424import geniusweb.deadline.DeadlineTime;
    25 import geniusweb.issuevalue.Bid;
     25import geniusweb.inform.Agreements;
    2626import geniusweb.progress.Progress;
    2727import geniusweb.progress.ProgressTime;
     
    2929import geniusweb.protocol.partyconnection.ProtocolToPartyConnections;
    3030import geniusweb.protocol.session.saop.SAOPSettings;
    31 import geniusweb.protocol.session.saop.SaopPartyWithProfile;
    3231import geniusweb.references.Parameters;
    3332import geniusweb.references.PartyRef;
     
    6059                                new PartyRef("party2"), new Parameters());
    6160                ProfileRef profile2 = new ProfileRef("profile2");
    62                 List<SaopPartyWithProfile> participants = Arrays.asList(
    63                                 new SaopPartyWithProfile(party1ref, profile1),
    64                                 new SaopPartyWithProfile(party2ref, profile2));
     61                List<OnePartyTeam> participants = Arrays.asList(
     62                                new OnePartyTeam(party1ref, profile1),
     63                                new OnePartyTeam(party2ref, profile2));
    6564                SessionSettings settings = new SAOPSettings(participants, deadline);
    6665                ProtocolException e = new ProtocolException("test protocol error",
    67                                 party1.getName());
     66                                party1);
    6867                HashMap<PartyId, PartyWithProfile> partyprofiles = new HashMap<PartyId, PartyWithProfile>();
    6968                partyprofiles.put(party1, new PartyWithProfile(party1ref, profile1));
     
    135134
    136135        @Override
    137         public Bid getAgreement() {
    138                 return null;
    139         }
    140 
    141         @Override
    142136        public SessionResult getResult() {
    143137
     
    145139                for (int n = 0; n < getConnections().size(); n++)
    146140                        emptylist.add(0d);
    147                 return new SessionResult(getSettings().getAllParties(), getAgreement(),
     141                return new SessionResult(getSettings().getAllParties(), getAgreements(),
    148142                                emptylist, getError());
    149143
    150144        }
    151145
     146        @Override
     147        public Agreements getAgreements() {
     148                return new Agreements();
     149        }
     150
    152151}
  • protocol/src/test/java/geniusweb/protocol/session/SessionResultTest.java

    r20 r21  
    77import java.util.Arrays;
    88import java.util.HashMap;
     9import java.util.HashSet;
    910import java.util.List;
    1011import java.util.Map;
     
    1617import com.fasterxml.jackson.databind.ObjectMapper;
    1718
     19import geniusweb.actions.PartyId;
     20import geniusweb.inform.Agreements;
    1821import geniusweb.issuevalue.Bid;
    1922import geniusweb.issuevalue.DiscreteValue;
     
    3235        private final String ISSUE1 = "issue1";
    3336        private SessionResult result1, result1a, result2, result3, result4;
    34         private String errorstring; // created dynamically: eclipse and maven
    35                                                                 // generate different stacktrace.
    36         private String jsonstring = "{\"participants\":[{\"party\":{\"partyref\":\"party1\",\"parameters\":{}},\"profile\":\"profile1\"},{\"party\":{\"partyref\":\"party2\",\"parameters\":{}},\"profile\":\"profile2\"}],\"agreement\":{\"issuevalues\":{\"issue1\":\"a\"}},\"penalties\":[0.0,0.0],\"error\":null}";
     37        private String jsonstring = "{\"participants\":[{\"party\":{\"partyref\":\"party1\",\"parameters\":{}},\"profile\":\"profile1\"},{\"party\":{\"partyref\":\"party2\",\"parameters\":{}},\"profile\":\"profile2\"}],\"agreements\":{\"party2\":{\"issuevalues\":{\"issue1\":\"a\"}},\"party1\":{\"issuevalues\":{\"issue1\":\"a\"}}},\"penalties\":[0.0,0.0],\"error\":null}";
    3738        private List<Double> nopenalties = Arrays.asList(0d, 0d);
    3839        private List<Double> penalties = Arrays.asList(0.1d, 0.2d);
    3940
     41        private PartyId PARTY1 = new PartyId("party1");
     42        private PartyId PARTY2 = new PartyId("party2");
     43        private PartyId PARTY3 = new PartyId("party3");
     44
    4045        @Before
    4146        public void before() throws URISyntaxException, JsonProcessingException {
    42                 errorstring = "\"error\":{\"java.lang.RuntimeException\":"
     47                String errorstring = "\"error\":{\"java.lang.RuntimeException\":"
    4348                                + jackson.writeValueAsString(error) + "}";
    44                 System.out.println(errorstring);
     49                // System.out.println(errorstring);
    4550
    4651                PartyWithParameters party1 = new PartyWithParameters(
     
    5762                issuevalues1.put(ISSUE1, new DiscreteValue("a"));
    5863                Bid bid1 = new Bid(issuevalues1);
     64                Agreements agreement1 = new Agreements().with(bid1,
     65                                new HashSet<>(Arrays.asList(PARTY1, PARTY2)));
    5966
    6067                // different order but that shouldn't matter
     
    6269                issuevalues2.put(ISSUE1, new DiscreteValue("b"));
    6370                Bid bid2 = new Bid(issuevalues2);
     71                Agreements agreement2 = new Agreements().with(bid2,
     72                                new HashSet<>(Arrays.asList(PARTY1, PARTY3)));
    6473
    6574                result1 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2),
    66                                 bid1, nopenalties, null);
     75                                agreement1, nopenalties, null);
    6776                result1a = new SessionResult(
    68                                 Arrays.asList(partyprofile1, partyprofile2), bid1, nopenalties,
    69                                 null);
     77                                Arrays.asList(partyprofile1, partyprofile2), agreement1,
     78                                nopenalties, null);
    7079                result2 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2),
    71                                 bid2, nopenalties, null);
     80                                agreement2, nopenalties, null);
    7281                result3 = new SessionResult(Arrays.asList(partyprofile2, partyprofile1),
    73                                 bid2, nopenalties, null);
     82                                agreement1, nopenalties, null);
    7483                result4 = new SessionResult(Arrays.asList(partyprofile2, partyprofile1),
    75                                 bid2, penalties, null);
     84                                agreement1, penalties, null);
    7685
    7786                // IGNORE ERROR for now, it fails somewhere deep in maven suddenly.
     
    9099        public List<String> getGeneralTestStrings() {
    91100                return Arrays.asList(
    92                                 "SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"a\".*0\\.0.*0\\.0.*null.*",
    93                                 "SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"b\".*0\\.0.*0\\.0.*null.*",
    94                                 "SessionResult.*party2.*profile2.*,.*party1.*profile1.*Bid.*issue1=\"b\".*0\\.0.*0\\.0.*null.*",
    95                                 "SessionResult.*party2.*profile2.*,.*party1.*profile1.*Bid.*issue1=\"b\".*0\\.1.*0\\.2.*null.*"
     101                                "SessionResult.*party1.*profile1.*,.*party2.*profile2.*Agreements.*Bid.*issue1=\"a\".*0\\.0.*0\\.0.*null.*",
     102                                "SessionResult.*party1.*profile1.*,.*party2.*profile2.*Agreements.*Bid.*issue1=\"b\".*0\\.0.*0\\.0.*null.*",
     103                                "SessionResult.*party2.*profile2.*,.*party1.*profile1.*Agreements.*Bid.*issue1=\"a\".*0\\.0.*0\\.0.*null.*",
     104                                "SessionResult.*party2.*profile2.*,.*party1.*profile1.*Agreements.*Bid.*issue1=\"a\".*0\\.1.*0\\.2.*null.*"
    96105
    97106                );
  • protocol/src/test/java/geniusweb/protocol/session/saop/SAOPSettingsTest.java

    r10 r21  
    1919import geniusweb.deadline.DeadlineRounds;
    2020import geniusweb.deadline.DeadlineTime;
     21import geniusweb.protocol.session.OnePartyTeam;
    2122import geniusweb.protocol.session.SessionSettings;
    2223import geniusweb.references.Parameters;
     
    2930public class SAOPSettingsTest extends GeneralTests<SAOPSettings> {
    3031
    31         private SaopPartyWithProfile partyprof1 = mock(SaopPartyWithProfile.class);
    32         private SaopPartyWithProfile partyprof2 = mock(SaopPartyWithProfile.class);
    33         private SaopPartyWithProfile partyprof3 = mock(SaopPartyWithProfile.class);
    34         private List<SaopPartyWithProfile> participants2 = Arrays.asList(partyprof1,
     32        private OnePartyTeam partyprof1 = mock(OnePartyTeam.class);
     33        private OnePartyTeam partyprof2 = mock(OnePartyTeam.class);
     34        private OnePartyTeam partyprof3 = mock(OnePartyTeam.class);
     35        private List<OnePartyTeam> participants2 = Arrays.asList(partyprof1,
    3536                        partyprof2);
    36         private List<SaopPartyWithProfile> participants3 = Arrays.asList(partyprof1,
     37        private List<OnePartyTeam> participants3 = Arrays.asList(partyprof1,
    3738                        partyprof2, partyprof3);
    3839
     
    6667                                new PartyRef("http://party2"), new Parameters());
    6768                ProfileRef profile2 = new ProfileRef("http://profile2");
    68                 SaopPartyWithProfile partywithprof1 = new SaopPartyWithProfile(party1,
    69                                 profile1);
    70                 SaopPartyWithProfile partywithprof2 = new SaopPartyWithProfile(party2,
    71                                 profile2);
    72                 List<SaopPartyWithProfile> participants = Arrays.asList(partywithprof1,
     69                OnePartyTeam partywithprof1 = new OnePartyTeam(party1, profile1);
     70                OnePartyTeam partywithprof2 = new OnePartyTeam(party2, profile2);
     71                List<OnePartyTeam> participants = Arrays.asList(partywithprof1,
    7372                                partywithprof2);
    7473
  • protocol/src/test/java/geniusweb/protocol/session/saop/SAOPStateTest.java

    r10 r21  
    176176                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    177177                                settings, null, null);
    178                 assertNull(state.getAgreement());
     178                assertTrue(state.getAgreements().getMap().isEmpty());
    179179        }
    180180
     
    184184                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    185185                                settings, null, null);
    186                 assertNull(state.getAgreement());
     186                assertTrue(state.getAgreements().getMap().isEmpty());
    187187        }
    188188
     
    192192                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    193193                                settings, null, null);
    194                 assertNull(state.getAgreement());
     194                assertTrue(state.getAgreements().getMap().isEmpty());
    195195        }
    196196
     
    200200                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    201201                                settings, null, null);
    202                 assertEquals(bid1, state.getAgreement());
     202                assertEquals(bid1, state.getAgreements().getMap().get(party1));
    203203                assertTrue(state.isFinal(NOW));
    204204        }
     
    209209                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    210210                                settings, null, null);
    211                 assertEquals(null, state.getAgreement());
     211                assertTrue(state.getAgreements().getMap().isEmpty());
    212212        }
    213213
     
    217217                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    218218                                settings, null, null);
    219                 assertEquals(null, state.getAgreement());
     219                assertTrue(state.getAgreements().getMap().isEmpty());
    220220        }
    221221
     
    246246                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    247247                                settings, null, null);
    248                 assertEquals(null, state.getAgreement());
     248                assertTrue(state.getAgreements().getMap().isEmpty());
    249249                assertEquals(null, state.getError());
    250250                assertTrue(state.isFinal(NOW));
     
    255255        public void isProtocolErrorFinal() {
    256256                SAOPState state = new SAOPState(actions, connections3, progressrounds,
    257                                 settings, null, new ProtocolException("test error", "test"));
     257                                settings, null,
     258                                new ProtocolException("test error", new PartyId("test")));
    258259                assertTrue(state.isFinal(NOW));
    259260                assertNotNull(state.getError());
     
    309310                assertTrue(state.isFinal(NOW));
    310311                assertNull(state.getError());
    311                 assertEquals(bid1, state.getAgreement());
     312                assertEquals(bid1, state.getAgreements().getMap().get(party1));
    312313
    313314        }
     
    325326                assertTrue(state.isFinal(NOW));
    326327                assertNull(state.getError());
    327                 assertEquals(bid2, state.getAgreement());
     328                assertEquals(bid2, state.getAgreements().getMap().get(party1));
    328329
    329330        }
  • protocol/src/test/java/geniusweb/protocol/session/saop/SAOPTest.java

    r10 r21  
    3434import geniusweb.events.CurrentState;
    3535import geniusweb.events.ProtocolEvent;
    36 import geniusweb.party.inform.Finished;
    37 import geniusweb.party.inform.Inform;
    38 import geniusweb.party.inform.Settings;
    39 import geniusweb.party.inform.YourTurn;
     36import geniusweb.inform.Finished;
     37import geniusweb.inform.Inform;
     38import geniusweb.inform.Settings;
     39import geniusweb.inform.YourTurn;
    4040import geniusweb.progress.Progress;
    4141import geniusweb.protocol.ProtocolException;
     
    4343import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory;
    4444import geniusweb.protocol.partyconnection.ProtocolToPartyConnections;
     45import geniusweb.protocol.session.OnePartyTeam;
    4546import geniusweb.protocol.session.TeamOfPartiesAndProfiles;
    4647import geniusweb.references.Parameters;
     
    7576        private final PartyRef party2ref = mock(PartyRef.class);
    7677        private final SAOPSettings settings = mock(SAOPSettings.class);
    77         private final SaopPartyWithProfile team1 = mock(SaopPartyWithProfile.class);
    78         private final SaopPartyWithProfile team2 = mock(SaopPartyWithProfile.class);
     78        private final OnePartyTeam team1 = mock(OnePartyTeam.class);
     79        private final OnePartyTeam team2 = mock(OnePartyTeam.class);
    7980        private SAOP saop;
    8081        private ProtocolToPartyConnFactory factory;
     
    8283        private ProtocolToPartyConn conn1 = mock(ProtocolToPartyConn.class),
    8384                        conn2 = mock(ProtocolToPartyConn.class);
    84         private Map<PartyId, SaopPartyWithProfile> partyprofiles;
     85        private Map<PartyId, OnePartyTeam> partyprofiles;
    8586        private Progress progress = mock(Progress.class);
    8687        private ProfileRef profile1;
  • protocol/src/test/java/geniusweb/protocol/session/saop/SaopPartyWithProfileTest.java

    r10 r21  
    1717import com.fasterxml.jackson.databind.ObjectMapper;
    1818
     19import geniusweb.protocol.session.OnePartyTeam;
    1920import geniusweb.protocol.session.TeamOfPartiesAndProfiles;
    2021import geniusweb.references.Parameters;
     
    2425import tudelft.utilities.junit.GeneralTests;
    2526
    26 public class SaopPartyWithProfileTest
    27                 extends GeneralTests<SaopPartyWithProfile> {
     27public class SaopPartyWithProfileTest extends GeneralTests<OnePartyTeam> {
    2828
    2929        private PartyRef party1, party1a, party2, party3;
    3030        private ProfileRef profile1, profile2;
    31         private SaopPartyWithProfile partyprof1, partyprof1a, partyprof2,
    32                         partyprof3, partyprof4;
     31        private OnePartyTeam partyprof1, partyprof1a, partyprof2, partyprof3,
     32                        partyprof4;
    3333        private final String serialized = "{\"party\":{\"partyref\":\"ws:party1\",\"parameters\":{}},\"profile\":\"ws:profile1\"}";
    3434
     
    5454                                settings1);
    5555
    56                 partyprof1 = new SaopPartyWithProfile(party1withparams1, profile1);
    57                 partyprof1a = new SaopPartyWithProfile(party1withparams1, profile1);
    58                 partyprof2 = new SaopPartyWithProfile(party2withparams1, profile1);
    59                 partyprof3 = new SaopPartyWithProfile(party1withparams1, profile2);
    60                 partyprof4 = new SaopPartyWithProfile(party1withparams2, profile1);
     56                partyprof1 = new OnePartyTeam(party1withparams1, profile1);
     57                partyprof1a = new OnePartyTeam(party1withparams1, profile1);
     58                partyprof2 = new OnePartyTeam(party2withparams1, profile1);
     59                partyprof3 = new OnePartyTeam(party1withparams1, profile2);
     60                partyprof4 = new OnePartyTeam(party1withparams2, profile1);
    6161
    6262        }
    6363
    6464        @Override
    65         public List<List<SaopPartyWithProfile>> getGeneralTestData() {
     65        public List<List<OnePartyTeam>> getGeneralTestData() {
    6666                return Arrays.asList(Arrays.asList(partyprof1, partyprof1a),
    6767                                Arrays.asList(partyprof2), Arrays.asList(partyprof3),
     
    8484        @Test(expected = IllegalArgumentException.class)
    8585        public void nullTest() throws URISyntaxException {
    86                 new SaopPartyWithProfile((PartyWithParameters) null, (ProfileRef) null);
     86                new OnePartyTeam((PartyWithParameters) null, (ProfileRef) null);
    8787        }
    8888
     
    103103                // and therfore can not serialize as TeamOfPartiesAndProfiles
    104104                TeamOfPartiesAndProfiles p = jackson.readValue(serialized,
    105                                 SaopPartyWithProfile.class);
     105                                OnePartyTeam.class);
    106106                System.out.println(p);
    107107                assertEquals(partyprof1, p);
  • protocol/src/test/java/geniusweb/protocol/session/shaop/SHAOPStateTest.java

    r20 r21  
    44import static org.junit.Assert.assertFalse;
    55import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
    76import static org.junit.Assert.assertTrue;
    87import static org.mockito.Mockito.mock;
     
    194193                SHAOPState state = new SHAOPState(actions, connections3, progressrounds,
    195194                                settings, null, 0, null, null);
    196                 assertNull(state.getAgreement());
     195                assertTrue(state.getAgreements().getMap().isEmpty());
    197196        }
    198197
     
    201200                List<Action> actions = Arrays.asList(offer1, accept2);
    202201                SHAOPState state = new SHAOPState(actions, connections4, progressrounds,
    203                                 settings, null, 0, null, null);
    204                 assertNotNull(state.getAgreement());
     202                                settings, null, 0, partynrs, null);
     203                assertFalse(state.getAgreements().getMap().isEmpty());
    205204                assertTrue(state.isFinal(NOW));
    206205        }
     
    211210                SHAOPState state = new SHAOPState(actions, connections3, progressrounds,
    212211                                settings, null, 0, null, null);
    213                 assertNull(state.getAgreement());
     212                assert (state.getAgreements().getMap().isEmpty());
    214213        }
    215214
     
    219218                SHAOPState state = new SHAOPState(actions, connections3, progressrounds,
    220219                                settings, null, 0, null, null);
    221                 assertEquals(null, state.getAgreement());
     220                assertTrue(state.getAgreements().getMap().isEmpty());
    222221        }
    223222
     
    245244                SHAOPState state = new SHAOPState(actions, connections3, progressrounds,
    246245                                settings, null, 0, null, null);
    247                 assertEquals(null, state.getAgreement());
     246                assertTrue(state.getAgreements().getMap().isEmpty());
    248247                assertEquals(null, state.getError());
    249248                assertTrue(state.isFinal(NOW));
     
    254253        public void isProtocolErrorFinal() {
    255254                SHAOPState state = new SHAOPState(actions, connections3, progressrounds,
    256                                 settings, new ProtocolException("test error", "test"), 0, null,
    257                                 null);
     255                                settings,
     256                                new ProtocolException("test error", new PartyId("test")), 0,
     257                                null, null);
    258258                assertTrue(state.isFinal(NOW));
    259259                assertNotNull(state.getError());
  • protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsProtocolTest.java

    r20 r21  
    2020
    2121import geniusweb.events.ProtocolEvent;
    22 import geniusweb.issuevalue.Bid;
     22import geniusweb.inform.Agreements;
    2323import geniusweb.protocol.CurrentNegoState;
    2424import geniusweb.protocol.NegoState;
     
    4444        private final SessionSettings settings = mock(SessionSettings.class);
    4545        private final SessionState finalsessionstate = mock(SessionState.class);
    46         private Bid agreement = mock(Bid.class);
     46        private Agreements agreement = mock(Agreements.class);
    4747        private final long NOW = 1000;
    4848        private SessionResult finalstate = mock(SessionResult.class);
     
    5353                when(finalsessionstate.isFinal(anyLong())).thenReturn(true);
    5454                when(finalsessionstate.getSettings()).thenReturn(settings);
    55                 when(finalsessionstate.getAgreement()).thenReturn(agreement);
     55                when(finalsessionstate.getAgreements()).thenReturn(agreement);
    5656                when(finalsessionstate.getResult()).thenReturn(finalstate);
    57                 when(finalstate.getAgreement()).thenReturn(agreement);
     57                when(finalstate.getAgreements()).thenReturn(agreement);
    5858                when(state.with(any())).thenReturn(newstate);
    5959        }
     
    112112                                .forClass(SessionResult.class);
    113113                verify(state, times(1)).with(argument.capture());
    114                 assertEquals(agreement, argument.getValue().getAgreement());
     114                assertEquals(agreement, argument.getValue().getAgreements());
    115115                assertNull(argument.getValue().getError());
    116116        }
  • protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsStateTest.java

    r20 r21  
    8888                AllPermutationsState state1 = state.with(result);
    8989
    90                 assertEquals(null, state1.getError());
    9190                assertEquals(8, state1.getResults().size());
    9291                assertEquals(toursettings, state1.getSettings());
Note: See TracChangeset for help on using the changeset viewer.