Adds random countries when creating users and while entering
verification on the test server interface to get country variance for
statisics
Change-Id: Id6157e2c5690133fa06461d9c019ecd7a1261357
package org.cacert.gigi.dbObjects;
package org.cacert.gigi.dbObjects;
+import java.util.Random;
+
import org.cacert.gigi.GigiApiException;
import org.cacert.gigi.database.GigiPreparedStatement;
import org.cacert.gigi.database.GigiResultSet;
import org.cacert.gigi.GigiApiException;
import org.cacert.gigi.database.GigiPreparedStatement;
import org.cacert.gigi.database.GigiResultSet;
throw new RuntimeException("Internal Error: CountryCode for country not found" + this.getCountry());
}
throw new RuntimeException("Internal Error: CountryCode for country not found" + this.getCountry());
}
+ public static CountryCode getRandomCountry(CountryCodeType cType) {
+ CountryCode[] cc = CountryCode.getCountryCodes(cType);
+ int rnd = new Random().nextInt(cc.length);
+ return cc[rnd];
+ }
+
}
private User createAssurer(int i) throws GigiApiException, IllegalAccessException {
}
private User createAssurer(int i) throws GigiApiException, IllegalAccessException {
- try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?")) {
+ try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?")) {
String mail = "test-assurer" + i + "@example.com";
User u = User.getByEmail(mail);
if (u == null) {
String mail = "test-assurer" + i + "@example.com";
User u = User.getByEmail(mail);
if (u == null) {
ps.setInt(3, 100);
ps.setString(4, "Manager init code");
ps.setString(5, "1990-01-01");
ps.setInt(3, 100);
ps.setString(4, "Manager init code");
ps.setString(5, "1990-01-01");
+ ps.setString(6, CountryCode.getRandomCountry(CountryCode.CountryCodeType.CODE_2_CHARS).getCountryCode());
ps.execute();
}
return u;
ps.execute();
}
return u;
Calendar gc = GregorianCalendar.getInstance();
gc.setTimeInMillis(0);
gc.set(1990, 0, 1);
Calendar gc = GregorianCalendar.getInstance();
gc.setTimeInMillis(0);
gc.set(1990, 0, 1);
- User u = new User(email, "xvXV12°§", new DayDate(gc.getTime().getTime()), Locale.ENGLISH, null, //
- new NamePart(NamePartType.FIRST_NAME, "Först"), new NamePart(NamePartType.FIRST_NAME, "Müddle"),//
+
+ CountryCode country = CountryCode.getRandomCountry(CountryCode.CountryCodeType.CODE_2_CHARS);
+
+ User u = new User(email, "xvXV12°§", new DayDate(gc.getTime().getTime()), Locale.ENGLISH, country, //
+ new NamePart(NamePartType.FIRST_NAME, "Först"), new NamePart(NamePartType.FIRST_NAME, "Müddle"), //
new NamePart(NamePartType.LAST_NAME, "Läst"), new NamePart(NamePartType.SUFFIX, "Süffix"));
EmailAddress ea = u.getEmails()[0];
verify(email, ea);
new NamePart(NamePartType.LAST_NAME, "Läst"), new NamePart(NamePartType.SUFFIX, "Süffix"));
EmailAddress ea = u.getEmails()[0];
verify(email, ea);
if (vp < 10) {
currentVP = vp;
}
if (vp < 10) {
currentVP = vp;
}
- Notary.assure(getAssurer(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
+ Notary.assure(getAssurer(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getRandomCountry(CountryCodeType.CODE_2_CHARS));
agentNumber += 1;
vp -= currentVP;
}
agentNumber += 1;
vp -= currentVP;
}
try {
for (int i = 0; i < 25; i++) {
User a = getAssurer(i);
try {
for (int i = 0; i < 25; i++) {
User a = getAssurer(i);
- Notary.assure(byEmail, a, a.getNames()[0], a.getDoB(), 10, "Testmanager exp up code", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getCountryCode("DE", CountryCodeType.CODE_2_CHARS));
+ Notary.assure(byEmail, a, a.getNames()[0], a.getDoB(), 10, "Testmanager exp up code", "2014-11-06", AssuranceType.FACE_TO_FACE, CountryCode.getRandomCountry(CountryCodeType.CODE_2_CHARS));
}
} catch (GigiApiException e) {
throw new Error(e);
}
} catch (GigiApiException e) {
throw new Error(e);