Search in sources :

Example 1 with DeleteProductsMutation

use of com.example.graphql.client.betterbotz.products.DeleteProductsMutation in project stargate by stargate.

the class ApolloTestBase method cleanupProduct.

private DeleteProductsMutation.Data cleanupProduct(ApolloClient client, Object productId) {
    DeleteProductsMutation mutation = DeleteProductsMutation.builder().value(ProductsInput.builder().id(productId).build()).build();
    DeleteProductsMutation.Data result = getObservable(client.mutate(mutation));
    return result;
}
Also used : DeleteProductsMutation(com.example.graphql.client.betterbotz.products.DeleteProductsMutation)

Example 2 with DeleteProductsMutation

use of com.example.graphql.client.betterbotz.products.DeleteProductsMutation in project stargate by stargate.

the class ApolloTest method deleteProducts.

@Test
public void deleteProducts() {
    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);
    DeleteProductsMutation mutation = DeleteProductsMutation.builder().value(ProductsInput.builder().id(productId).build()).build();
    DeleteProductsMutation.Data result = getObservable(client.mutate(mutation));
    assertThat(result.getDeleteProducts()).hasValueSatisfying(deleteProducts -> {
        assertThat(deleteProducts.getApplied()).hasValue(true);
        assertThat(deleteProducts.getValue()).hasValueSatisfying(product -> {
            assertThat(product.getId()).hasValue(productId);
            assertThat(product.getName()).isEmpty();
            assertThat(product.getPrice()).isEmpty();
            assertThat(product.getCreated()).isEmpty();
            assertThat(product.getDescription()).isEmpty();
        });
    });
    List<Value> remainingProductValues = getProductValues(client, productId);
    assertThat(remainingProductValues).isEmpty();
}
Also used : ApolloClient(com.apollographql.apollo.ApolloClient) DeleteProductsMutation(com.example.graphql.client.betterbotz.products.DeleteProductsMutation) Value(com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery.Value) ProductsInput(com.example.graphql.client.betterbotz.type.ProductsInput) Test(org.junit.jupiter.api.Test)

Example 3 with DeleteProductsMutation

use of com.example.graphql.client.betterbotz.products.DeleteProductsMutation in project stargate by stargate.

the class ApolloTest method deleteProductsIfExistsTrue.

@Test
public void deleteProductsIfExistsTrue() {
    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 deleteInput = ProductsInput.builder().id(productId).name(insertInput.name()).price(insertInput.price()).created(insertInput.created()).build();
    DeleteProductsMutation mutation = DeleteProductsMutation.builder().value(deleteInput).ifExists(true).build();
    DeleteProductsMutation.Data result = getObservable(client.mutate(mutation));
    assertThat(result.getDeleteProducts()).hasValueSatisfying(deleteProducts -> {
        assertThat(deleteProducts.getApplied()).hasValue(true);
    });
}
Also used : ApolloClient(com.apollographql.apollo.ApolloClient) DeleteProductsMutation(com.example.graphql.client.betterbotz.products.DeleteProductsMutation) ProductsInput(com.example.graphql.client.betterbotz.type.ProductsInput) Test(org.junit.jupiter.api.Test)

Aggregations

DeleteProductsMutation (com.example.graphql.client.betterbotz.products.DeleteProductsMutation)3 ApolloClient (com.apollographql.apollo.ApolloClient)2 ProductsInput (com.example.graphql.client.betterbotz.type.ProductsInput)2 Test (org.junit.jupiter.api.Test)2 Value (com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery.Value)1