use of com.example.graphql.client.betterbotz.products.UpdateProductsMutation in project stargate by stargate.
the class ApolloTest method updateProducts.
@Test
public void updateProducts() {
ApolloClient client = getApolloClient("/graphql/" + keyspace);
String productId = UUID.randomUUID().toString();
ProductsInput insertInput = ProductsInput.builder().id(productId).name("Shiny Legs").price("3199.99").created(now()).description("Normal legs but shiny.").build();
insertProduct(client, insertInput);
ProductsInput input = ProductsInput.builder().id(productId).name(insertInput.name()).price(insertInput.price()).created(insertInput.created()).description("Normal legs but shiny. Now available in different colors").build();
UpdateProductsMutation mutation = UpdateProductsMutation.builder().value(input).build();
UpdateProductsMutation.Data result = getObservable(client.mutate(mutation));
assertThat(result.getUpdateProducts()).hasValueSatisfying(updateProducts -> {
assertThat(updateProducts.getApplied()).hasValue(true);
assertThat(updateProducts.getValue()).hasValueSatisfying(product -> {
assertThat(product.getId()).hasValue(productId);
assertThat(product.getName()).hasValue(input.name());
assertThat(product.getPrice()).hasValue(input.price());
assertThat(product.getCreated()).hasValue(input.created());
assertThat(product.getDescription()).hasValue(input.description());
});
});
GetProductsWithFilterQuery.Value product = getProduct(client, productId);
assertThat(product.getId()).hasValue(productId);
assertThat(product.getName()).hasValue(input.name());
assertThat(product.getPrice()).hasValue(input.price());
assertThat(product.getCreated()).hasValue(input.created());
assertThat(product.getDescription()).hasValue(input.description());
}
use of com.example.graphql.client.betterbotz.products.UpdateProductsMutation in project stargate by stargate.
the class ApolloTest method updateProductsMissingIfExistsTrue.
@Test
public void updateProductsMissingIfExistsTrue() {
ApolloClient client = getApolloClient("/graphql/" + keyspace);
String productId = UUID.randomUUID().toString();
ProductsInput input = ProductsInput.builder().id(productId).name("Shiny Legs").price("3199.99").created(now()).description("Normal legs but shiny.").build();
UpdateProductsMutation mutation = UpdateProductsMutation.builder().value(input).ifExists(true).build();
UpdateProductsMutation.Data result = getObservable(client.mutate(mutation));
assertThat(result.getUpdateProducts()).hasValueSatisfying(products -> {
assertThat(products.getApplied()).hasValue(false);
assertThat(products.getValue()).hasValueSatisfying(value -> {
assertThat(value.getId()).isEmpty();
assertThat(value.getName()).isEmpty();
assertThat(value.getPrice()).isEmpty();
assertThat(value.getCreated()).isEmpty();
assertThat(value.getDescription()).isEmpty();
});
});
}
Aggregations