diff --git a/src/it/java/teammates/it/ui/webapi/RejectAccountRequestActionIT.java b/src/it/java/teammates/it/ui/webapi/RejectAccountRequestActionIT.java index 74aba31e1fb..469804b9921 100644 --- a/src/it/java/teammates/it/ui/webapi/RejectAccountRequestActionIT.java +++ b/src/it/java/teammates/it/ui/webapi/RejectAccountRequestActionIT.java @@ -1,7 +1,9 @@ package teammates.it.ui.webapi; +import java.util.List; import java.util.UUID; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -15,7 +17,6 @@ import teammates.common.util.HibernateUtil; import teammates.common.util.SanitizationHelper; import teammates.storage.sqlentity.AccountRequest; -import teammates.storage.sqlentity.Course; import teammates.ui.output.AccountRequestData; import teammates.ui.request.AccountRequestRejectionRequest; import teammates.ui.request.InvalidHttpRequestBodyException; @@ -49,9 +50,7 @@ public class RejectAccountRequestActionIT extends BaseActionIT accountRequests = logic.getAllAccountRequests(); + for (AccountRequest ar : accountRequests) { + logic.deleteAccountRequest(ar.getEmail(), ar.getInstitute()); + } + HibernateUtil.commitTransaction(); } } diff --git a/src/it/java/teammates/it/ui/webapi/UpdateAccountRequestActionIT.java b/src/it/java/teammates/it/ui/webapi/UpdateAccountRequestActionIT.java index 8240421d27a..45ad945c673 100644 --- a/src/it/java/teammates/it/ui/webapi/UpdateAccountRequestActionIT.java +++ b/src/it/java/teammates/it/ui/webapi/UpdateAccountRequestActionIT.java @@ -124,7 +124,7 @@ public void testExecute() throws Exception { InvalidHttpParameterException ihpe = verifyHttpParameterFailure(requestBody, params); - assertEquals("Invalid UUID string: invalid", ihpe.getMessage()); + assertEquals("Expected UUID value for id parameter, but found: [invalid]", ihpe.getMessage()); ______TS("invalid email"); accountRequest = logic.createAccountRequestWithTransaction("name", "email@email.com", diff --git a/src/main/java/teammates/ui/webapi/RejectAccountRequestAction.java b/src/main/java/teammates/ui/webapi/RejectAccountRequestAction.java index 6b0b2534b44..f34d6ea3467 100644 --- a/src/main/java/teammates/ui/webapi/RejectAccountRequestAction.java +++ b/src/main/java/teammates/ui/webapi/RejectAccountRequestAction.java @@ -17,18 +17,17 @@ */ public class RejectAccountRequestAction extends AdminOnlyAction { + @Override + public boolean isTransactionNeeded() { + return false; + } + @Override public JsonResult execute() throws InvalidOperationException, InvalidHttpRequestBodyException { String id = getNonNullRequestParamValue(Const.ParamsNames.ACCOUNT_REQUEST_ID); - UUID accountRequestId; - - try { - accountRequestId = UUID.fromString(id); - } catch (IllegalArgumentException e) { - throw new InvalidHttpParameterException(e.getMessage(), e); - } + UUID accountRequestId = getUuidFromString(Const.ParamsNames.ACCOUNT_REQUEST_ID, id); - AccountRequest accountRequest = sqlLogic.getAccountRequest(accountRequestId); + AccountRequest accountRequest = sqlLogic.getAccountRequestWithTransaction(accountRequestId); if (accountRequest == null) { String errorMessage = String.format(Const.ACCOUNT_REQUEST_NOT_FOUND, accountRequestId.toString()); @@ -41,13 +40,14 @@ public JsonResult execute() throws InvalidOperationException, InvalidHttpRequest try { accountRequest.setStatus(AccountRequestStatus.REJECTED); - accountRequest = sqlLogic.updateAccountRequest(accountRequest); + accountRequest = sqlLogic.updateAccountRequestWithTransaction(accountRequest); if (accountRequestRejectionRequest.checkHasReason() && initialStatus != AccountRequestStatus.REJECTED) { EmailWrapper email = sqlEmailGenerator.generateAccountRequestRejectionEmail(accountRequest, accountRequestRejectionRequest.getReasonTitle(), accountRequestRejectionRequest.getReasonBody()); emailSender.sendEmail(email); } + taskQueuer.scheduleAccountRequestForSearchIndexing(accountRequest.getId().toString()); } catch (InvalidParametersException e) { throw new InvalidHttpRequestBodyException(e); } catch (EntityDoesNotExistException e) { diff --git a/src/main/java/teammates/ui/webapi/UpdateAccountRequestAction.java b/src/main/java/teammates/ui/webapi/UpdateAccountRequestAction.java index 0f1f679be35..c98d925d619 100644 --- a/src/main/java/teammates/ui/webapi/UpdateAccountRequestAction.java +++ b/src/main/java/teammates/ui/webapi/UpdateAccountRequestAction.java @@ -25,13 +25,7 @@ public boolean isTransactionNeeded() { @Override public JsonResult execute() throws InvalidOperationException, InvalidHttpRequestBodyException { String id = getNonNullRequestParamValue(Const.ParamsNames.ACCOUNT_REQUEST_ID); - UUID accountRequestId; - - try { - accountRequestId = UUID.fromString(id); - } catch (IllegalArgumentException e) { - throw new InvalidHttpParameterException(e.getMessage(), e); - } + UUID accountRequestId = getUuidFromString(Const.ParamsNames.ACCOUNT_REQUEST_ID, id); AccountRequest accountRequest = sqlLogic.getAccountRequestWithTransaction(accountRequestId);