-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add facade logic method to get an account request by ID * Add storage method to get an account request by ID * Add logic method to get an account request by ID
- Loading branch information
1 parent
5618370
commit 0aa7dfb
Showing
7 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/teammates/sqllogic/core/AccountRequestsLogicTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package teammates.sqllogic.core; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.UUID; | ||
|
||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.AccountRequestStatus; | ||
import teammates.storage.sqlapi.AccountRequestsDb; | ||
import teammates.storage.sqlentity.AccountRequest; | ||
import teammates.test.BaseTestCase; | ||
|
||
/** | ||
* SUT: {@link AccountRequestsLogic}. | ||
*/ | ||
public class AccountRequestsLogicTest extends BaseTestCase { | ||
|
||
private AccountRequestsLogic accountRequestsLogic = AccountRequestsLogic.inst(); | ||
|
||
private AccountRequestsDb accountRequestsDb; | ||
|
||
@BeforeMethod | ||
public void setUpMethod() { | ||
accountRequestsDb = mock(AccountRequestsDb.class); | ||
accountRequestsLogic.initLogicDependencies(accountRequestsDb); | ||
} | ||
|
||
@Test | ||
public void testGetAccountRequest_nonExistentAccountRequest_returnsNull() { | ||
UUID id = UUID.randomUUID(); | ||
when(accountRequestsDb.getAccountRequest(id)).thenReturn(null); | ||
AccountRequest actualAccountRequest = accountRequestsLogic.getAccountRequest(id); | ||
verify(accountRequestsDb).getAccountRequest(id); | ||
assertNull(actualAccountRequest); | ||
} | ||
|
||
@Test | ||
public void testGetAccountRequest_existingAccountRequest_getsSuccessfully() { | ||
AccountRequest expectedAccountRequest = | ||
new AccountRequest("test@gmail.com", "name", "institute", AccountRequestStatus.PENDING, "comments"); | ||
UUID id = expectedAccountRequest.getId(); | ||
when(accountRequestsDb.getAccountRequest(id)).thenReturn(expectedAccountRequest); | ||
AccountRequest actualAccountRequest = accountRequestsLogic.getAccountRequest(id); | ||
verify(accountRequestsDb).getAccountRequest(id); | ||
assertEquals(expectedAccountRequest, actualAccountRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters