-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGetAccountTest.java
57 lines (46 loc) · 2.04 KB
/
GetAccountTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package ai.pluggy.client.integration;
import static ai.pluggy.client.integration.helper.AccountHelper.getPluggyBankAccounts;
import static ai.pluggy.client.integration.helper.ItemHelper.NON_EXISTING_ITEM_ID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import ai.pluggy.client.response.Account;
import ai.pluggy.client.response.AccountsResponse;
import ai.pluggy.client.response.ErrorResponse;
import java.io.IOException;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;
import retrofit2.Response;
public class GetAccountTest extends BaseApiIntegrationTest {
@Test
void getAccount_nonExistingId_responseError404() throws IOException {
// get account response
Response<Account> getAccountsResponse = client.service()
.getAccount(NON_EXISTING_ITEM_ID)
.execute();
// expect response to not be succesful
assertFalse(getAccountsResponse.isSuccessful());
// expect error response status 404
ErrorResponse errorResponse = client.parseError(getAccountsResponse);
assertNotNull(errorResponse);
assertEquals(errorResponse.getCode(), 404);
}
@SneakyThrows
@Test
void getAccountById_afterExecutionCompleted_responseOk() {
// precondition: run sandbox accounts execution, wait for result, and retrieve it
AccountsResponse pluggyBankAccounts = getPluggyBankAccounts(client, this.getItemsIdCreated());
// get account response
String firstAccountId = pluggyBankAccounts.getResults().get(0).getId();
Response<Account> getAccountResponse = client.service()
.getAccount(firstAccountId)
.execute();
// expect account response to be OK
assertTrue(getAccountResponse.isSuccessful());
Account accountResponse = getAccountResponse.body();
assertNotNull(accountResponse);
// expect account id to match the request id
assertEquals(accountResponse.getId(), firstAccountId);
}
}