Search in sources :

Example 1 with GetOrdersByValueQuery

use of com.example.graphql.client.betterbotz.orders.GetOrdersByValueQuery in project stargate by stargate.

the class ApolloTest method getOrdersByValue.

@Test
public void getOrdersByValue() throws ExecutionException, InterruptedException {
    ApolloClient client = getApolloClient("/graphql/" + keyspace);
    OrdersInput ordersInput = OrdersInput.builder().prodName("Medium Lift Arms").build();
    GetOrdersByValueQuery query = GetOrdersByValueQuery.builder().value(ordersInput).build();
    CompletableFuture<GetOrdersByValueQuery.Data> future = new CompletableFuture<>();
    ApolloQueryCall<Optional<GetOrdersByValueQuery.Data>> observable = client.query(query);
    observable.enqueue(queryCallback(future));
    GetOrdersByValueQuery.Data result = future.get();
    observable.cancel();
    assertThat(result.getOrders()).isPresent();
    GetOrdersByValueQuery.Orders orders = result.getOrders().get();
    assertThat(orders.getValues()).isPresent();
    List<GetOrdersByValueQuery.Value> valuesList = orders.getValues().get();
    GetOrdersByValueQuery.Value value = valuesList.get(0);
    assertThat(value.getId()).hasValue("792d0a56-bb46-4bc2-bc41-5f4a94a83da9");
    assertThat(value.getProdId()).hasValue("31047029-2175-43ce-9fdd-b3d568b19bb2");
    assertThat(value.getProdName()).hasValue("Medium Lift Arms");
    assertThat(value.getCustomerName()).hasValue("Janice Evernathy");
    assertThat(value.getAddress()).hasValue("2101 Everplace Ave 3116");
    assertThat(value.getDescription()).hasValue("Ordering some more arms for my construction bot.");
    assertThat(value.getPrice()).hasValue("3199.99");
    assertThat(value.getSellPrice()).hasValue("3119.99");
}
Also used : GetOrdersByValueQuery(com.example.graphql.client.betterbotz.orders.GetOrdersByValueQuery) Optional(java.util.Optional) ApolloClient(com.apollographql.apollo.ApolloClient) OrdersInput(com.example.graphql.client.betterbotz.type.OrdersInput) CompletableFuture(java.util.concurrent.CompletableFuture) Value(com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery.Value) Test(org.junit.jupiter.api.Test)

Aggregations

ApolloClient (com.apollographql.apollo.ApolloClient)1 GetOrdersByValueQuery (com.example.graphql.client.betterbotz.orders.GetOrdersByValueQuery)1 Value (com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery.Value)1 OrdersInput (com.example.graphql.client.betterbotz.type.OrdersInput)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Test (org.junit.jupiter.api.Test)1