fix: error when adding Verifications Points via Test Manager
authorINOPIAE <m.maengel@inopiae.de>
Mon, 30 Sep 2019 04:33:07 +0000 (06:33 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Wed, 4 Dec 2019 04:59:14 +0000 (05:59 +0100)
fixes issue #86

Change-Id: I4175313ae2f73717b2f857f2e593f0a593d3afcf

util-testing/club/wpia/gigi/pages/Manager.java

index bd90d26..f68d307 100644 (file)
@@ -409,17 +409,43 @@ public class Manager extends Page {
             }
 
             int vp = 0;
+            int verifications = 0;
+            String info = "";
 
             try {
-                vp = Integer.parseInt(verificationPoints);
-            } catch (NumberFormatException e) {
-                resp.getWriter().println("No valid Verification Points entered.</br>");
-                vp = 0;
-            }
+                try {
+                    vp = Integer.parseInt(verificationPoints);
+                } catch (NumberFormatException e) {
+                    resp.getWriter().println("The value for Verification Points must be an integer.</br>");
+                    vp = 0;
+                }
+
+                int agentNumber = addVerificationPoints(vp, byEmail);
+
+                while (vp > 0) {
+                    int currentVP = 10;
+                    if (vp < 10) {
+                        currentVP = vp;
+                    }
+                    if (Notary.checkVerificationIsPossible(getAgent(agentNumber), byEmail.getPreferredName())) {
+
+                        Notary.verify(getAgent(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), VerificationType.FACE_TO_FACE, getRandomCountry());
+                        vp -= currentVP;
+                        verifications += 1;
 
-            int agentNumber = addVerificationPoints(vp, byEmail);
+                    }
+                    agentNumber += 1;
+                    if (agentNumber >= agents.length) {
+                        info = "<br/>The limit of agents is reached. You cannot add any more Verification Points to the preferred name of this user using this method.";
+                        break;
+                    }
+                }
+
+            } catch (GigiApiException e) {
+                throw new Error(e);
+            }
 
-            resp.getWriter().println("User has been verified " + agentNumber + " times.");
+            resp.getWriter().println("User has been verified " + verifications + " times." + info);
 
         } else if (req.getParameter("letverify") != null) {
             String mail = req.getParameter("letverifyEmail");