Changeset 24 for events/src
- Timestamp:
- 10/06/20 13:12:20 (4 years ago)
- Location:
- events/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
events/src/main/java/geniusweb/actions/Votes.java
r21 r24 57 57 * with power at most P. 58 58 * 59 * @param otherVotes 59 * @param otherVotes the {@link Votes}, usually from a previous round, that 60 * this should extend. 60 61 * @return true iff this extends the otherVotes. 61 62 */ … … 65 66 for (Vote vote : otherVotes.getVotes()) { 66 67 Vote myvote = getVote(vote.getBid()); 67 if (myvote == null) 68 return false; 69 if (myvote.getMinPower() > vote.getMinPower()) 68 if (myvote == null || myvote.getMinPower() > vote.getMinPower() 69 || myvote.getMaxPower() < vote.getMaxPower()) 70 70 return false; 71 71 } -
events/src/main/java/geniusweb/events/ActionEvent.java
r1 r24 18 18 /** 19 19 * 20 * @param action 20 * @param action the {@link Action} that was done 21 21 * @param time the current time to use. see 22 22 * {@link System#currentTimeMillis()}. -
events/src/main/java/geniusweb/events/NegotiationEvent.java
r1 r24 6 6 import com.fasterxml.jackson.annotation.JsonTypeInfo; 7 7 import com.fasterxml.jackson.annotation.JsonTypeInfo.As; 8 9 import geniusweb.actions.Action; 8 10 9 11 /** -
events/src/main/java/geniusweb/inform/Agreements.java
r21 r24 51 51 52 52 /** 53 * @param bid 54 * @param parties 53 * @param bid a {@link Bid} to be added 54 * @param parties {@link Set} of the {@link PartyId}s that accepted the bid 55 55 * @return new Agreements, with the new bid/parties added. 56 56 */ -
events/src/main/java/geniusweb/inform/Finished.java
r21 r24 15 15 * The session finished (can be for any reason). 16 16 * 17 * @param agreedBid the bid that was finally agreed on; null if no 18 * agreement. 17 * @param agreements the {@link Agreements} that were finally agreed on. 19 18 */ 20 19 @JsonCreator 21 20 public Finished(@JsonProperty("agreements") Agreements agreements) { 21 if (agreements == null) 22 throw new NullPointerException("Agreements can't be null"); 22 23 this.agreements = agreements; 23 24 } -
events/src/main/java/geniusweb/inform/Inform.java
r21 r24 7 7 8 8 /** 9 * base class of all information sent to the {@link Party}9 * base class of all information sent to a Party 10 10 */ 11 11 @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) -
events/src/main/java/geniusweb/inform/Settings.java
r21 r24 2 2 3 3 import java.util.HashMap; 4 import java.util.Map; 4 5 5 6 import com.fasterxml.jackson.annotation.JsonCreator; … … 13 14 14 15 /** 15 * Informs a {@link Party} about all settings for the upcoming negotiation 16 * session. This should be sent to a party one time, so that the party knows the 17 * situation. 16 * Informs a Party about all settings for the upcoming negotiation session. This 17 * should be sent to a party one time, so that the party knows the situation. 18 18 * 19 19 */ … … 31 31 * @param protocol the protocol used in this session 32 32 * @param progress the {@link Progress} object used for this session 33 * @param parameters a Map<String, Object> containing initialization34 * parameters for this party. The Object can be a HashMap,35 * ArrayList, String, or number (Integer, Double, etc).36 * The Object should not be just any Object because37 * deserialization will work only with the mentioned38 * t ypes.33 * @param parameters a {@link Map} <String, Object> containing 34 * initialization parameters for this party. The Object 35 * can be a HashMap, ArrayList, String, or number 36 * (Integer, Double, etc). The Object should not be just 37 * any Object because deserialization will work only with 38 * the mentioned types. 39 39 */ 40 40 @JsonCreator … … 85 85 /** 86 86 * 87 * @return a HashMap<String,Object> containing initialization parameters88 * that can be used by the party.87 * @return a {@link HashMap}<String,Object> containing initialization 88 * parameters that can be used by the party. 89 89 */ 90 90 public HashMap<String, Object> getParameters() { -
events/src/test/java/actions/VotesTest.java
r22 r24 94 94 95 95 @Test 96 public void isExtendingTestLessPower() { 97 Vote powervoteA1 = new Vote(partyA, bid1, 3, 9); 98 Votes powerVotes = new Votes(partyA, Arrays.asList(powervoteA1)); 99 assertFalse(powerVotes.isExtending(votes1)); 100 assertTrue(votes1.isExtending(powerVotes)); 96 public void isExtendingIdenticalVotes() { 97 assertTrue(votes1.isExtending(votes1)); 98 } 99 100 @Test 101 public void isReallyExtendingVotesMin() { 102 Vote powervoteA1 = new Vote(partyA, bid1, 1, 9); 103 Votes powerVotes = new Votes(partyA, 104 Arrays.asList(powervoteA1, voteA2)); 105 assertTrue(powerVotes.isExtending(votes1)); 106 } 107 108 @Test 109 public void isReallyExtendingVotesMax() { 110 Vote powervoteA1 = new Vote(partyA, bid1, 2, 10); 111 Votes powerVotes = new Votes(partyA, 112 Arrays.asList(powervoteA1, voteA2)); 113 assertTrue(powerVotes.isExtending(votes1)); 114 } 115 116 @Test 117 public void IsNarrowingOneVoteRemoved() { 118 Votes narrowVotes = new Votes(partyA, Arrays.asList(voteA2)); 119 assertFalse(narrowVotes.isExtending(votes1)); 120 } 121 122 @Test 123 public void isNarrowingTestMoreMinPower() { 124 Vote narrowVoteA1 = new Vote(partyA, bid1, 3, 9); 125 Votes narrowVotes = new Votes(partyA, 126 Arrays.asList(narrowVoteA1, voteA2)); 127 assertFalse(narrowVotes.isExtending(votes1)); 128 assertTrue(votes1.isExtending(narrowVotes)); 129 } 130 131 @Test 132 public void isNarrowingLessMaxPower() { 133 Vote powervoteA1 = new Vote(partyA, bid1, 2, 8); 134 Votes narrowVotes = new Votes(partyA, 135 Arrays.asList(powervoteA1, voteA2)); 136 assertFalse(narrowVotes.isExtending(votes1)); 137 assertTrue(votes1.isExtending(narrowVotes)); 101 138 } 102 139
Note:
See TracChangeset
for help on using the changeset viewer.