Changeset 14 for protocol/src/test/java/geniusweb
- Timestamp:
- 04/28/20 12:56:46 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java
r11 r14 23 23 import geniusweb.references.PartyRef; 24 24 import geniusweb.references.PartyWithParameters; 25 import geniusweb.references.PartyWithProfile;26 25 import geniusweb.references.ProfileRef; 27 26 import tudelft.utilities.junit.GeneralTests; … … 33 32 private final ObjectMapper jackson = new ObjectMapper(); 34 33 35 private final String serialized = "{\"AllPermutationsSettings\":{\" parties\":[{\"partyref\":\"party1\",\"parameters\":{}},{\"partyref\":\"party2\",\"parameters\":{}}],\"reuseParties\":false,\"profiles\":[\"profile1\",\"profile2\",\"profile3\"],\"partiesPerSession\":2,\"sessionsettings\":{\"SAOPSettings\":{\"participants\":[],\"deadline\":{\"deadlinetime\":{\"durationms\":10000}}}}}}";34 private final String serialized = "{\"AllPermutationsSettings\":{\"teams\":[{\"Team\":[{\"partyref\":\"party1\",\"parameters\":{}}]},{\"Team\":[{\"partyref\":\"party2\",\"parameters\":{}}]}],\"profileslists\":[{\"ProfileList\":[\"profile1\"]},{\"ProfileList\":[\"profile2\"]},{\"ProfileList\":[\"profile3\"]}],\"reuseTeams\":false,\"teamsPerSession\":2,\"sessionsettings\":{\"SAOPSettings\":{\"participants\":[],\"deadline\":{\"deadlinetime\":{\"durationms\":10000}}}}}}"; 36 35 private AllPermutationsSettings settings, settings1a, settings2, settings3, 37 36 settings4; 38 37 38 // use directly because there is some hard coding currently. 39 39 private SAOPSettings saopsettings; 40 40 41 41 private ProfileRef profile1, profile2, profile3; 42 43 private List< PartyWithParameters> parties;42 private ProfileList profiles1, profiles2, profiles3; 43 private List<Team> parties; 44 44 45 45 @Before … … 53 53 Parameters params3 = new Parameters(); 54 54 55 PartyWithParameters partywithparams1 = new PartyWithParameters(56 partyref1, params1);57 PartyWithParameters partywithparams2 = new PartyWithParameters(58 partyref2, params2);59 PartyWithParameters partywithparams3 = new PartyWithParameters(60 partyref3, params3);55 Team partywithparams1 = new Team( 56 Arrays.asList(new PartyWithParameters(partyref1, params1))); 57 Team partywithparams2 = new Team( 58 Arrays.asList(new PartyWithParameters(partyref2, params2))); 59 Team partywithparams3 = new Team( 60 Arrays.asList(new PartyWithParameters(partyref3, params3))); 61 61 62 62 parties = Arrays.asList(partywithparams1, partywithparams2); … … 68 68 profile2 = new ProfileRef("profile2"); 69 69 profile3 = new ProfileRef("profile3"); 70 71 List<ProfileRef> profiles = Arrays.asList(profile1, profile2, profile3); 72 73 settings = new AllPermutationsSettings(parties, false, profiles, 2, 74 saopsettings); 75 76 settings1a = new AllPermutationsSettings(parties, false, profiles, 2, 70 ProfileList profiles1 = new ProfileList(Arrays.asList(profile1)); 71 ProfileList profiles2 = new ProfileList(Arrays.asList(profile2)); 72 ProfileList profiles3 = new ProfileList(Arrays.asList(profile3)); 73 74 List<ProfileList> profiles = Arrays.asList(profiles1, profiles2, 75 profiles3); 76 77 settings = new AllPermutationsSettings(parties, profiles, false, 2, 78 saopsettings); 79 80 settings1a = new AllPermutationsSettings(parties, profiles, false, 2, 77 81 saopsettings); 78 82 79 83 settings2 = new AllPermutationsSettings(Arrays.asList(partywithparams1, 80 partywithparams2, partywithparams3), false, profiles, 2,81 saopsettings); 82 83 settings3 = new AllPermutationsSettings(parties, true, profiles, 2,84 saopsettings); 85 86 settings4 = new AllPermutationsSettings(parties, false,87 Arrays.asList(profile 1, profile2, profile3, profile1), 2,88 saopsettings);84 partywithparams2, partywithparams3), profiles, false, 2, 85 saopsettings); 86 87 settings3 = new AllPermutationsSettings(parties, profiles, true, 2, 88 saopsettings); 89 90 settings4 = new AllPermutationsSettings(parties, 91 Arrays.asList(profiles1, profiles2, profiles3, profiles1), 92 false, 2, saopsettings); 89 93 90 94 } … … 131 135 @Test(expected = IllegalArgumentException.class) 132 136 public void testNullParties() { 133 new AllPermutationsSettings(null, true,134 Arrays.asList(profile 1, profile2, profile3, profile1), 2,135 saopsettings);137 new AllPermutationsSettings(null, 138 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 139 2, saopsettings); 136 140 137 141 } … … 139 143 @Test(expected = IllegalArgumentException.class) 140 144 public void testNoParties() { 141 new AllPermutationsSettings(Collections.emptyList(), true,142 Arrays.asList(profile 1, profile2, profile3, profile1), 2,143 saopsettings);145 new AllPermutationsSettings(Collections.emptyList(), 146 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 147 2, saopsettings); 144 148 145 149 } … … 147 151 @Test(expected = IllegalArgumentException.class) 148 152 public void testNullProfiles() { 149 new AllPermutationsSettings(parties, true, null, 2, saopsettings);153 new AllPermutationsSettings(parties, null, true, 2, saopsettings); 150 154 151 155 } … … 153 157 @Test(expected = IllegalArgumentException.class) 154 158 public void testInsufficientProfiles() { 155 new AllPermutationsSettings(parties, true,156 Arrays.asList(profile 1, profile2, profile3, profile1), 4,157 saopsettings);159 new AllPermutationsSettings(parties, 160 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 161 4, saopsettings); 158 162 159 163 } … … 161 165 @Test(expected = IllegalArgumentException.class) 162 166 public void testNullSessionSettings() { 163 new AllPermutationsSettings(parties, true, 164 Arrays.asList(profile1, profile2, profile3, profile1), 4, null); 167 new AllPermutationsSettings(parties, 168 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 169 4, null); 165 170 166 171 } … … 168 173 @Test(expected = IllegalArgumentException.class) 169 174 public void testOnePartyPerSession() { 170 new AllPermutationsSettings(parties, true,171 Arrays.asList(profile 1, profile2, profile3, profile1), 1,172 saopsettings);175 new AllPermutationsSettings(parties, 176 Arrays.asList(profiles1, profiles2, profiles3, profiles1), true, 177 1, saopsettings); 173 178 174 179 } … … 180 185 } 181 186 182 @Test183 public void makeCobTest() throws URISyntaxException {184 // Check that the cob party gets profile without the query part185 String profilebase = "ws://1.2.3.4:8080/profilesserver-a.b.c/websocket/get/someprofile";186 String partybase = "http://131.180.202.213:8080/partiesserver/run/";187 String query = "?a=2&partial=4";188 PartyWithProfile partyprofile = AllPermutationsSettings.makeCob(189 new PartyRef(partybase + AllPermutationsSettings.COB_PARTY),190 new ProfileRef(profilebase + query));191 assertEquals(profilebase,192 partyprofile.getProfile().getURI().toString());193 assertEquals(partybase + AllPermutationsSettings.COB_PARTY,194 partyprofile.getParty().getPartyRef().getURI().toString());195 }187 // @Test 188 // public void makeCobTest() throws URISyntaxException { 189 // // Check that the cob party gets profile without the query part 190 // String profilebase = "ws://1.2.3.4:8080/profilesserver-a.b.c/websocket/get/someprofile"; 191 // String partybase = "http://131.180.202.213:8080/partiesserver/run/"; 192 // String query = "?a=2&partial=4"; 193 // PartyWithProfile partyprofile = AllPermutationsSettings.makeCob( 194 // new PartyRef(partybase + AllPermutationsSettings.COB_PARTY), 195 // new ProfileRef(profilebase + query)); 196 // assertEquals(profilebase, 197 // partyprofile.getProfile().getURI().toString()); 198 // assertEquals(partybase + AllPermutationsSettings.COB_PARTY, 199 // partyprofile.getParty().getPartyRef().getURI().toString()); 200 // } 196 201 197 202 }
Note:
See TracChangeset
for help on using the changeset viewer.