]> WPIA git - gigi.git/commitdiff
UPD: change "email"-constructor to match the syntax of the
authorFelix Dörre <felix@dogcraft.de>
Thu, 4 Sep 2014 17:57:14 +0000 (19:57 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 4 Sep 2014 17:57:14 +0000 (19:57 +0200)
domain-constructor.

src/org/cacert/gigi/dbObjects/EmailAddress.java
src/org/cacert/gigi/pages/account/MailAddForm.java
src/org/cacert/gigi/pages/main/Signup.java
tests/org/cacert/gigi/TestObjectCache.java
tests/org/cacert/gigi/TestUser.java
tests/org/cacert/gigi/pages/account/TestMailManagement.java
tests/org/cacert/gigi/testUtils/ManagedTest.java
util/org/cacert/gigi/util/DatabaseManager.java

index f0ce010f5ed4fedd559906832c44ff4f04a67de3..2acf59006e257f33fd7cf2f9bb493dbd05e23372 100644 (file)
@@ -37,7 +37,7 @@ public class EmailAddress implements IdCachable {
         rs.close();
     }
 
-    public EmailAddress(String address, User owner) {
+    public EmailAddress(User owner, String address) {
         if ( !EmailProvider.MAIL.matcher(address).matches()) {
             throw new IllegalArgumentException("Invalid email.");
         }
index f36fa35d2c61a0601bdd1f940182ff3092b76b31..ad3344121f654466a035e4b7d7abfc1547698a9d 100644 (file)
@@ -33,7 +33,7 @@ public class MailAddForm extends Form {
         String formMail = req.getParameter("newemail");
         mail = formMail;
         try {
-            EmailAddress addr = new EmailAddress(mail, target);
+            EmailAddress addr = new EmailAddress(target, mail);
             addr.insert(Page.getLanguage(req));
         } catch (IllegalArgumentException e) {
             out.println("<div class='formError'>Error: Invalid address!</div>");
index f62161fa6016a55309e75d09a208d0d4027b2102..55b56b0a57ecc7c41c28589043a20e9127c1d0d2 100644 (file)
@@ -183,7 +183,7 @@ public class Signup extends Form {
             buildup.setDob(myDoB.getDate());
             buildup.insert(password);
             int memid = buildup.getId();
-            EmailAddress ea = new EmailAddress(buildup.getEmail(), buildup);
+            EmailAddress ea = new EmailAddress(buildup, buildup.getEmail());
             ea.insert(Page.getLanguage(req));
 
             PreparedStatement ps = DatabaseConnection.getInstance().prepare("insert into `alerts` set `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?");
index 525469a65f87d8d33092d48be5cf72cf2cb0bb69..c63da92219ec39c67ad15a4b3cdd206bdc53b44a 100644 (file)
@@ -51,7 +51,7 @@ public class TestObjectCache extends ManagedTest {
 
     @Test
     public void testEmailCache() {
-        EmailAddress em = new EmailAddress(createUniqueName() + "@example.org", User.getById(uid));
+        EmailAddress em = new EmailAddress(User.getById(uid), createUniqueName() + "@example.org");
         em.insert(Language.getInstance(Locale.ENGLISH));
 
         assertThat(em, is(sameInstance(EmailAddress.getById(em.getId()))));
index 379f35473cc03abf1a4cf48f06ba4f12ab214dde..30a46b7e66ab41b883a19162db188b039e3cddd4 100644 (file)
@@ -66,8 +66,8 @@ public class TestUser extends ManagedTest {
         int id = createVerifiedUser("aä", "b", uq + "a@email.org", TEST_PASSWORD);
 
         User u = User.getById(id);
-        new EmailAddress(uq + "b@email.org", u).insert(Language.getInstance(Locale.ENGLISH));
-        new EmailAddress(uq + "c@email.org", u).insert(Language.getInstance(Locale.ENGLISH));
+        new EmailAddress(u, uq + "b@email.org").insert(Language.getInstance(Locale.ENGLISH));
+        new EmailAddress(u, uq + "c@email.org").insert(Language.getInstance(Locale.ENGLISH));
         new Domain(u, uq + "a.testdomain.org").insert();
         new Domain(u, uq + "b.testdomain.org").insert();
         new Domain(u, uq + "c.testdomain.org").insert();
index 079b2d0425fb01561324b7b114430fc0f24ed7f4..5ad75a60ee23af66323dce418a27a9b74457766c 100644 (file)
@@ -37,7 +37,7 @@ public class TestMailManagement extends ManagedTest {
     @Test
     public void testMailAddInternalFaulty() {
         try {
-            new EmailAddress("kurti ", u);
+            new EmailAddress(u, "kurti ");
             fail();
         } catch (IllegalArgumentException e) {
             // Intended.
@@ -79,7 +79,7 @@ public class TestMailManagement extends ManagedTest {
 
     @Test
     public void testMailSetDefaultWebUnverified() throws MalformedURLException, UnsupportedEncodingException, IOException, InterruptedException, GigiApiException {
-        EmailAddress adrr = new EmailAddress(createUniqueName() + "test@test.tld", u);
+        EmailAddress adrr = new EmailAddress(u, createUniqueName() + "test@test.tld");
         adrr.insert(Language.getInstance(Locale.ENGLISH));
         assertNotNull(executeBasicWebInteraction(cookie, path, "makedefault&emailid=" + adrr.getId()));
         assertNotEquals(User.getById(u.getId()).getEmail(), adrr.getAddress());
index ab3bfc2344f25973f51b802fed61f650f0c88a30..0c81e370a2e6119d9381215f0225904531c9df92 100644 (file)
@@ -506,7 +506,7 @@ public class ManagedTest {
     }
 
     public static EmailAddress createVerifiedEmail(User u) throws InterruptedException, GigiApiException {
-        EmailAddress adrr = new EmailAddress(createUniqueName() + "test@test.tld", u);
+        EmailAddress adrr = new EmailAddress(u, createUniqueName() + "test@test.tld");
         adrr.insert(Language.getInstance(Locale.ENGLISH));
         TestMail testMail = getMailReciever().recieve();
         assertEquals(adrr.getAddress(), testMail.getTo());
index e5e0b1f056097459dd264fb014fe2ec167016965..c97e2e864631cc67d8a4ec32eed47d76be8554b9 100644 (file)
@@ -36,6 +36,7 @@ public class DatabaseManager {
     public static void run(String[] args, boolean truncate) throws ClassNotFoundException, SQLException, IOException {
         Class.forName(args[0]);
         Connection conn = DriverManager.getConnection(args[1], args[2], args[3]);
+        conn.setAutoCommit(false);
         Statement stmt = conn.createStatement();
         addFile(stmt, new File("doc/tableStructure.sql"), truncate);
         File localData = new File("doc/sampleData.sql");
@@ -43,6 +44,7 @@ public class DatabaseManager {
             addFile(stmt, localData, false);
         }
         stmt.executeBatch();
+        conn.commit();
         stmt.close();
     }