use of tech.cassandre.trading.bot.api.graphql.client.generated.client.AccountsProjectionRoot in project cassandre-trading-bot by cassandre-tech.
the class AccountDataFetcherTest method accounts.
@Test
@DisplayName("accounts: [Account]")
public void accounts() {
// Query and fields definition.
GraphQLQueryRequest graphQLQueryRequest = new GraphQLQueryRequest(new AccountsGraphQLQuery.Builder().build(), new AccountsProjectionRoot().accountId().name());
// Query execution.
List<Account> accounts = dgsQueryExecutor.executeAndExtractJsonPathAsObject(graphQLQueryRequest.serialize(), "data." + DgsConstants.QUERY.Accounts + "[*]", new TypeRef<>() {
});
// Tests.
assertEquals(2, accounts.size());
// Trade account tests.
final Optional<Account> tradeAccount = accounts.stream().filter(account -> "trade".equals(account.getAccountId())).findAny();
assertTrue(tradeAccount.isPresent());
assertEquals("trade", tradeAccount.get().getAccountId());
assertEquals("trade account name", tradeAccount.get().getName());
// Savings account tests.
final Optional<Account> savingsAccount = accounts.stream().filter(account -> "savings".equals(account.getAccountId())).findAny();
assertTrue(savingsAccount.isPresent());
assertEquals("savings", savingsAccount.get().getAccountId());
assertEquals("savings account name", savingsAccount.get().getName());
}
Aggregations