use of com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery.Products in project stargate by stargate.
the class ApolloTest method queryWithPaging.
@Test
public void queryWithPaging() {
ApolloClient client = getApolloClient("/graphql/" + keyspace);
for (String name : Arrays.asList("a", "b", "c")) {
insertProduct(client, ProductsInput.builder().id(UUID.randomUUID().toString()).name(name).price("1.0").created(now()).build());
}
List<String> names = new ArrayList<>();
Optional<Products> products = Optional.empty();
do {
products = getProducts(client, 1, products.flatMap(r -> r.getPageState()));
products.ifPresent(p -> {
p.getValues().ifPresent(values -> {
for (Value value : values) {
value.getName().ifPresent(names::add);
}
});
});
} while (products.map(p -> p.getValues().map(v -> !v.isEmpty()).orElse(false)).orElse(// Continue if there are still values
false));
assertThat(names).containsExactlyInAnyOrder("a", "b", "c");
}
use of com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery.Products in project stargate by stargate.
the class ApolloTest method shouldSupportMultipleMutationsWithAtomicDirective.
@Test
@DisplayName("Should execute multiple mutations with atomic directive")
public void shouldSupportMultipleMutationsWithAtomicDirective() {
UUID id = UUID.randomUUID();
String productName = "prod " + id;
String customer = "cust " + id;
String price = "123";
String description = "desc " + id;
ApolloClient client = getApolloClient("/graphql/" + keyspace);
ProductsAndOrdersMutation mutation = ProductsAndOrdersMutation.builder().productValue(ProductsInput.builder().id(id.toString()).prodName(productName).price(price).name(productName).customerName(customer).created(now()).description(description).build()).orderValue(OrdersInput.builder().prodName(productName).customerName(customer).price(price).description(description).build()).build();
getObservable(client.mutate(mutation));
assertThat(session.execute(SimpleStatement.newInstance("SELECT * FROM \"Products\" WHERE id = ?", id)).one()).isNotNull().extracting(r -> r.getString("\"prodName\""), r -> r.getString("description")).containsExactly(productName, description);
assertThat(session.execute(SimpleStatement.newInstance("SELECT * FROM \"Orders\" WHERE \"prodName\" = ?", productName)).one()).isNotNull().extracting(r -> r.getString("\"customerName\""), r -> r.getString("description")).containsExactly(customer, description);
}
Aggregations