- Timestamp:
- 08/05/20 09:42:15 (4 years ago)
- Location:
- protocol
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/pom.xml
r19 r20 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>protocol</artifactId> 8 <version>1.4. 2</version> <!-- must equal ${geniusweb.version} -->8 <version>1.4.4</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. 2</geniusweb.version>19 <geniusweb.version>1.4.4</geniusweb.version> 20 20 </properties> 21 21 -
protocol/src/main/java/geniusweb/protocol/session/SessionState.java
r11 r20 65 65 */ 66 66 Bid getAgreement(); 67 68 /** 69 * 70 * @return the {@link SessionResult}. Assumes {@link #isFinal(long)}. result 71 * may be undefined if not. 72 */ 73 SessionResult getResult(); 67 74 } -
protocol/src/main/java/geniusweb/protocol/session/saop/SAOPState.java
r10 r20 19 19 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 20 20 import geniusweb.protocol.session.DefaultSessionState; 21 import geniusweb.protocol.session.SessionResult; 21 22 import geniusweb.protocol.session.SessionSettings; 22 23 import geniusweb.references.PartyWithProfile; … … 248 249 } 249 250 251 @Override 252 public SessionResult getResult() { 253 List<Double> emptylist = new LinkedList<>(); 254 for (int n = 0; n < getConnections().size(); n++) 255 emptylist.add(0d); 256 return new SessionResult(getSettings().getAllParties(), getAgreement(), 257 emptylist, getError()); 258 } 259 250 260 } -
protocol/src/main/java/geniusweb/protocol/session/shaop/BareSHAOPState.java
r18 r20 1 1 package geniusweb.protocol.session.shaop; 2 2 3 import java.util.Arrays; 3 4 import java.util.Collections; 4 5 import java.util.LinkedList; … … 13 14 import geniusweb.protocol.ProtocolException; 14 15 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 16 import geniusweb.protocol.session.SessionResult; 15 17 import geniusweb.protocol.session.SessionSettings; 16 18 import geniusweb.protocol.session.SessionState; … … 169 171 170 172 @Override 173 public SessionResult getResult() { 174 Double[] penalties = new Double[partyNumbers.size()]; 175 for (PartyId party : partyNumbers.keySet()) { 176 Double spent = totalSpent.get(party); 177 if (spent == null) { 178 spent = 0d; 179 } else { 180 spent = Math.max(0, Math.min(1.0, spent)); 181 } 182 penalties[partyNumbers.get(party)] = spent; 183 } 184 return new SessionResult(getSettings().getAllParties(), getAgreement(), 185 Arrays.asList(penalties), getError()); 186 187 } 188 189 @Override 171 190 public int hashCode() { 172 191 final int prime = 31; -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsProtocol.java
r10 r20 6 6 import geniusweb.events.TournamentStarted; 7 7 import geniusweb.protocol.CurrentNegoState; 8 import geniusweb.protocol.SessionResult;9 8 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 10 9 import geniusweb.protocol.session.SessionProtocol; 10 import geniusweb.protocol.session.SessionResult; 11 11 import geniusweb.protocol.session.SessionSettings; 12 12 import geniusweb.protocol.session.SessionState; … … 83 83 // List<TeamOfPartiesAndProfiles> participants = 84 84 // sessionstate.getSettings().getParticipants() 85 SessionResult result = new SessionResult( 86 sessionstate.getSettings().getAllParties(), 87 sessionstate.getAgreement(), sessionstate.getError()); 85 SessionResult result = sessionstate.getResult(); 88 86 state = state.with(result); 89 87 notifyListeners(new CurrentNegoState(state)); -
protocol/src/main/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsState.java
r10 r20 6 6 7 7 import geniusweb.protocol.ProtocolException; 8 import geniusweb.protocol. SessionResult;8 import geniusweb.protocol.session.SessionResult; 9 9 import geniusweb.protocol.session.SessionSettings; 10 10 import geniusweb.protocol.tournament.TournamentState; -
protocol/src/test/java/geniusweb/protocol/session/DefaultSessionStateTest.java
r10 r20 139 139 } 140 140 141 @Override 142 public SessionResult getResult() { 143 144 List<Double> emptylist = new LinkedList<>(); 145 for (int n = 0; n < getConnections().size(); n++) 146 emptylist.add(0d); 147 return new SessionResult(getSettings().getAllParties(), getAgreement(), 148 emptylist, getError()); 149 150 } 151 141 152 } -
protocol/src/test/java/geniusweb/protocol/session/SessionResultTest.java
r8 r20 19 19 import geniusweb.issuevalue.DiscreteValue; 20 20 import geniusweb.issuevalue.Value; 21 import geniusweb.protocol.SessionResult;22 21 import geniusweb.references.Parameters; 23 22 import geniusweb.references.PartyRef; … … 32 31 33 32 private final String ISSUE1 = "issue1"; 34 private SessionResult result1, result1a, result2, result3 ;//, result4;33 private SessionResult result1, result1a, result2, result3, result4; 35 34 private String errorstring; // created dynamically: eclipse and maven 36 35 // generate different stacktrace. 37 private String jsonstring = "{\"participants\":[{\"party\":{\"partyref\":\"party1\",\"parameters\":{}},\"profile\":\"profile1\"},{\"party\":{\"partyref\":\"party2\",\"parameters\":{}},\"profile\":\"profile2\"}],\"agreement\":{\"issuevalues\":{\"issue1\":\"a\"}},\"error\":null}"; 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 List<Double> nopenalties = Arrays.asList(0d, 0d); 38 private List<Double> penalties = Arrays.asList(0.1d, 0.2d); 38 39 39 40 @Before … … 63 64 64 65 result1 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2), 65 bid1, n ull);66 bid1, nopenalties, null); 66 67 result1a = new SessionResult( 67 Arrays.asList(partyprofile1, partyprofile2), bid1, null); 68 Arrays.asList(partyprofile1, partyprofile2), bid1, nopenalties, 69 null); 68 70 result2 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2), 69 bid2, n ull);71 bid2, nopenalties, null); 70 72 result3 = new SessionResult(Arrays.asList(partyprofile2, partyprofile1), 71 bid2, null); 73 bid2, nopenalties, null); 74 result4 = new SessionResult(Arrays.asList(partyprofile2, partyprofile1), 75 bid2, penalties, null); 76 72 77 // IGNORE ERROR for now, it fails somewhere deep in maven suddenly. 73 78 // result4 = new SessionResult(Arrays.asList(partyprofile1, … … 78 83 public List<List<SessionResult>> getGeneralTestData() { 79 84 return Arrays.asList(Arrays.asList(result1, result1a), 80 Arrays.asList(result2), Arrays.asList(result3) 81 // ,Arrays.asList(result4) 82 ); 85 Arrays.asList(result2), Arrays.asList(result3), 86 Arrays.asList(result4)); 83 87 } 84 88 … … 86 90 public List<String> getGeneralTestStrings() { 87 91 return Arrays.asList( 88 "SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"a\".* null.",89 "SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"b\".* null.*",90 "SessionResult.*party2.*profile2.*,.*party1.*profile1.*Bid.*issue1=\"b\".* null.*"91 // ,"SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"a\".*null.*"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.*" 92 96 93 97 ); -
protocol/src/test/java/geniusweb/protocol/session/shaop/SHAOPStateTest.java
r18 r20 31 31 import geniusweb.protocol.partyconnection.ProtocolToPartyConn; 32 32 import geniusweb.protocol.partyconnection.ProtocolToPartyConnections; 33 import geniusweb.protocol.session.SessionResult; 33 34 import geniusweb.protocol.session.TeamOfPartiesAndProfiles; 34 35 import tudelft.utilities.junit.GeneralTests; … … 314 315 } 315 316 317 @Test 318 public void getResultTest() { 319 320 Map<PartyId, Double> spent = new HashMap<>(); 321 spent.put(party1, 0.1d); 322 SHAOPState state = new SHAOPState(actions, connections4, 323 new ProgressRounds(10, 0, null), settings, null, 0, partynrs, 324 spent); 325 SessionResult res = state.getResult(); 326 327 } 328 316 329 } -
protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsProtocolTest.java
r10 r20 23 23 import geniusweb.protocol.CurrentNegoState; 24 24 import geniusweb.protocol.NegoState; 25 import geniusweb.protocol.SessionResult;26 25 import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory; 27 26 import geniusweb.protocol.session.SessionProtocol; 27 import geniusweb.protocol.session.SessionResult; 28 28 import geniusweb.protocol.session.SessionSettings; 29 29 import geniusweb.protocol.session.SessionState; … … 46 46 private Bid agreement = mock(Bid.class); 47 47 private final long NOW = 1000; 48 private SessionResult finalstate = mock(SessionResult.class); 48 49 49 50 @Before … … 53 54 when(finalsessionstate.getSettings()).thenReturn(settings); 54 55 when(finalsessionstate.getAgreement()).thenReturn(agreement); 56 when(finalsessionstate.getResult()).thenReturn(finalstate); 57 when(finalstate.getAgreement()).thenReturn(agreement); 55 58 when(state.with(any())).thenReturn(newstate); 56 59 } -
protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsStateTest.java
r10 r20 13 13 import org.junit.Test; 14 14 15 import geniusweb.protocol. SessionResult;15 import geniusweb.protocol.session.SessionResult; 16 16 import geniusweb.protocol.session.SessionSettings; 17 17 import geniusweb.references.PartyWithProfile;
Note:
See TracChangeset
for help on using the changeset viewer.