+
+ @Test
+ public void testChangeTooYoung() throws IOException {
+ Calendar c = GregorianCalendar.getInstance();
+ c.add(Calendar.YEAR, -User.MINIMUM_AGE);
+ c.add(Calendar.DAY_OF_MONTH, +1);
+ assertNotNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&action=updateDoB", 0));
+ }
+
+ @Test
+ public void testChangeTooOld() throws IOException {
+ Calendar c = GregorianCalendar.getInstance();
+ c.add(Calendar.YEAR, -User.MAXIMUM_PLAUSIBLE_AGE);
+ c.add(Calendar.DAY_OF_MONTH, -1);
+ assertNotNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "day=" + c.get(Calendar.DAY_OF_MONTH) + "&month=" + (c.get(Calendar.MONTH) + 1) + "&year=" + c.get(Calendar.YEAR) + "&action=updateDoB", 0));
+ }
+
+ @Test
+ public void testChangeResidenceCountry() throws IOException {
+ assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "residenceCountry=DE&action=updateResidenceCountry", 0));
+ User user = User.getById(id);
+ assertEquals("DE", user.getResidenceCountry().getCode());
+ }
+
+ @Test
+ public void testChangeResidenceCountryToNull() throws IOException {
+ User user = User.getById(id);
+ assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "residenceCountry=invalid&action=updateResidenceCountry", 0));
+ assertEquals(null, user.getResidenceCountry());
+ }
+
+ @Test
+ public void testModifyUserGroup() throws IOException {
+ User user = User.getById(id);
+ // test add group
+ assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "action=addGroup&groupToModify=" + URLEncoder.encode(Group.LOCATE_AGENT.getDBName(), "UTF-8"), 0));
+
+ user = User.getById(id);
+ user.refreshGroups();
+ assertTrue(user.isInGroup(Group.LOCATE_AGENT));
+
+ // test remove group
+ assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "action=removeGroup&groupToModify=" + URLEncoder.encode(Group.LOCATE_AGENT.getDBName(), "UTF-8"), 0));
+
+ user = User.getById(id);
+ user.refreshGroups();
+ assertFalse(user.isInGroup(Group.LOCATE_AGENT));
+
+ // test add group that only support can add
+ assertNotNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "action=addGroup&groupToModify=" + URLEncoder.encode(Group.SUPPORTER.getDBName(), "UTF-8"), 0));
+
+ user = User.getById(id);
+ user.refreshGroups();
+ assertFalse(user.isInGroup(Group.SUPPORTER));
+
+ // test add invalid group
+ assertNotNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "action=addGroup&groupToModify=non-existing", 0));
+ }