- Timestamp:
- 09/22/20 08:52:04 (4 years ago)
- Location:
- protocol
- Files:
-
- 29 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/pom.xml
r20 r21 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>protocol</artifactId> 8 <version>1. 4.4</version> <!-- must equal ${geniusweb.version} -->8 <version>1.5.0</version> <!-- must equal ${geniusweb.version} --> 9 9 <packaging>jar</packaging> 10 10 … … 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 18 <jackson-2-version>2.9.10</jackson-2-version> 19 <geniusweb.version>1. 4.4</geniusweb.version>19 <geniusweb.version>1.5.0</geniusweb.version> 20 20 </properties> 21 21 … … 28 28 29 29 <dependencies> 30 30 <dependency> 31 <groupId>geniusweb</groupId> 32 <artifactId>issuevalue</artifactId> 33 <version>${geniusweb.version}</version> 34 </dependency> 35 <dependency> 36 <groupId>geniusweb</groupId> 37 <artifactId>voting</artifactId> 38 <version>${geniusweb.version}</version> 39 </dependency> 31 40 <dependency> 32 41 <groupId>geniusweb</groupId> … … 34 43 <version>${geniusweb.version}</version> 35 44 </dependency> 36 <dependency>45 <!-- <dependency> 37 46 <groupId>geniusweb</groupId> 38 47 <artifactId>party</artifactId> 39 48 <version>${geniusweb.version}</version> 40 49 </dependency> 41 <dependency>50 --> <dependency> 42 51 <groupId>geniusweb</groupId> 43 52 <artifactId>references</artifactId> … … 52 61 <groupId>tudelft.utilities</groupId> 53 62 <artifactId>immutablelist</artifactId> 54 <version>1.1. 0</version>63 <version>1.1.1</version> 55 64 </dependency> 56 65 <dependency> -
protocol/src/main/java/geniusweb/protocol/NegoProtocol.java
r9 r21 8 8 9 9 import geniusweb.connection.ConnectionFactory; 10 import geniusweb.deadline.Deadline; 10 11 import geniusweb.events.CurrentState; 11 12 import geniusweb.events.ProtocolEvent; … … 26 27 * {@link #getDescription()}. A protocol reports the progress through its 27 28 * {@link Listenable} interface. <br> 28 * < p>29 * <h2>General information</h2> 29 30 * 30 31 * A protocol is mutable because the incoming connections cause state changes. … … 33 34 * Because a protocol contains an internal state, it can be used only once. 34 35 * <p> 35 * The protocol also needs to keep an eye on the deadline and take appropriate36 * 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.40 36 * <p> 41 37 * The protocol can emit a {@link CurrentState} event at any time. It should do … … 48 44 * {@link #start(SessionSettings, ConnectionFactory)}. 49 45 * 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 * 50 58 */ 51 59 @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE) 52 60 @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) }) 54 63 55 64 public interface NegoProtocol extends Listenable<ProtocolEvent> { … … 64 73 * <p> 65 74 * 66 * All errors are to be handled through {@link SessionState#getError()} except67 * for plain {@link IllegalArgumentException}s. <br>68 * The protocol usually uses the incoming connections to keep running. It does69 * 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. 70 79 * 71 80 * 72 * @param connectionfactory the {@link ProtocolToPartyConnFactory} that allows73 * the protocol to connect with the {@link Reference}s74 * in the settings81 * @param connectionfactory the {@link ProtocolToPartyConnFactory} that 82 * allows the protocol to connect with the 83 * {@link Reference}s in the settings 75 84 */ 76 85 void start(ProtocolToPartyConnFactory connectionfactory); … … 78 87 /** 79 88 * 80 * @return a complete description of how this protocol behaves. Presented to the81 * end users who should know negotiation basics but not all technical82 * te rms.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. 83 92 */ 84 93 String getDescription(); … … 86 95 /** 87 96 * @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. 90 99 */ 91 100 NegoState getState(); … … 98 107 99 108 /** 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. 102 112 * 103 113 * @param party the {@link PartyWithProfile} to be added. -
protocol/src/main/java/geniusweb/protocol/NegoState.java
r1 r21 5 5 import com.fasterxml.jackson.annotation.JsonSubTypes; 6 6 import com.fasterxml.jackson.annotation.JsonSubTypes.Type; 7 import com.fasterxml.jackson.annotation.JsonTypeInfo; 7 8 8 9 import geniusweb.protocol.session.SessionState; 9 10 import geniusweb.protocol.tournament.TournamentState; 10 11 11 import com.fasterxml.jackson.annotation.JsonTypeInfo;12 13 12 /** 14 * The current state of the tournament. Must be serializabl;e so that it can be15 * 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. 16 15 */ 17 16 @JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, isGetterVisibility = Visibility.NONE) … … 36 35 boolean isFinal(long currentTimeMs); 37 36 38 /**39 *40 * @return a fatal error occured during the tournament. returns null if no41 * errors occured.42 */43 ProtocolException getError();44 37 } -
protocol/src/main/java/geniusweb/protocol/ProtocolException.java
r4 r21 2 2 3 3 import geniusweb.actions.PartyId; 4 import geniusweb.party.Party;5 4 import geniusweb.references.PartyRef; 6 5 … … 10 9 */ 11 10 public 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 13 13 14 14 /** … … 17 17 * {@link PartyRef} 18 18 */ 19 public ProtocolException(String message, Stringparty) {19 public ProtocolException(String message, PartyId party) { 20 20 this(message, party, null); 21 21 } … … 30 30 * 31 31 * @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} 34 33 * @param e the cause of the error 35 34 */ 36 public ProtocolException(String message, Stringparty, Throwable e) {35 public ProtocolException(String message, PartyId party, Throwable e) { 37 36 super(party + ":" + message, e, true, false); 38 37 this.party = party; … … 43 42 * @return offending party, either the {@link PartyId} or a {@link PartyRef} 44 43 */ 45 public StringgetParty() {44 public PartyId getParty() { 46 45 return party; 47 46 } -
protocol/src/main/java/geniusweb/protocol/partyconnection/ProtocolToPartyConn.java
r9 r21 4 4 import geniusweb.actions.PartyId; 5 5 import geniusweb.connection.ConnectionEnd; 6 import geniusweb. party.inform.Inform;6 import geniusweb.inform.Inform; 7 7 8 8 /** … … 14 14 /** 15 15 * 16 * @return the partyId of the party that this connects to 16 * @return the partyId of the party that this connects to. 17 17 */ 18 18 PartyId getParty(); -
protocol/src/main/java/geniusweb/protocol/partyconnection/ProtocolToPartyConnFactory.java
r9 r21 6 6 import geniusweb.actions.Action; 7 7 import geniusweb.connection.ConnectionFactory; 8 import geniusweb. party.inform.Inform;8 import geniusweb.inform.Inform; 9 9 import geniusweb.references.Reference; 10 10 import tudelft.utilities.repository.NoResourcesNowException; -
protocol/src/main/java/geniusweb/protocol/partyconnection/ProtocolToPartyConnections.java
r9 r21 9 9 10 10 import geniusweb.actions.PartyId; 11 import geniusweb. party.inform.Inform;11 import geniusweb.inform.Inform; 12 12 13 13 /** 14 14 * Contains all parties with their connections. immutable 15 15 */ 16 public class ProtocolToPartyConnections implements Iterable<ProtocolToPartyConn> { 16 public class ProtocolToPartyConnections 17 implements Iterable<ProtocolToPartyConn> { 17 18 private List<ProtocolToPartyConn> connections; 18 19 -
protocol/src/main/java/geniusweb/protocol/session/DefaultSessionState.java
r10 r21 57 57 * {@link ProtocolException}s. All errors in our own 58 58 * code are bugs (not ProtocolExceptions) and should 59 * result in a throw .59 * result in a throw and terminate the session. 60 60 */ 61 61 public DefaultSessionState(List<Action> actions, … … 130 130 } 131 131 132 @Override133 132 public ProtocolException getError() { 134 133 return error; -
protocol/src/main/java/geniusweb/protocol/session/SessionResult.java
r20 r21 10 10 import com.fasterxml.jackson.annotation.JsonTypeInfo; 11 11 12 import geniusweb.i ssuevalue.Bid;12 import geniusweb.inform.Agreements; 13 13 import geniusweb.references.PartyWithProfile; 14 14 … … 20 20 public class SessionResult { 21 21 private final List<PartyWithProfile> participants; 22 private final Bid agreement;22 private final Agreements agreements; 23 23 private final List<Double> penalties; 24 24 … … 33 33 * never be null. Some of them may have entered later of 34 34 * 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. 37 36 * @param penalties the penalties in [0,1] for each participant, same 38 37 * order as the participants list. … … 48 47 public SessionResult( 49 48 @JsonProperty("participants") List<PartyWithProfile> participants, 50 @JsonProperty("agreement ") Bid agreement,49 @JsonProperty("agreements") Agreements agreements, 51 50 @JsonProperty("penalties") List<Double> penalties, 52 51 @JsonProperty("error") Throwable error) { 53 52 this.participants = participants; 54 this.agreement = agreement;53 this.agreements = agreements; 55 54 this.penalties = penalties; 56 55 this.error = error; … … 69 68 70 69 /** 71 * 8return the final agreement {@link Bid} of the session. Null if no72 * agreement was reached.70 * 8return the final {@link Agreements} of the session. May be empty, not 71 * null 73 72 */ 74 public Bid getAgreement() {75 return agreement ;73 public Agreements getAgreements() { 74 return agreements; 76 75 }; 77 76 … … 99 98 @Override 100 99 public String toString() { 101 return "SessionResult[" + participants + "," + agreement + ","100 return "SessionResult[" + participants + "," + agreements + "," 102 101 + penalties + "," + error + "]"; 103 102 } … … 108 107 int result = 1; 109 108 result = prime * result 110 + ((agreement == null) ? 0 : agreement.hashCode());109 + ((agreements == null) ? 0 : agreements.hashCode()); 111 110 result = prime * result + ((error == null) ? 0 : error.hashCode()); 112 111 result = prime * result … … 126 125 return false; 127 126 SessionResult other = (SessionResult) obj; 128 if (agreement == null) {129 if (other.agreement != null)127 if (agreements == null) { 128 if (other.agreements != null) 130 129 return false; 131 } else if (!agreement .equals(other.agreement))130 } else if (!agreements.equals(other.agreements)) 132 131 return false; 133 132 if (error == null) { -
protocol/src/main/java/geniusweb/protocol/session/SessionSettings.java
r10 r21 6 6 7 7 import geniusweb.protocol.NegoSettings; 8 import geniusweb.protocol.session.amop.AMOPSettings; 9 import geniusweb.protocol.session.mopac.MOPACSettings; 8 10 import geniusweb.protocol.session.saop.SAOPSettings; 9 11 import geniusweb.protocol.session.shaop.SHAOPSettings; … … 15 17 */ 16 18 @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) }) 18 22 public interface SessionSettings extends NegoSettings { 19 23 -
protocol/src/main/java/geniusweb/protocol/session/SessionState.java
r20 r21 6 6 7 7 import geniusweb.actions.Action; 8 import geniusweb.i ssuevalue.Bid;8 import geniusweb.inform.Agreements; 9 9 import geniusweb.progress.Progress; 10 10 import geniusweb.protocol.NegoState; 11 import geniusweb.protocol.session.amop.AMOPState; 12 import geniusweb.protocol.session.mopac.MOPACState; 11 13 import geniusweb.protocol.session.saop.SAOPState; 12 14 import geniusweb.protocol.session.shaop.SHAOPState; … … 35 37 */ 36 38 @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) }) 39 42 public interface SessionState extends NegoState { 40 43 … … 45 48 * 46 49 * @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 48 52 */ 49 53 List<Action> getActions(); … … 64 68 * {@link #isFinal()}. 65 69 */ 66 Bid getAgreement();70 Agreements getAgreements(); 67 71 68 72 /** -
protocol/src/main/java/geniusweb/protocol/session/TeamOfPartiesAndProfiles.java
r10 r21 7 7 import com.fasterxml.jackson.annotation.JsonSubTypes; 8 8 9 import geniusweb.protocol.session.saop.SaopPartyWithProfile;10 9 import geniusweb.protocol.session.shaop.ShaopTeam; 11 10 import geniusweb.references.PartyWithProfile; … … 23 22 // and do not (de)serialize individual TeamOfPartiesAndProfiles. 24 23 //@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) 25 @JsonSubTypes({ @JsonSubTypes.Type(value = SaopPartyWithProfile.class),24 @JsonSubTypes({ @JsonSubTypes.Type(value = OnePartyTeam.class), 26 25 @JsonSubTypes.Type(value = ShaopTeam.class) }) 27 26 public interface TeamOfPartiesAndProfiles { -
protocol/src/main/java/geniusweb/protocol/session/saop/SAOP.java
r10 r21 15 15 import geniusweb.deadline.Deadline; 16 16 import 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;17 import geniusweb.inform.ActionDone; 18 import geniusweb.inform.Finished; 19 import geniusweb.inform.Inform; 20 import geniusweb.inform.Settings; 21 import geniusweb.inform.YourTurn; 22 22 import geniusweb.progress.ProgressFactory; 23 23 import geniusweb.protocol.CurrentNegoState; … … 227 227 } catch (IOException e) { 228 228 throw new ProtocolException("Failed to initialize", 229 connection.getParty() .getName(), e);229 connection.getParty(), e); 230 230 } 231 231 } … … 257 257 * Synchronized so that we always handle only 1 action at a time. 258 258 * 259 * @param partyconn the connection on which the action came in 259 * @param partyconn the connection on which the action came in. 260 260 * @param action the {@link Action} taken by some party 261 261 */ … … 266 266 if (err == null) { 267 267 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); 272 272 return; 273 273 } … … 278 278 throw new ProtocolException( 279 279 "Party acts without having the turn", 280 partyconn.getParty() .getName());280 partyconn.getParty()); 281 281 } 282 282 state.getConnections().broadcast(new ActionDone(action)); … … 286 286 } catch (Throwable e) { 287 287 handleError("failed to handle action " + action, 288 partyconn.getParty() .getName(), e);288 partyconn.getParty(), e); 289 289 } 290 290 … … 301 301 state.getConnections().get(party).send(new YourTurn()); 302 302 } catch (IOException e) { 303 handleError("failed to send YourTurn", party .getName(), e);303 handleError("failed to send YourTurn", party, e); 304 304 } 305 305 } … … 313 313 */ 314 314 private synchronized void handleError(final String message, 315 final Stringparty, final Throwable e) {315 final PartyId party, final Throwable e) { 316 316 if (e instanceof ProtocolException) { 317 317 setState(state.with((ProtocolException) e)); … … 353 353 if (!isFinishedInfoSent.compareAndSet(false, true)) 354 354 return; 355 Inform finished = new Finished(state.getAgreement ());355 Inform finished = new Finished(state.getAgreements()); 356 356 for (ProtocolToPartyConn conn : state.getConnections()) { 357 357 sendFinish(conn, finished); -
protocol/src/main/java/geniusweb/protocol/session/saop/SAOPSettings.java
r10 r21 10 10 11 11 import geniusweb.deadline.Deadline; 12 import geniusweb.protocol.session.OnePartyTeam; 12 13 import geniusweb.protocol.session.SessionProtocol; 13 14 import geniusweb.protocol.session.SessionSettings; … … 17 18 18 19 public class SAOPSettings implements SessionSettings { 19 private final List< SaopPartyWithProfile> participants;20 private final List<OnePartyTeam> participants; 20 21 private final Deadline deadline; 21 22 … … 30 31 @JsonCreator 31 32 public SAOPSettings( 32 @JsonProperty("participants") List< SaopPartyWithProfile> participants,33 @JsonProperty("participants") List<OnePartyTeam> participants, 33 34 @JsonProperty("deadline") Deadline deadline) { 34 35 this.participants = participants; … … 111 112 @Override 112 113 public SessionSettings with(TeamOfPartiesAndProfiles party) { 113 if (!(party instanceof SaopPartyWithProfile))114 if (!(party instanceof OnePartyTeam)) 114 115 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); 119 119 return new SAOPSettings(newparts, deadline); 120 120 } -
protocol/src/main/java/geniusweb/protocol/session/saop/SAOPState.java
r20 r21 6 6 import java.util.List; 7 7 import java.util.Map; 8 import java.util.Set; 9 import java.util.stream.Collectors; 8 10 9 11 import geniusweb.actions.Accept; … … 12 14 import geniusweb.actions.Offer; 13 15 import geniusweb.actions.PartyId; 16 import geniusweb.inform.Agreements; 14 17 import geniusweb.issuevalue.Bid; 15 18 import geniusweb.progress.Progress; … … 113 116 114 117 @Override 115 public Bid getAgreement() { 118 public Agreements getAgreements() { 119 Agreements agree = new Agreements(); 116 120 List<Action> acts = getActions(); 117 121 int nparticipants = getConnections().size(); 118 122 if (nparticipants < 2 || acts.size() < nparticipants) { 119 return null;123 return agree; 120 124 } 121 125 Action offer = acts.get(acts.size() - nparticipants); 122 126 if (!(offer instanceof Offer)) 123 return null;127 return agree; 124 128 Bid bid = ((Offer) offer).getBid(); 125 129 … … 128 132 .allMatch(act -> act instanceof Accept 129 133 && 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()); 131 146 } 132 147 … … 134 149 public boolean isFinal(long currentTimeMs) { 135 150 List<Action> acts = getActions(); 136 return super.isFinal(currentTimeMs) || getAgreement() != null137 || (!acts.isEmpty()151 return super.isFinal(currentTimeMs) 152 || !getAgreements().getMap().isEmpty() || (!acts.isEmpty() 138 153 && acts.get(acts.size() - 1) instanceof EndNegotiation); 139 154 } … … 254 269 for (int n = 0; n < getConnections().size(); n++) 255 270 emptylist.add(0d); 256 return new SessionResult(getSettings().getAllParties(), getAgreement (),271 return new SessionResult(getSettings().getAllParties(), getAgreements(), 257 272 emptylist, getError()); 258 273 } -
protocol/src/main/java/geniusweb/protocol/session/shaop/BareSHAOPState.java
r20 r21 158 158 } 159 159 160 @Override161 160 public ProtocolException getError() { 162 161 return error; … … 182 181 penalties[partyNumbers.get(party)] = spent; 183 182 } 184 return new SessionResult(getSettings().getAllParties(), getAgreement (),183 return new SessionResult(getSettings().getAllParties(), getAgreements(), 185 184 Arrays.asList(penalties), getError()); 186 185 -
protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOP.java
r18 r21 21 21 import geniusweb.deadline.Deadline; 22 22 import 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;23 import geniusweb.inform.ActionDone; 24 import geniusweb.inform.Finished; 25 import geniusweb.inform.Inform; 26 import geniusweb.inform.Settings; 27 import geniusweb.inform.YourTurn; 28 28 import geniusweb.progress.ProgressFactory; 29 29 import geniusweb.protocol.CurrentNegoState; … … 238 238 } catch (IOException e) { 239 239 throw new ProtocolException("Failed to initialize", 240 connection.getParty() .getName(), e);240 connection.getParty(), e); 241 241 } 242 242 } … … 276 276 } catch (Throwable e) { 277 277 handleError("failed to handle action " + action, 278 partyconn.getParty() .getName(), e);278 partyconn.getParty(), e); 279 279 } 280 280 } … … 289 289 290 290 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); 293 292 294 293 // check if action allowed … … 296 295 if (!ALLOWED_ACTIONS.contains(action.getClass())) { 297 296 throw new ProtocolException( 298 "Illegal action for SHAOP Party:" + action, 299 partyid.getName()); 297 "Illegal action for SHAOP Party:" + action, partyid); 300 298 } 301 299 } else { 302 300 if (!(action instanceof Comparison)) 303 301 throw new ProtocolException( 304 "Illegal action for COB Party:" + action, 305 partyid.getName()); 302 "Illegal action for COB Party:" + action, partyid); 306 303 } 307 304 … … 316 313 if (!partyconn.getParty().equals(state.getCurrentTeam())) 317 314 throw new ProtocolException( 318 "Party acts without having the turn", 319 partyid.getName()); 315 "Party acts without having the turn", partyid); 320 316 setState(state.with(partyconn.getParty(), action)); 321 317 state.connections.broadcast(new ActionDone(action)); … … 336 332 state.getConnections().get(party).send(new YourTurn()); 337 333 } catch (IOException e) { 338 handleError("failed to send YourTurn", party .getName(), e);334 handleError("failed to send YourTurn", party, e); 339 335 } 340 336 } … … 348 344 */ 349 345 private synchronized void handleError(final String message, 350 final Stringparty, final Throwable e) {346 final PartyId party, final Throwable e) { 351 347 log.log(Level.WARNING, "SHAOP protocol intercepted error due to party " 352 348 + party + ": " + message, e); … … 388 384 if (!isFinishedInfoSent.compareAndSet(false, true)) 389 385 return; 390 Inform finished = new Finished(state.getAgreement ());386 Inform finished = new Finished(state.getAgreements()); 391 387 state.connections.stream().forEach(conn -> sendFinish(conn, finished)); 392 388 notifyListeners(new CurrentNegoState(state)); -
protocol/src/main/java/geniusweb/protocol/session/shaop/SHAOPState.java
r18 r21 6 6 import java.util.List; 7 7 import java.util.Map; 8 import java.util.Set; 9 import java.util.stream.Collectors; 8 10 9 11 import com.fasterxml.jackson.annotation.JsonCreator; … … 17 19 import geniusweb.actions.Offer; 18 20 import geniusweb.actions.PartyId; 21 import geniusweb.inform.Agreements; 19 22 import geniusweb.issuevalue.Bid; 20 23 import geniusweb.progress.Progress; … … 78 81 /** 79 82 * 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 * 80 92 * @param party a Party Id 81 93 * @return the PartyId of the party (COB and SHAOP are partners) … … 88 100 public boolean isFinal(long currentTimeMs) { 89 101 List<Action> acts = getActions(); 90 return super.isFinal(currentTimeMs) || getAgreement() != null91 || (!acts.isEmpty()102 return super.isFinal(currentTimeMs) 103 || !getAgreements().getMap().isEmpty() || (!acts.isEmpty() 92 104 && acts.get(acts.size() - 1) instanceof EndNegotiation); 93 105 } … … 166 178 167 179 @Override 168 public Bid getAgreement() { 180 public Agreements getAgreements() { 181 Agreements agrees = new Agreements(); 169 182 List<Action> acts = getActions(); 170 183 if (acts.isEmpty()) 171 return null;184 return agrees; 172 185 173 186 int requiredaccepts = getSettings().getTeams().size() - 1; … … 179 192 continue; 180 193 if (requiredaccepts == 0 && act instanceof Offer) 181 return ((Offer) act).getBid();194 return agrees.with(((Offer) act).getBid(), getLeaders()); 182 195 if (!(act instanceof Accept)) 183 return null;196 return agrees; 184 197 requiredaccepts--; 185 198 } 186 return null;199 return agrees; 187 200 } 188 201 -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettings.java
r18 r21 9 9 import com.fasterxml.jackson.annotation.JsonProperty; 10 10 11 import geniusweb.protocol.session.OnePartyTeam; 11 12 import geniusweb.protocol.session.SessionSettings; 12 13 import geniusweb.protocol.session.TeamOfPartiesAndProfiles; 14 import geniusweb.protocol.session.amop.AMOPSettings; 15 import geniusweb.protocol.session.mopac.MOPACSettings; 13 16 import geniusweb.protocol.session.saop.SAOPSettings; 14 import geniusweb.protocol.session.saop.SaopPartyWithProfile;15 17 import geniusweb.protocol.session.shaop.SHAOPSettings; 16 18 import geniusweb.protocol.session.shaop.ShaopTeam; … … 106 108 throw new IllegalArgumentException("nTournaments must be >0"); 107 109 int teamsize; 108 if (sesettings instanceof SAOPSettings) 110 if (sesettings instanceof SAOPSettings 111 || sesettings instanceof MOPACSettings 112 || sesettings instanceof AMOPSettings) 109 113 teamsize = 1; 110 114 else if (sesettings instanceof SHAOPSettings) … … 283 287 public TeamOfPartiesAndProfiles apply(Team team, 284 288 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), 287 293 profilelist.getProfiles().get(0)); 288 294 else if (sessionsettings instanceof SHAOPSettings) { -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsState.java
r20 r21 5 5 import java.util.List; 6 6 7 import geniusweb.protocol.ProtocolException;8 7 import geniusweb.protocol.session.SessionResult; 9 8 import geniusweb.protocol.session.SessionSettings; … … 65 64 } 66 65 67 @Override68 public ProtocolException getError() {69 return null;70 }71 72 66 /** 73 67 * -
protocol/src/test/java/geniusweb/protocol/session/DefaultSessionStateTest.java
r20 r21 23 23 import geniusweb.actions.PartyId; 24 24 import geniusweb.deadline.DeadlineTime; 25 import geniusweb.i ssuevalue.Bid;25 import geniusweb.inform.Agreements; 26 26 import geniusweb.progress.Progress; 27 27 import geniusweb.progress.ProgressTime; … … 29 29 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 30 30 import geniusweb.protocol.session.saop.SAOPSettings; 31 import geniusweb.protocol.session.saop.SaopPartyWithProfile;32 31 import geniusweb.references.Parameters; 33 32 import geniusweb.references.PartyRef; … … 60 59 new PartyRef("party2"), new Parameters()); 61 60 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)); 65 64 SessionSettings settings = new SAOPSettings(participants, deadline); 66 65 ProtocolException e = new ProtocolException("test protocol error", 67 party1 .getName());66 party1); 68 67 HashMap<PartyId, PartyWithProfile> partyprofiles = new HashMap<PartyId, PartyWithProfile>(); 69 68 partyprofiles.put(party1, new PartyWithProfile(party1ref, profile1)); … … 135 134 136 135 @Override 137 public Bid getAgreement() {138 return null;139 }140 141 @Override142 136 public SessionResult getResult() { 143 137 … … 145 139 for (int n = 0; n < getConnections().size(); n++) 146 140 emptylist.add(0d); 147 return new SessionResult(getSettings().getAllParties(), getAgreement (),141 return new SessionResult(getSettings().getAllParties(), getAgreements(), 148 142 emptylist, getError()); 149 143 150 144 } 151 145 146 @Override 147 public Agreements getAgreements() { 148 return new Agreements(); 149 } 150 152 151 } -
protocol/src/test/java/geniusweb/protocol/session/SessionResultTest.java
r20 r21 7 7 import java.util.Arrays; 8 8 import java.util.HashMap; 9 import java.util.HashSet; 9 10 import java.util.List; 10 11 import java.util.Map; … … 16 17 import com.fasterxml.jackson.databind.ObjectMapper; 17 18 19 import geniusweb.actions.PartyId; 20 import geniusweb.inform.Agreements; 18 21 import geniusweb.issuevalue.Bid; 19 22 import geniusweb.issuevalue.DiscreteValue; … … 32 35 private final String ISSUE1 = "issue1"; 33 36 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}"; 37 38 private List<Double> nopenalties = Arrays.asList(0d, 0d); 38 39 private List<Double> penalties = Arrays.asList(0.1d, 0.2d); 39 40 41 private PartyId PARTY1 = new PartyId("party1"); 42 private PartyId PARTY2 = new PartyId("party2"); 43 private PartyId PARTY3 = new PartyId("party3"); 44 40 45 @Before 41 46 public void before() throws URISyntaxException, JsonProcessingException { 42 errorstring = "\"error\":{\"java.lang.RuntimeException\":"47 String errorstring = "\"error\":{\"java.lang.RuntimeException\":" 43 48 + jackson.writeValueAsString(error) + "}"; 44 System.out.println(errorstring);49 // System.out.println(errorstring); 45 50 46 51 PartyWithParameters party1 = new PartyWithParameters( … … 57 62 issuevalues1.put(ISSUE1, new DiscreteValue("a")); 58 63 Bid bid1 = new Bid(issuevalues1); 64 Agreements agreement1 = new Agreements().with(bid1, 65 new HashSet<>(Arrays.asList(PARTY1, PARTY2))); 59 66 60 67 // different order but that shouldn't matter … … 62 69 issuevalues2.put(ISSUE1, new DiscreteValue("b")); 63 70 Bid bid2 = new Bid(issuevalues2); 71 Agreements agreement2 = new Agreements().with(bid2, 72 new HashSet<>(Arrays.asList(PARTY1, PARTY3))); 64 73 65 74 result1 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2), 66 bid1, nopenalties, null);75 agreement1, nopenalties, null); 67 76 result1a = new SessionResult( 68 Arrays.asList(partyprofile1, partyprofile2), bid1, nopenalties,69 n ull);77 Arrays.asList(partyprofile1, partyprofile2), agreement1, 78 nopenalties, null); 70 79 result2 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2), 71 bid2, nopenalties, null);80 agreement2, nopenalties, null); 72 81 result3 = new SessionResult(Arrays.asList(partyprofile2, partyprofile1), 73 bid2, nopenalties, null);82 agreement1, nopenalties, null); 74 83 result4 = new SessionResult(Arrays.asList(partyprofile2, partyprofile1), 75 bid2, penalties, null);84 agreement1, penalties, null); 76 85 77 86 // IGNORE ERROR for now, it fails somewhere deep in maven suddenly. … … 90 99 public List<String> getGeneralTestStrings() { 91 100 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.*" 96 105 97 106 ); -
protocol/src/test/java/geniusweb/protocol/session/saop/SAOPSettingsTest.java
r10 r21 19 19 import geniusweb.deadline.DeadlineRounds; 20 20 import geniusweb.deadline.DeadlineTime; 21 import geniusweb.protocol.session.OnePartyTeam; 21 22 import geniusweb.protocol.session.SessionSettings; 22 23 import geniusweb.references.Parameters; … … 29 30 public class SAOPSettingsTest extends GeneralTests<SAOPSettings> { 30 31 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, 35 36 partyprof2); 36 private List< SaopPartyWithProfile> participants3 = Arrays.asList(partyprof1,37 private List<OnePartyTeam> participants3 = Arrays.asList(partyprof1, 37 38 partyprof2, partyprof3); 38 39 … … 66 67 new PartyRef("http://party2"), new Parameters()); 67 68 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, 73 72 partywithprof2); 74 73 -
protocol/src/test/java/geniusweb/protocol/session/saop/SAOPStateTest.java
r10 r21 176 176 SAOPState state = new SAOPState(actions, connections3, progressrounds, 177 177 settings, null, null); 178 assert Null(state.getAgreement());178 assertTrue(state.getAgreements().getMap().isEmpty()); 179 179 } 180 180 … … 184 184 SAOPState state = new SAOPState(actions, connections3, progressrounds, 185 185 settings, null, null); 186 assert Null(state.getAgreement());186 assertTrue(state.getAgreements().getMap().isEmpty()); 187 187 } 188 188 … … 192 192 SAOPState state = new SAOPState(actions, connections3, progressrounds, 193 193 settings, null, null); 194 assert Null(state.getAgreement());194 assertTrue(state.getAgreements().getMap().isEmpty()); 195 195 } 196 196 … … 200 200 SAOPState state = new SAOPState(actions, connections3, progressrounds, 201 201 settings, null, null); 202 assertEquals(bid1, state.getAgreement ());202 assertEquals(bid1, state.getAgreements().getMap().get(party1)); 203 203 assertTrue(state.isFinal(NOW)); 204 204 } … … 209 209 SAOPState state = new SAOPState(actions, connections3, progressrounds, 210 210 settings, null, null); 211 assert Equals(null, state.getAgreement());211 assertTrue(state.getAgreements().getMap().isEmpty()); 212 212 } 213 213 … … 217 217 SAOPState state = new SAOPState(actions, connections3, progressrounds, 218 218 settings, null, null); 219 assert Equals(null, state.getAgreement());219 assertTrue(state.getAgreements().getMap().isEmpty()); 220 220 } 221 221 … … 246 246 SAOPState state = new SAOPState(actions, connections3, progressrounds, 247 247 settings, null, null); 248 assert Equals(null, state.getAgreement());248 assertTrue(state.getAgreements().getMap().isEmpty()); 249 249 assertEquals(null, state.getError()); 250 250 assertTrue(state.isFinal(NOW)); … … 255 255 public void isProtocolErrorFinal() { 256 256 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"))); 258 259 assertTrue(state.isFinal(NOW)); 259 260 assertNotNull(state.getError()); … … 309 310 assertTrue(state.isFinal(NOW)); 310 311 assertNull(state.getError()); 311 assertEquals(bid1, state.getAgreement ());312 assertEquals(bid1, state.getAgreements().getMap().get(party1)); 312 313 313 314 } … … 325 326 assertTrue(state.isFinal(NOW)); 326 327 assertNull(state.getError()); 327 assertEquals(bid2, state.getAgreement ());328 assertEquals(bid2, state.getAgreements().getMap().get(party1)); 328 329 329 330 } -
protocol/src/test/java/geniusweb/protocol/session/saop/SAOPTest.java
r10 r21 34 34 import geniusweb.events.CurrentState; 35 35 import 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;36 import geniusweb.inform.Finished; 37 import geniusweb.inform.Inform; 38 import geniusweb.inform.Settings; 39 import geniusweb.inform.YourTurn; 40 40 import geniusweb.progress.Progress; 41 41 import geniusweb.protocol.ProtocolException; … … 43 43 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 44 44 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 45 import geniusweb.protocol.session.OnePartyTeam; 45 46 import geniusweb.protocol.session.TeamOfPartiesAndProfiles; 46 47 import geniusweb.references.Parameters; … … 75 76 private final PartyRef party2ref = mock(PartyRef.class); 76 77 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); 79 80 private SAOP saop; 80 81 private ProtocolToPartyConnFactory factory; … … 82 83 private ProtocolToPartyConn conn1 = mock(ProtocolToPartyConn.class), 83 84 conn2 = mock(ProtocolToPartyConn.class); 84 private Map<PartyId, SaopPartyWithProfile> partyprofiles;85 private Map<PartyId, OnePartyTeam> partyprofiles; 85 86 private Progress progress = mock(Progress.class); 86 87 private ProfileRef profile1; -
protocol/src/test/java/geniusweb/protocol/session/saop/SaopPartyWithProfileTest.java
r10 r21 17 17 import com.fasterxml.jackson.databind.ObjectMapper; 18 18 19 import geniusweb.protocol.session.OnePartyTeam; 19 20 import geniusweb.protocol.session.TeamOfPartiesAndProfiles; 20 21 import geniusweb.references.Parameters; … … 24 25 import tudelft.utilities.junit.GeneralTests; 25 26 26 public class SaopPartyWithProfileTest 27 extends GeneralTests<SaopPartyWithProfile> { 27 public class SaopPartyWithProfileTest extends GeneralTests<OnePartyTeam> { 28 28 29 29 private PartyRef party1, party1a, party2, party3; 30 30 private ProfileRef profile1, profile2; 31 private SaopPartyWithProfile partyprof1, partyprof1a, partyprof2,32 partyprof 3, partyprof4;31 private OnePartyTeam partyprof1, partyprof1a, partyprof2, partyprof3, 32 partyprof4; 33 33 private final String serialized = "{\"party\":{\"partyref\":\"ws:party1\",\"parameters\":{}},\"profile\":\"ws:profile1\"}"; 34 34 … … 54 54 settings1); 55 55 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); 61 61 62 62 } 63 63 64 64 @Override 65 public List<List< SaopPartyWithProfile>> getGeneralTestData() {65 public List<List<OnePartyTeam>> getGeneralTestData() { 66 66 return Arrays.asList(Arrays.asList(partyprof1, partyprof1a), 67 67 Arrays.asList(partyprof2), Arrays.asList(partyprof3), … … 84 84 @Test(expected = IllegalArgumentException.class) 85 85 public void nullTest() throws URISyntaxException { 86 new SaopPartyWithProfile((PartyWithParameters) null, (ProfileRef) null);86 new OnePartyTeam((PartyWithParameters) null, (ProfileRef) null); 87 87 } 88 88 … … 103 103 // and therfore can not serialize as TeamOfPartiesAndProfiles 104 104 TeamOfPartiesAndProfiles p = jackson.readValue(serialized, 105 SaopPartyWithProfile.class);105 OnePartyTeam.class); 106 106 System.out.println(p); 107 107 assertEquals(partyprof1, p); -
protocol/src/test/java/geniusweb/protocol/session/shaop/SHAOPStateTest.java
r20 r21 4 4 import static org.junit.Assert.assertFalse; 5 5 import static org.junit.Assert.assertNotNull; 6 import static org.junit.Assert.assertNull;7 6 import static org.junit.Assert.assertTrue; 8 7 import static org.mockito.Mockito.mock; … … 194 193 SHAOPState state = new SHAOPState(actions, connections3, progressrounds, 195 194 settings, null, 0, null, null); 196 assert Null(state.getAgreement());195 assertTrue(state.getAgreements().getMap().isEmpty()); 197 196 } 198 197 … … 201 200 List<Action> actions = Arrays.asList(offer1, accept2); 202 201 SHAOPState state = new SHAOPState(actions, connections4, progressrounds, 203 settings, null, 0, null, null);204 assert NotNull(state.getAgreement());202 settings, null, 0, partynrs, null); 203 assertFalse(state.getAgreements().getMap().isEmpty()); 205 204 assertTrue(state.isFinal(NOW)); 206 205 } … … 211 210 SHAOPState state = new SHAOPState(actions, connections3, progressrounds, 212 211 settings, null, 0, null, null); 213 assert Null(state.getAgreement());212 assert (state.getAgreements().getMap().isEmpty()); 214 213 } 215 214 … … 219 218 SHAOPState state = new SHAOPState(actions, connections3, progressrounds, 220 219 settings, null, 0, null, null); 221 assert Equals(null, state.getAgreement());220 assertTrue(state.getAgreements().getMap().isEmpty()); 222 221 } 223 222 … … 245 244 SHAOPState state = new SHAOPState(actions, connections3, progressrounds, 246 245 settings, null, 0, null, null); 247 assert Equals(null, state.getAgreement());246 assertTrue(state.getAgreements().getMap().isEmpty()); 248 247 assertEquals(null, state.getError()); 249 248 assertTrue(state.isFinal(NOW)); … … 254 253 public void isProtocolErrorFinal() { 255 254 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); 258 258 assertTrue(state.isFinal(NOW)); 259 259 assertNotNull(state.getError()); -
protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsProtocolTest.java
r20 r21 20 20 21 21 import geniusweb.events.ProtocolEvent; 22 import geniusweb.i ssuevalue.Bid;22 import geniusweb.inform.Agreements; 23 23 import geniusweb.protocol.CurrentNegoState; 24 24 import geniusweb.protocol.NegoState; … … 44 44 private final SessionSettings settings = mock(SessionSettings.class); 45 45 private final SessionState finalsessionstate = mock(SessionState.class); 46 private Bid agreement = mock(Bid.class);46 private Agreements agreement = mock(Agreements.class); 47 47 private final long NOW = 1000; 48 48 private SessionResult finalstate = mock(SessionResult.class); … … 53 53 when(finalsessionstate.isFinal(anyLong())).thenReturn(true); 54 54 when(finalsessionstate.getSettings()).thenReturn(settings); 55 when(finalsessionstate.getAgreement ()).thenReturn(agreement);55 when(finalsessionstate.getAgreements()).thenReturn(agreement); 56 56 when(finalsessionstate.getResult()).thenReturn(finalstate); 57 when(finalstate.getAgreement ()).thenReturn(agreement);57 when(finalstate.getAgreements()).thenReturn(agreement); 58 58 when(state.with(any())).thenReturn(newstate); 59 59 } … … 112 112 .forClass(SessionResult.class); 113 113 verify(state, times(1)).with(argument.capture()); 114 assertEquals(agreement, argument.getValue().getAgreement ());114 assertEquals(agreement, argument.getValue().getAgreements()); 115 115 assertNull(argument.getValue().getError()); 116 116 } -
protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsStateTest.java
r20 r21 88 88 AllPermutationsState state1 = state.with(result); 89 89 90 assertEquals(null, state1.getError());91 90 assertEquals(8, state1.getResults().size()); 92 91 assertEquals(toursettings, state1.getSettings());
Note:
See TracChangeset
for help on using the changeset viewer.