Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#12921] Reintroduce AccountRequest search indexing #12923

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package teammates.it.ui.webapi;

import org.testng.annotations.Test;

import teammates.common.util.Const;
import teammates.common.util.EmailType;
import teammates.common.util.EmailWrapper;
import teammates.storage.sqlentity.AccountRequest;
import teammates.ui.output.JoinLinkData;
import teammates.ui.request.AccountCreateRequest;
import teammates.ui.webapi.CreateAccountRequestAction;
import teammates.ui.webapi.JsonResult;

/**
* SUT: {@link CreateAccountRequestAction}.
*/
public class CreateAccountRequestActionIT extends BaseActionIT<CreateAccountRequestAction> {

@Override
String getActionUri() {
return Const.ResourceURIs.ACCOUNT_REQUEST;
}

@Override
String getRequestMethod() {
return POST;
}

@Override
@Test
protected void testExecute() throws Exception {
// This is a minimal test; other cases are not tested due to upcoming changes in behaviour.
AccountCreateRequest request = new AccountCreateRequest();
request.setInstructorEmail("[email protected]");
request.setInstructorName("Frodo Baggins");
request.setInstructorInstitution("The Fellowship of the Ring");
CreateAccountRequestAction action = getAction(request);
JsonResult result = getJsonResult(action);
JoinLinkData output = (JoinLinkData) result.getOutput();
AccountRequest accountRequest = logic.getAccountRequest("[email protected]", "The Fellowship of the Ring");
assertEquals("[email protected]", accountRequest.getEmail());
assertEquals("Frodo Baggins", accountRequest.getName());
assertEquals("The Fellowship of the Ring", accountRequest.getInstitute());
assertNull(accountRequest.getRegisteredAt());
assertEquals(accountRequest.getRegistrationUrl(), output.getJoinLink());
verifyNumberOfEmailsSent(1);
verifySpecifiedTasksAdded(Const.TaskQueue.SEARCH_INDEXING_QUEUE_NAME, 1);
EmailWrapper emailSent = mockEmailSender.getEmailsSent().get(0);
assertEquals(String.format(EmailType.NEW_INSTRUCTOR_ACCOUNT.getSubject(), "Frodo Baggins"),
emailSent.getSubject());
assertEquals("[email protected]", emailSent.getRecipient());
assertTrue(emailSent.getContent().contains(output.getJoinLink()));
}

@Override
protected void testAccessControl() throws Exception {
// This is not tested due to upcoming changes in behaviour.
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Creates a new account request.
*/
class CreateAccountRequestAction extends AdminOnlyAction {
public class CreateAccountRequestAction extends AdminOnlyAction {

@Override
public JsonResult execute()
Expand All @@ -26,6 +26,7 @@ public JsonResult execute()

try {
accountRequest = sqlLogic.createAccountRequest(instructorName, instructorEmail, instructorInstitution);
taskQueuer.scheduleAccountRequestForSearchIndexing(instructorEmail, instructorInstitution);
} catch (InvalidParametersException ipe) {
throw new InvalidHttpRequestBodyException(ipe);
} catch (EntityAlreadyExistsException eaee) {
Expand Down
Loading