Ignore:
Timestamp:
04/28/20 12:56:46 (4 years ago)
Author:
bart
Message:

Release 1.4.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocol/src/test/java/geniusweb/protocol/tournament/allpermutations/AllPermutationsSettingsTest.java

    r11 r14  
    2323import geniusweb.references.PartyRef;
    2424import geniusweb.references.PartyWithParameters;
    25 import geniusweb.references.PartyWithProfile;
    2625import geniusweb.references.ProfileRef;
    2726import tudelft.utilities.junit.GeneralTests;
     
    3332        private final ObjectMapper jackson = new ObjectMapper();
    3433
    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}}}}}}";
    3635        private AllPermutationsSettings settings, settings1a, settings2, settings3,
    3736                        settings4;
    3837
     38        // use directly because there is some hard coding currently.
    3939        private SAOPSettings saopsettings;
    4040
    4141        private ProfileRef profile1, profile2, profile3;
    42 
    43         private List<PartyWithParameters> parties;
     42        private ProfileList profiles1, profiles2, profiles3;
     43        private List<Team> parties;
    4444
    4545        @Before
     
    5353                Parameters params3 = new Parameters();
    5454
    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)));
    6161
    6262                parties = Arrays.asList(partywithparams1, partywithparams2);
     
    6868                profile2 = new ProfileRef("profile2");
    6969                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,
    7781                                saopsettings);
    7882
    7983                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(profile1, 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);
    8993
    9094        }
     
    131135        @Test(expected = IllegalArgumentException.class)
    132136        public void testNullParties() {
    133                 new AllPermutationsSettings(null, true,
    134                                 Arrays.asList(profile1, profile2, profile3, profile1), 2,
    135                                 saopsettings);
     137                new AllPermutationsSettings(null,
     138                                Arrays.asList(profiles1, profiles2, profiles3, profiles1), true,
     139                                2, saopsettings);
    136140
    137141        }
     
    139143        @Test(expected = IllegalArgumentException.class)
    140144        public void testNoParties() {
    141                 new AllPermutationsSettings(Collections.emptyList(), true,
    142                                 Arrays.asList(profile1, profile2, profile3, profile1), 2,
    143                                 saopsettings);
     145                new AllPermutationsSettings(Collections.emptyList(),
     146                                Arrays.asList(profiles1, profiles2, profiles3, profiles1), true,
     147                                2, saopsettings);
    144148
    145149        }
     
    147151        @Test(expected = IllegalArgumentException.class)
    148152        public void testNullProfiles() {
    149                 new AllPermutationsSettings(parties, true, null, 2, saopsettings);
     153                new AllPermutationsSettings(parties, null, true, 2, saopsettings);
    150154
    151155        }
     
    153157        @Test(expected = IllegalArgumentException.class)
    154158        public void testInsufficientProfiles() {
    155                 new AllPermutationsSettings(parties, true,
    156                                 Arrays.asList(profile1, profile2, profile3, profile1), 4,
    157                                 saopsettings);
     159                new AllPermutationsSettings(parties,
     160                                Arrays.asList(profiles1, profiles2, profiles3, profiles1), true,
     161                                4, saopsettings);
    158162
    159163        }
     
    161165        @Test(expected = IllegalArgumentException.class)
    162166        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);
    165170
    166171        }
     
    168173        @Test(expected = IllegalArgumentException.class)
    169174        public void testOnePartyPerSession() {
    170                 new AllPermutationsSettings(parties, true,
    171                                 Arrays.asList(profile1, profile2, profile3, profile1), 1,
    172                                 saopsettings);
     175                new AllPermutationsSettings(parties,
     176                                Arrays.asList(profiles1, profiles2, profiles3, profiles1), true,
     177                                1, saopsettings);
    173178
    174179        }
     
    180185        }
    181186
    182         @Test
    183         public void makeCobTest() throws URISyntaxException {
    184                 // Check that the cob party gets profile without the query part
    185                 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//      }
    196201
    197202}
Note: See TracChangeset for help on using the changeset viewer.