-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGetIncomeReportTest.java
48 lines (38 loc) · 1.78 KB
/
GetIncomeReportTest.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
package ai.pluggy.client.integration;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Objects;
import org.junit.jupiter.api.Test;
import static ai.pluggy.client.integration.helper.ItemHelper.createPluggyBankItem;
import static ai.pluggy.client.integration.helper.ItemHelper.getItemStatus;
import ai.pluggy.client.integration.util.Poller;
import ai.pluggy.client.response.IncomeReportResponse;
import ai.pluggy.client.response.ItemResponse;
import ai.pluggy.client.response.ItemStatus;
import lombok.SneakyThrows;
import retrofit2.Response;
public class GetIncomeReportTest extends BaseApiIntegrationTest {
@SneakyThrows
@Test
void getIncomeReport_byExistingItemId_ok() {
ItemResponse pluggyBankExecution = createPluggyBankItem(client);
itemsIdCreated.add(pluggyBankExecution.getId());
// poll check of connector item status until it's completed (status: "UPDATED")
Poller.pollRequestUntil(
() -> getItemStatus(client, pluggyBankExecution.getId()),
(ItemResponse itemResponse) -> Objects.equals(itemResponse.getStatus(), ItemStatus.UPDATED),
500, 30000);
// get income report from exising item
Response<IncomeReportResponse> incomeReportResponse = client.service()
.getIncomeReport(pluggyBankExecution.getId())
.execute();
// expect income report response to be valid
assertTrue(incomeReportResponse.isSuccessful());
IncomeReportResponse incomeReport = incomeReportResponse.body();
assertNotNull(incomeReport);
// expect income report to have a valid url
assertNotNull(incomeReport.getResults().get(0).getUrl());
// expect income report to have a valid year
assertNotNull(incomeReport.getResults().get(0).getYear());
}
}