From 2f1ddb5668a70ee79703393b6783c09bbe138ef3 Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Tue, 5 Oct 2021 14:38:42 +0200 Subject: [PATCH 1/5] add querying docs --- build.gradle | 4 +- .../api/models/PagedQueryResourceRequest.java | 45 ++++++ .../commercetools/docs/meta/ClientTuning.java | 48 +++--- .../docs/meta/Compatibility.java | 32 ++-- .../docs/meta/Configuration.java | 55 ++++--- .../commercetools/docs/meta/Endpoints.java | 16 +- .../com/commercetools/docs/meta/Features.java | 90 +++++------ .../docs/meta/GettingStarted.java | 54 +++---- .../com/commercetools/docs/meta/Logging.java | 142 +++++++++--------- .../com/commercetools/docs/meta/Querying.java | 24 +++ .../docs/meta/Serialization.java | 50 +++--- .../com/commercetools/docs/meta/Using.java | 47 +++++- .../src/test/java/example/ExamplesTest.java | 99 ++++++++---- src/main/javadoc/overview.html | 3 +- 14 files changed, 432 insertions(+), 277 deletions(-) create mode 100644 commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java diff --git a/build.gradle b/build.gradle index 5899e3125b0..4951777ab21 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,9 @@ plugins { } configurations { - taglet + taglet { + resolutionStrategy.force("net.sourceforge.plantuml:plantuml:1.2021.10") + } } dependencies { taglet 'com.commercetools.build.taglets:commercetools-taglets:2.1.4' diff --git a/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java index 91df015da99..b9f81fc46dd 100644 --- a/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java +++ b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java @@ -1,6 +1,9 @@ package com.commercetools.api.models; +import java.util.List; +import java.util.Map; + import io.vrap.rmf.base.client.ClientRequestCommand; import io.vrap.rmf.base.client.RequestCommand; @@ -34,10 +37,52 @@ public interface PagedQueryResourceRequest addPredicateVar(final String varName, final String predicateVar); + PagedQueryResourceRequest withPredicateVar(final String varName, final List predicateVar); + + PagedQueryResourceRequest addPredicateVar(final String varName, final List predicateVar); + default PagedQueryResourceRequest asPagedQueryResourceRequest() { return this; } + @SuppressWarnings("unchecked") + default T withWhere(final String where, final String predicateVar, final String predicateVarValue) { + return (T) withWhere(where).withPredicateVar(predicateVar, predicateVarValue); + } + + @SuppressWarnings("unchecked") + default T addWhere(final String where, final String predicateVar, final String predicateVarValue) { + return (T) addWhere(where).withPredicateVar(predicateVar, predicateVarValue); + } + + @SuppressWarnings("unchecked") + default T withWhere(final String where, final Map> predicateVar) { + PagedQueryResourceRequest request = withWhere(where); + predicateVar.forEach(request::withPredicateVar); + return (T) request; + } + + @SuppressWarnings("unchecked") + default T addWhere(final String where, final Map> predicateVar) { + PagedQueryResourceRequest request = addWhere(where); + predicateVar.forEach(request::withPredicateVar); + return (T) request; + } + + @SuppressWarnings("unchecked") + default T withWhere(final String where, final List> predicateVar) { + PagedQueryResourceRequest request = withWhere(where); + predicateVar.forEach(pair -> request.withPredicateVar(pair.getKey(), pair.getValue())); + return (T) request; + } + + @SuppressWarnings("unchecked") + default T addWhere(final String where, final List> predicateVar) { + PagedQueryResourceRequest request = addWhere(where); + predicateVar.forEach(pair -> request.withPredicateVar(pair.getKey(), pair.getValue())); + return (T) request; + } + @SuppressWarnings("unchecked") default T asPagedQueryResourceRequestToBaseType() { return (T) this; diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/ClientTuning.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/ClientTuning.java index 0e9b581a855..91ff38437cd 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/ClientTuning.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/ClientTuning.java @@ -4,30 +4,30 @@ import io.vrap.rmf.base.client.ApiMethod; /** -

Tuning the client

- -

Blocking execution

- -

In a lot of frameworks there is no support for asynchronous execution and so it is necessary to wait for the responses. - The client can wait for responses with the method {@link ApiMethod#executeBlocking()}. This method enforces a timeout for - resilience and throws directly {@link io.vrap.rmf.base.client.ApiHttpException}.

- - {@include.example example.ExamplesTest#executeBlocking()} - -

RetryMiddleware

- -

The {@link io.vrap.rmf.base.client.http.RetryMiddleware} configures a client to handle failures like gateway timeouts - and version conflicts through retrying the request.

- -

A best practice example to retry on gateway timeouts and similar problems

- - {@include.example example.ExamplesTest#retry()} - -

Configure the underlying http client

- -

The {@link com.commercetools.api.defaultconfig.ApiRootBuilder} has create methods which allow to pass a preconfigured HTTP client.

- - {@include.example example.ExamplesTest#proxy()} + *

Tuning the client

+ * + *

Blocking execution

+ * + *

In a lot of frameworks there is no support for asynchronous execution and so it is necessary to wait for the responses. + * The client can wait for responses with the method {@link ApiMethod#executeBlocking()}. This method enforces a timeout for + * resilience and throws directly {@link io.vrap.rmf.base.client.ApiHttpException}.

+ * + * {@include.example example.ExamplesTest#executeBlocking()} + * + *

RetryMiddleware

+ * + *

The {@link io.vrap.rmf.base.client.http.RetryMiddleware} configures a client to handle failures like gateway timeouts + * and version conflicts through retrying the request.

+ * + *

A best practice example to retry on gateway timeouts and similar problems

+ * + * {@include.example example.ExamplesTest#retry()} + * + *

Configure the underlying http client

+ * + *

The {@link com.commercetools.api.defaultconfig.ApiRootBuilder} has create methods which allow to pass a preconfigured HTTP client.

+ * + * {@include.example example.ExamplesTest#proxy()} */ public class ClientTuning { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Compatibility.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Compatibility.java index cb4ef782773..53a48b6dccc 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Compatibility.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Compatibility.java @@ -2,22 +2,22 @@ package com.commercetools.docs.meta; /** -

Compatibility layer for JVM SDK

- -

The module commercetools-sdk-compat-v1 allows the usage of the SDK in conjunction with the JVM SDK (v1)

- -

Using Requests from the JVM SDK (v1)

- -

The {@link com.commercetools.compat.CompatClient} can be used to execute a {@link io.sphere.sdk.client.SphereRequest} - with an {@link io.vrap.rmf.base.client.ApiHttpClient}

- - {@include.example com.commercetools.compat.CompatClientUsageTest} - -

Creating a SphereClient with the v2 SDK

- -

The {@link com.commercetools.compat.CompatSphereClient} acts as a replacement {@link io.sphere.sdk.client.SphereClient} for applications using the JVM SDK (v1).

- - {@include.example com.commercetools.compat.CompatSphereClientUsageTest} + *

Compatibility layer for JVM SDK

+ * + *

The module commercetools-sdk-compat-v1 allows the usage of the SDK in conjunction with the JVM SDK (v1)

+ * + *

Using Requests from the JVM SDK (v1)

+ * + *

The {@link com.commercetools.compat.CompatClient} can be used to execute a {@link io.sphere.sdk.client.SphereRequest} + * with an {@link io.vrap.rmf.base.client.ApiHttpClient}

+ * + * {@include.example com.commercetools.compat.CompatClientUsageTest} + * + *

Creating a SphereClient with the v2 SDK

+ * + *

The {@link com.commercetools.compat.CompatSphereClient} acts as a replacement {@link io.sphere.sdk.client.SphereClient} for applications using the JVM SDK (v1).

+ * + * {@include.example com.commercetools.compat.CompatSphereClientUsageTest} */ public class Compatibility { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Configuration.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Configuration.java index 4a64b1c2c60..a8cbdcb678c 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Configuration.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Configuration.java @@ -2,34 +2,33 @@ package com.commercetools.docs.meta; /** -

Configuration

- -

ApiRoot and ProjectApiRoot

- -

The SDK modules provide an ApiRootBuilder to create an {@link io.vrap.rmf.base.client.ApiHttpClient}. To ease the development - the builder can also create a module specific ApiRoot or ProjectApiRoot. E.g.: {@link com.commercetools.api.client.ApiRoot} - and {@link com.commercetools.api.client.ProjectApiRoot} -

-

Creating http requests starts from the ApiRoot which holds information specific to the project. The following example - shows how to configure an API root and a project scoped root:

- - {@include.example example.ExamplesTest#instance()} - -

Similar configuration to create the root instances for the Import API

- - {@include.example example.ImportExamplesTest#instance()} - -

Custom HTTP client

- -

The builder can be instantiated with a custom {@link io.vrap.rmf.base.client.VrapHttpClient} instance. For example a - specific instance of a client

- - {@include.example example.ExamplesTest#customHttpClient()} - -

This can also be useful to wrap preconfigured clients e.g. with additional middlewares

- - {@include.example example.ExamplesTest#wrappedClient()} - + *

Configuration

+ * + *

ApiRoot and ProjectApiRoot

+ * + *

The SDK modules provide an ApiRootBuilder to create an {@link io.vrap.rmf.base.client.ApiHttpClient}. To ease the development + * the builder can also create a module specific ApiRoot or ProjectApiRoot. E.g.: {@link com.commercetools.api.client.ApiRoot} + * and {@link com.commercetools.api.client.ProjectApiRoot} + *

+ *

Creating http requests starts from the ApiRoot which holds information specific to the project. The following example + * shows how to configure an API root and a project scoped root:

+ * + * {@include.example example.ExamplesTest#instance()} + * + *

Similar configuration to create the root instances for the Import API

+ * + * {@include.example example.ImportExamplesTest#instance()} + * + *

Custom HTTP client

+ * + *

The builder can be instantiated with a custom {@link io.vrap.rmf.base.client.VrapHttpClient} instance. For example a + * specific instance of a client

+ * + * {@include.example example.ExamplesTest#customHttpClient()} + * + *

This can also be useful to wrap preconfigured clients e.g. with additional middlewares

+ * + * {@include.example example.ExamplesTest#wrappedClient()} */ public class Configuration { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Endpoints.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Endpoints.java index 57e881bcbe8..8160acedbcc 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Endpoints.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Endpoints.java @@ -2,14 +2,14 @@ package com.commercetools.docs.meta; /** -

Supported endpoints

- -
    -
  • {@link com.commercetools.api.client.ByProjectKeyRequestBuilder Project API}
  • -
  • {@link com.commercetools.importapi.client.ByProjectKeyRequestBuilder Import API}
  • -
  • {@link com.commercetools.ml.client.ByProjectKeyRequestBuilder Machine learning API}
  • -
  • {@link com.commercetools.history.client.ByProjectKeyRequestBuilder Audit log API}
  • -
+ *

Supported endpoints

+ * + *
    + *
  • {@link com.commercetools.api.client.ByProjectKeyRequestBuilder Project API}
  • + *
  • {@link com.commercetools.importapi.client.ByProjectKeyRequestBuilder Import API}
  • + *
  • {@link com.commercetools.ml.client.ByProjectKeyRequestBuilder Machine learning API}
  • + *
  • {@link com.commercetools.history.client.ByProjectKeyRequestBuilder Audit log API}
  • + *
*/ public class Endpoints { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Features.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Features.java index 54b1402f7ad..343aec0a1d9 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Features.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Features.java @@ -2,51 +2,51 @@ package com.commercetools.docs.meta; /** -

Features

- -

Embracing Java 8

- -

The SDK API uses:

- -
    -
  • {@link java.util.concurrent.CompletionStage}
  • -
  • Java Date API: {@link java.time.ZonedDateTime}, {@link java.time.LocalDate} and {@link java.time.LocalTime}
  • -
  • {@link FunctionalInterface functional interfaces}
  • -
-

Request builders

- -

The SDK provides a request builder which allows to explore the API while writing the program.

- - {@include.example example.ExamplesTest#performRequest()} - -

The request method objects are immutable as shown in this example.

- - {@include.example example.ExamplesTest#immutableRequest()} - -

Good defaults for equals() and hashCode()

- -

The SDK's model implementation classes provide default implementations for the methods.

- -

Client interfaces

- -

The HTTP client abstract itself is a functional interface and can be replaced with test doubles.

- -

Model factory methods

- -

Each model has a factory method {@code ::of()} to create a new empty instance. The method {@code ::builder()} - returns a new builder instance.

- -

Middlewares

- -

The client supports middlewares to adjust request and responses while being executed. - A {@link io.vrap.rmf.base.client.http.Middleware middleware} is a functional interface - which has the request and the next middleware as an argument and returns a CompletableFuture with the response. The following - example shows how to add an additional header.

- - {@include.example example.ExamplesTest#middleware()} - -

The authentication, logging and other functionality has been implemented in middlewares and is added by default to the {@link io.vrap.rmf.base.client.http.HandlerStack} - in the {@link io.vrap.rmf.base.client.ClientBuilder}

+ *

Features

+ * + *

Embracing Java 8

+ * + *

The SDK API uses:

+ * + *
    + *
  • {@link java.util.concurrent.CompletionStage}
  • + *
  • Java Date API: {@link java.time.ZonedDateTime}, {@link java.time.LocalDate} and {@link java.time.LocalTime}
  • + *
  • {@link FunctionalInterface functional interfaces}
  • + *
+ *

Request builders

+ * + *

The SDK provides a request builder which allows to explore the API while writing the program.

+ * + * {@include.example example.ExamplesTest#performRequest()} + * + *

The request method objects are immutable as shown in this example.

+ * + * {@include.example example.ExamplesTest#immutableRequest()} + * + *

Good defaults for equals() and hashCode()

+ * + *

The SDK's model implementation classes provide default implementations for the methods.

+ * + *

Client interfaces

+ * + *

The HTTP client abstract itself is a functional interface and can be replaced with test doubles.

+ * + *

Model factory methods

+ * + *

Each model has a factory method {@code ::of()} to create a new empty instance. The method {@code ::builder()} + * returns a new builder instance.

+ * + *

Middlewares

+ * + *

The client supports middlewares to adjust request and responses while being executed. + * A {@link io.vrap.rmf.base.client.http.Middleware middleware} is a functional interface + * which has the request and the next middleware as an argument and returns a CompletableFuture with the response. The following + * example shows how to add an additional header.

+ * + * {@include.example example.ExamplesTest#middleware()} + * + *

The authentication, logging and other functionality has been implemented in middlewares and is added by default to the {@link io.vrap.rmf.base.client.http.HandlerStack} + * in the {@link io.vrap.rmf.base.client.ClientBuilder}

*/ public class Features { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/GettingStarted.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/GettingStarted.java index f9ef0a5b5ee..1e1f1581a6c 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/GettingStarted.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/GettingStarted.java @@ -2,33 +2,33 @@ package com.commercetools.docs.meta; /** -

About the client

- -

The commercetools platform client communicates asynchronously with the API via HTTPS - and it takes care about authentication.

- -

The client uses Java objects to formulate an HTTP request, performs the request and - maps the JSON response into a Java object. Since the client is thread-safe you need - only one client to perform multiple requests in parallel.

- -

Instantiation

- -

Creating an instance for a project:

- - {@include.example example.ExamplesTest#instance()} - -

Performing requests

- -

A client works on the abstraction level of one HTTP request. - With one client you can start multiple requests in parallel, it is thread-safe.

- -

Example

- - {@include.example example.ExamplesTest#performRequest()} - -

Closing the client

- -

The client holds resources like thread pools and IO connections, so call {@code close()} to release them.

+ *

About the client

+ * + *

The commercetools platform client communicates asynchronously with the API via HTTPS + * and it takes care about authentication.

+ * + *

The client uses Java objects to formulate an HTTP request, performs the request and + * maps the JSON response into a Java object. Since the client is thread-safe you need + * only one client to perform multiple requests in parallel.

+ * + *

Instantiation

+ * + *

Creating an instance for a project:

+ * + * {@include.example example.ExamplesTest#instance()} + * + *

Performing requests

+ * + *

A client works on the abstraction level of one HTTP request. + * With one client you can start multiple requests in parallel, it is thread-safe.

+ * + *

Example

+ * + * {@include.example example.ExamplesTest#performRequest()} + * + *

Closing the client

+ * + *

The client holds resources like thread pools and IO connections, so call {@code close()} to release them.

*/ public class GettingStarted { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Logging.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Logging.java index 94d20a52dab..b55f6f96007 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Logging.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Logging.java @@ -2,77 +2,77 @@ package com.commercetools.docs.meta; /** -

Logging

- -

Internal logging used by the commercetools client itself. Uses slf4j logger named {@code commercetools}.

- -

Logger hierarchy

- -

The loggers form a hierarchy separated by a dot. The root logger is {@code commercetools}.

- -

The child loggers of commercetools are the endpoints, so for example {@code commercetools.categories} for categories and {@code commercetools.product-types} for product types.

- -

The grandchild loggers refer to the action. {@code commercetools.categories.request} refers to performing requests per HTTPS to commercetools for categories, {@code commercetools.categories.response} refers to the responses of the platform.

- -

The logger makes use of different log levels, so for example {@code commercetools.categories.response} logs on debug level the http response from the platform (abbreviated example):

- -
{@code
-    [OkHttp https://api.europe-west1.gcp.commercetools.com/...] DEBUG commercetools.categories.response - io.vrap.rmf.base.client.ApiHttpResponse@33e37acd[statusCode=200,headers=...,textInterpretedBody={"limit":20,"offset":0,"count":4,"total":4,"results":[{"id":"ca7f64dc-ab41-4e7f-b65b-bfc25bf01111","version":1,"createdAt":"2021-01-06T09:21:55.445Z","lastModifiedAt":"2021-01-06T09:21:55.445Z","key":"random-key-15aab6ee-9a48-4fdc-a8c3-8ff9ff390d60","name":{"key-6bc3cc62-1995-43f4":"value-random-string-c3ff7f1a-6371-4c0c-a3b9-5060eca08b8a"},"slug":{"key-6bc3cc62-1995-43f4":"value-random-string-c3ff7f1a-6371-4c0c-a3b9-5060eca08b8a"},"description":{"key-6bc3cc62-1995-43f4":"value-random-string-c3ff7f1a-6371-4c0c-a3b9-5060eca08b8a"},"ancestors":[],"orderHint":"random-string-a99e6941-3225-4766-923a-4a654652532f","externalId":"random-id-100b3851-29b4-47c1-aef3-860b4cd28f54"}]}]
-    }
- -

{@code commercetools.categories.response} logs on trace level additional the formatted http response from the platform (abbreviated example):

- -
{@code
-    [OkHttp https://api.europe-west1.gcp.commercetools.com/...] TRACE commercetools.categories.response - 200
-    {
-      "limit" : 20,
-      "offset" : 0,
-      "count" : 4,
-      "total" : 4,
-      "results" : [ {
-        "id" : "bcb15128-b69e-47b6-81c4-1ea5f9a63b83",
-        "version" : 1,
-        "lastMessageSequenceNumber" : 1,
-        "createdAt" : "2021-01-06T09:21:50.485Z",
-        "lastModifiedAt" : "2021-01-06T09:21:50.485Z",
-        "createdBy" : {
-          "clientId" : "h-QvaF3NpsjPBWeXa6TUOnq0",
-          "isPlatformClient" : false
-        },
-        "key" : "random-key-f45535f5-1111-4bfb-98ac-164234ac2c73",
-        "name" : {
-          "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
-        },
-        "slug" : {
-          "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
-        },
-        "description" : {
-          "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
-        },
-        "ancestors" : [ ],
-        "orderHint" : "random-string-6b88f299-d4ca-491a-9d7c-3463e718c8d2",
-        "externalId" : "random-id-b98a5ab4-5413-40b3-8119-eb5ac2b5afbb",
-        "metaTitle" : {
-          "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
-        },
-        "metaKeywords" : {
-          "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
-        },
-        "metaDescription" : {
-          "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
-        }
-      }, {
-      ...
-      } ]
-    }
-    }
- -

{@code commercetools.products.responses.queries} logs only HTTP GET requests and {@code commercetools.products.responses.commands} logs only HTTP POST/DELETE requests.

- -
{@code
-    [pool-1-thread-1] DEBUG commercetools.products.request.commands - io.vrap.rmf.base.client.ApiHttpRequest@1d2c6948[method=POST,uri="https://api.europe-west1.gcp.commercetools.com/test-php-dev-integration-1/products",headers=[...],textInterpretedBody={"productType":{"id":"cda39953-23af-4e85-abb0-5b89517ec5f2","typeId":"product-type"},"name":{"random-string-b66de021-d2fa-4262-8837-94a6992a8cdc":"random-string-da28a010-e66b-49d4-a18b-f1bfc145d2f6"},...}]
-    [pool-1-thread-1] DEBUG commercetools.products.request.queries - io.vrap.rmf.base.client.ApiHttpRequest@53667fdb[method=GET,uri="https://api.europe-west1.gcp.commercetools.com/test-php-dev-integration-1/products/ef745227-b115-4132-ba2c-4e46db80df79",headers=[...],textInterpretedBody=empty body]
-    }
+ *

Logging

+ * + *

Internal logging used by the commercetools client itself. Uses slf4j logger named {@code commercetools}.

+ * + *

Logger hierarchy

+ * + *

The loggers form a hierarchy separated by a dot. The root logger is {@code commercetools}.

+ * + *

The child loggers of commercetools are the endpoints, so for example {@code commercetools.categories} for categories and {@code commercetools.product-types} for product types.

+ * + *

The grandchild loggers refer to the action. {@code commercetools.categories.request} refers to performing requests per HTTPS to commercetools for categories, {@code commercetools.categories.response} refers to the responses of the platform.

+ * + *

The logger makes use of different log levels, so for example {@code commercetools.categories.response} logs on debug level the http response from the platform (abbreviated example):

+ * + *
{@code
+ * [OkHttp https://api.europe-west1.gcp.commercetools.com/...] DEBUG commercetools.categories.response - io.vrap.rmf.base.client.ApiHttpResponse@33e37acd[statusCode=200,headers=...,textInterpretedBody={"limit":20,"offset":0,"count":4,"total":4,"results":[{"id":"ca7f64dc-ab41-4e7f-b65b-bfc25bf01111","version":1,"createdAt":"2021-01-06T09:21:55.445Z","lastModifiedAt":"2021-01-06T09:21:55.445Z","key":"random-key-15aab6ee-9a48-4fdc-a8c3-8ff9ff390d60","name":{"key-6bc3cc62-1995-43f4":"value-random-string-c3ff7f1a-6371-4c0c-a3b9-5060eca08b8a"},"slug":{"key-6bc3cc62-1995-43f4":"value-random-string-c3ff7f1a-6371-4c0c-a3b9-5060eca08b8a"},"description":{"key-6bc3cc62-1995-43f4":"value-random-string-c3ff7f1a-6371-4c0c-a3b9-5060eca08b8a"},"ancestors":[],"orderHint":"random-string-a99e6941-3225-4766-923a-4a654652532f","externalId":"random-id-100b3851-29b4-47c1-aef3-860b4cd28f54"}]}]
+ * }
+ * + *

{@code commercetools.categories.response} logs on trace level additional the formatted http response from the platform (abbreviated example):

+ * + *
{@code
+ * [OkHttp https://api.europe-west1.gcp.commercetools.com/...] TRACE commercetools.categories.response - 200
+ * {
+ *   "limit" : 20,
+ *   "offset" : 0,
+ *   "count" : 4,
+ *   "total" : 4,
+ *   "results" : [ {
+ *     "id" : "bcb15128-b69e-47b6-81c4-1ea5f9a63b83",
+ *     "version" : 1,
+ *     "lastMessageSequenceNumber" : 1,
+ *     "createdAt" : "2021-01-06T09:21:50.485Z",
+ *     "lastModifiedAt" : "2021-01-06T09:21:50.485Z",
+ *     "createdBy" : {
+ *       "clientId" : "h-QvaF3NpsjPBWeXa6TUOnq0",
+ *       "isPlatformClient" : false
+ *     },
+ *     "key" : "random-key-f45535f5-1111-4bfb-98ac-164234ac2c73",
+ *     "name" : {
+ *       "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
+ *     },
+ *     "slug" : {
+ *       "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
+ *     },
+ *     "description" : {
+ *       "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
+ *     },
+ *     "ancestors" : [ ],
+ *     "orderHint" : "random-string-6b88f299-d4ca-491a-9d7c-3463e718c8d2",
+ *     "externalId" : "random-id-b98a5ab4-5413-40b3-8119-eb5ac2b5afbb",
+ *     "metaTitle" : {
+ *       "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
+ *     },
+ *     "metaKeywords" : {
+ *       "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
+ *     },
+ *     "metaDescription" : {
+ *       "key-b7d87008-9526-47b3-8b80" : "value-random-string-baf1a1ae-3726-4573-bec5-2c53c7d1114a"
+ *     }
+ *   }, {
+ *   ...
+ *   } ]
+ * }
+ * }
+ * + *

{@code commercetools.products.responses.queries} logs only HTTP GET requests and {@code commercetools.products.responses.commands} logs only HTTP POST/DELETE requests.

+ * + *
{@code
+ * [pool-1-thread-1] DEBUG commercetools.products.request.commands - io.vrap.rmf.base.client.ApiHttpRequest@1d2c6948[method=POST,uri="https://api.europe-west1.gcp.commercetools.com/test-php-dev-integration-1/products",headers=[...],textInterpretedBody={"productType":{"id":"cda39953-23af-4e85-abb0-5b89517ec5f2","typeId":"product-type"},"name":{"random-string-b66de021-d2fa-4262-8837-94a6992a8cdc":"random-string-da28a010-e66b-49d4-a18b-f1bfc145d2f6"},...}]
+ * [pool-1-thread-1] DEBUG commercetools.products.request.queries - io.vrap.rmf.base.client.ApiHttpRequest@53667fdb[method=GET,uri="https://api.europe-west1.gcp.commercetools.com/test-php-dev-integration-1/products/ef745227-b115-4132-ba2c-4e46db80df79",headers=[...],textInterpretedBody=empty body]
+ * }
*/ public class Logging { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java new file mode 100644 index 00000000000..4276d791feb --- /dev/null +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java @@ -0,0 +1,24 @@ + +package com.commercetools.docs.meta; + +/** + *

Querying the API

+ * + *

Predicates

+ * + *

The platform allows the use of predicates when + * querying the API. Predicates are added as query parameter string to the request itself. The following example shows + * the usage of input variables

+ * + * {@include.example example.ExamplesTest#queryPredicateVariable()} + * + * It's also possible to use array values in predicates in case of a varying number of parameters + * + * {@include.example example.ExamplesTest#queryPredicateVariableArray()} + * + *

Get by id/key

+ * + * {@include.example example.ExamplesTest#getByIdOrKey()} + */ +public class Querying { +} diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Serialization.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Serialization.java index 96dcf480420..37b4cc4baa2 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Serialization.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Serialization.java @@ -4,31 +4,31 @@ import io.vrap.rmf.base.client.utils.json.modules.ModuleOptions; /** -

Serialization

- -

The SDK uses Jackson for searializing and deserializing JSON. - The default configured {@link com.fasterxml.jackson.databind.ObjectMapper} uses some modules to correctly work with our API. - The details can be found in {@link io.vrap.rmf.base.client.utils.json.JsonUtils#createObjectMapper(ModuleOptions)}

- -

Customization

- -

To allow customization of the ObjectMapper the SDK uses {@link java.util.ServiceLoader} for - {@link io.vrap.rmf.base.client.utils.json.ModuleSupplier}. Adding a file - resources/META-INF/services/io.vrap.rmf.base.client.utils.json.ModuleSupplier to your project - with FQCN of the module supplier to be used will register the supplied modules

- -

E.g.: - {@include.file commercetools/commercetools-sdk-java-api/src/main/resources/META-INF/services/io.vrap.rmf.base.client.utils.json.ModuleSupplier} - {@include.file commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/json/ApiModule.java} -

- -

Date and time attributes

- -

When using Date, Time and DateTime types for product attributes or custom fields the SDK deserializes them as {@link java.time.LocalDate}, - {@link java.time.LocalTime} and {@link java.time.ZonedDateTime}. As sometimes it may needed to serialize them as {@link String} the ObjectMapper - can be configured with {@link ModuleOptions}. The {@link com.commercetools.api.json.ApiModule} also is loading the configuration options - using {@link System#getProperty(String)} e.g.: {@link com.commercetools.api.json.ApiModuleOptions#DESERIALIZE_DATE_ATTRIBUTE_AS_STRING commercetools.deserializeDateAttributeAsString}

- {@include.example example.SerializationTest#dateAsString()} + *

Serialization

+ * + *

The SDK uses Jackson for searializing and deserializing JSON. + * The default configured {@link com.fasterxml.jackson.databind.ObjectMapper} uses some modules to correctly work with our API. + * The details can be found in {@link io.vrap.rmf.base.client.utils.json.JsonUtils#createObjectMapper(ModuleOptions)}

+ * + *

Customization

+ * + *

To allow customization of the ObjectMapper the SDK uses {@link java.util.ServiceLoader} for + * {@link io.vrap.rmf.base.client.utils.json.ModuleSupplier}. Adding a file + * resources/META-INF/services/io.vrap.rmf.base.client.utils.json.ModuleSupplier to your project + * with FQCN of the module supplier to be used will register the supplied modules

+ * + *

E.g.: + * {@include.file commercetools/commercetools-sdk-java-api/src/main/resources/META-INF/services/io.vrap.rmf.base.client.utils.json.ModuleSupplier} + * {@include.file commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/json/ApiModule.java} + *

+ * + *

Date and time attributes

+ * + *

When using Date, Time and DateTime types for product attributes or custom fields the SDK deserializes them as {@link java.time.LocalDate}, + * {@link java.time.LocalTime} and {@link java.time.ZonedDateTime}. As sometimes it may needed to serialize them as {@link String} the ObjectMapper + * can be configured with {@link ModuleOptions}. The {@link com.commercetools.api.json.ApiModule} also is loading the configuration options + * using {@link System#getProperty(String)} e.g.: {@link com.commercetools.api.json.ApiModuleOptions#DESERIALIZE_DATE_ATTRIBUTE_AS_STRING commercetools.deserializeDateAttributeAsString}

+ * {@include.example example.SerializationTest#dateAsString()}

*/ public class Serialization { } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Using.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Using.java index 7ac584f0145..3cdb75cba05 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Using.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Using.java @@ -1,12 +1,49 @@ package com.commercetools.docs.meta; -/** -

Using SDK

- -

SDK follows a builder pattern when creating requests and model entities. Category resource will be used to demonstrate how to use the SDK. This behaviour is the same for all resources.

+import io.vrap.rmf.base.client.ApiMethod; - {@include.example example.ExamplesTest#usage()} +/** + *

Using SDK

+ * + *

SDK follows a builder pattern when creating requests and model entities. Category resource will be used to demonstrate + * how to use the SDK. This behaviour is the same for all resources.

+ * + *

Models and Builders

+ * + *

Models are defined as interfaces. For each model a {@link io.vrap.rmf.base.client.Builder} class exists which builds + * the implementation class of a model. The model builder has a build method which checks that required properties + * have been set. The buildUnchecked method creates a new instance without checking for required properties

+ * + * Classes of a model + * + * {@include.example example.ExamplesTest#draftBuilder()} + * + *

Request DSL

+ * + *

Building request can be done with the help of an ApiRoot, e.g. {@link com.commercetools.api.client.ProjectApiRoot}. + * The DSL mirrors the directory structure and HTTP methods of the API and allows navigating and discovering the commercetools + * API while typing. The HTTP method builders includes methods for every query parameter. Additionally there are + * the {@link ApiMethod#execute()} and {@link ApiMethod#executeBlocking()} methods which are sending the request using the + * configured {@link io.vrap.rmf.base.client.ApiHttpClient} and mapping the result to the correct response class. In case + * the raw JSON is needed {@link ApiMethod#send()} and {@link ApiMethod#sendBlocking()} will return an {@link io.vrap.rmf.base.client.ApiHttpResponse} + * with the byte array.

+ * + * {@include.example example.ExamplesTest#usage()} + * + * @startuml model-classes.svg + * interface Model + * class ModelImpl implements Model + * class ModelBuilder> + * ModelBuilder : Model build() + * note right of ModelBuilder::build + * method checks required properties + * have been set + * endnote + * ModelBuilder : Model buildUnchecked() + * ModelImpl <-- ModelBuilder::build + * ModelImpl <-- ModelBuilder::buildUnchecked + * @enduml */ public class Using { } diff --git a/commercetools/internal-docs/src/test/java/example/ExamplesTest.java b/commercetools/internal-docs/src/test/java/example/ExamplesTest.java index f33897a0ef2..642b8601f27 100644 --- a/commercetools/internal-docs/src/test/java/example/ExamplesTest.java +++ b/commercetools/internal-docs/src/test/java/example/ExamplesTest.java @@ -3,9 +3,8 @@ import java.net.InetSocketAddress; import java.net.Proxy; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; +import java.util.Collections; import java.util.concurrent.CompletableFuture; import com.commercetools.api.client.ApiRoot; @@ -14,7 +13,6 @@ import com.commercetools.api.defaultconfig.ApiRootBuilder; import com.commercetools.api.defaultconfig.ServiceRegion; import com.commercetools.api.models.category.*; -import com.commercetools.api.models.common.LocalizedString; import com.commercetools.api.models.common.LocalizedStringBuilder; import com.commercetools.api.models.project.Project; import com.commercetools.api.models.tax_category.TaxCategoryPagedQueryResponse; @@ -25,6 +23,7 @@ import io.vrap.rmf.base.client.VrapHttpClient; import io.vrap.rmf.base.client.oauth2.ClientCredentials; +import org.apache.commons.lang3.tuple.Pair; import org.assertj.core.api.Assertions; import org.junit.Test; @@ -90,9 +89,7 @@ public void performRequest() { .execute(); } - public void usage() { - ProjectApiRoot apiRoot = createProjectClient(); - + public CategoryDraft draftBuilder() { CategoryDraft categoryDraft = CategoryDraftBuilder.of() .name(LocalizedStringBuilder.of().addValue("en", "name").build()) .slug(LocalizedStringBuilder.of().addValue("en", "slug").build()) @@ -103,8 +100,16 @@ public void usage() { .orderHint("hint") .build(); + Assertions.assertThat(categoryDraft).isInstanceOf(CategoryDraft.class); + + return categoryDraft; + } + + public void usage() { + ProjectApiRoot apiRoot = createProjectClient(); + // Use in the previous step configured ApiRoot instance to send and receive a newly created Category - Category category = apiRoot.categories().post(categoryDraft).executeBlocking().getBody(); + Category category = apiRoot.categories().post(draftBuilder()).executeBlocking().getBody(); // Get Category by id Category queriedCategory = apiRoot.categories().withId(category.getId()).get().executeBlocking().getBody(); @@ -124,28 +129,15 @@ public void usage() { .executeBlocking() .getBody(); - // Delete Category by id - Category deletedCategory = apiRoot.categories() - .withId(category.getId()) - .delete() - .withVersion(1) - .executeBlocking() - .getBody(); - // Update Category - List updateActions = new ArrayList<>(); - LocalizedString newName = LocalizedString.of(); - newName.setValue("key-Temp", "value-Temp"); - updateActions.add(CategoryChangeNameActionBuilder.of().name(newName).build()); - - CategoryUpdate categoryUpdate = CategoryUpdateBuilder.of() - .version(category.getVersion()) - .actions(updateActions) - .build(); - Category updatedCategory = apiRoot.categories() .withId(category.getId()) - .post(categoryUpdate) + .post(CategoryUpdateBuilder.of() + .version(category.getVersion()) + .actions(CategoryChangeNameActionBuilder.of() + .name(LocalizedStringBuilder.of().addValue("key-Temp", "value-Temp").build()) + .build()) + .build()) .executeBlocking() .getBody(); @@ -158,6 +150,61 @@ public void usage() { .getBody(); } + public void queryPredicateVariable() { + ProjectApiRoot apiRoot = createProjectClient(); + apiRoot.customers() + .get() + .withWhere("firstName = :firstName and lastName = :lastName", + Arrays.asList(Pair.of("firstName", "John"), Pair.of("lastName", "Doe"))); + + apiRoot.customers() + .get() + .withWhere("firstName = :firstName", "firstName", "John") + .addWhere("lastName = :lastName", "lastName", "John"); + + apiRoot.customers() + .get() + .withWhere("firstName = :firstName") + .addWhere("lastName = :lastName") + .withPredicateVar("firstName", "John") + .withPredicateVar("lastName", "Doe"); + } + + public void queryPredicateVariableArray() { + ProjectApiRoot apiRoot = createProjectClient(); + apiRoot.productProjections() + .get() + .withWhere("masterVariant(sku in :skus)", + Collections.singletonMap("skus", Arrays.asList("abc", "def"))); + + apiRoot.productProjections() + .get() + .withWhere("masterVariant(sku in :skus)", + Arrays.asList(Pair.of("skus", "abc"), Pair.of("skus", "def"))); + + apiRoot.productProjections() + .get() + .withWhere("masterVariant(sku in :skus)") + .withPredicateVar("skus", Arrays.asList("abc", "def")); + + apiRoot.productProjections() + .get() + .withWhere("masterVariant(sku in :skus)") + .withPredicateVar("skus", "abc") + .addPredicateVar("skus", "def"); + } + + public void getByIdOrKey() { + ProjectApiRoot apiRoot = createProjectClient(); + apiRoot.productProjections() + .withKey("product-key") + .get(); + + apiRoot.productProjections() + .withId("product-key") + .get(); + } + public void middleware() { ProjectApiRoot apiRoot = ApiRootBuilder.of() .defaultClient(ClientCredentials.of() diff --git a/src/main/javadoc/overview.html b/src/main/javadoc/overview.html index ea5f6e79961..c1bc7656788 100644 --- a/src/main/javadoc/overview.html +++ b/src/main/javadoc/overview.html @@ -16,8 +16,8 @@

First steps

  • {@link com.commercetools.docs.meta.Configuration Configuration}
  • +
  • {@link com.commercetools.docs.meta.Querying Querying}
  • {@link com.commercetools.docs.meta.Middlewares Middlewares}
  • -
  • {@link com.commercetools.docs.meta.ClientTuning Client Tuning}
  • Preparing for the worst

      @@ -27,6 +27,7 @@

      Preparing for the worst

      Customization

      1. {@link com.commercetools.docs.meta.Serialization Serialization}
      2. +
      3. {@link com.commercetools.docs.meta.ClientTuning Client Tuning}

      Other

        From 8f10ff99227c4893a482286e7e4ae79ebbf2cd80 Mon Sep 17 00:00:00 2001 From: Auto Mation Date: Tue, 5 Oct 2021 12:40:09 +0000 Subject: [PATCH 2/5] spotless: Fix code style --- .../internal-docs/src/test/java/example/ExamplesTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/commercetools/internal-docs/src/test/java/example/ExamplesTest.java b/commercetools/internal-docs/src/test/java/example/ExamplesTest.java index 642b8601f27..1497f2b5444 100644 --- a/commercetools/internal-docs/src/test/java/example/ExamplesTest.java +++ b/commercetools/internal-docs/src/test/java/example/ExamplesTest.java @@ -196,13 +196,9 @@ public void queryPredicateVariableArray() { public void getByIdOrKey() { ProjectApiRoot apiRoot = createProjectClient(); - apiRoot.productProjections() - .withKey("product-key") - .get(); + apiRoot.productProjections().withKey("product-key").get(); - apiRoot.productProjections() - .withId("product-key") - .get(); + apiRoot.productProjections().withId("product-key").get(); } public void middleware() { From 37ee2d48de33f8c75e05528c690ae356d11db46a Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Wed, 6 Oct 2021 12:42:29 +0200 Subject: [PATCH 3/5] add query utils with query all helper --- .../DeleteEverythingIntegrationTest.java | 132 ++++++-------- .../product/ProductFixtures.java | 2 +- .../utils/CommercetoolsTestUtils.java | 7 + .../commercetools/api/client/QueryAll.java | 164 ++++++++++++++++++ .../commercetools/api/client/QueryUtils.java | 123 +++++++++++++ .../api/models/PagedQueryResourceRequest.java | 7 + .../com/commercetools/docs/meta/Querying.java | 4 + 7 files changed, 358 insertions(+), 81 deletions(-) create mode 100644 commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryAll.java create mode 100644 commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryUtils.java diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/cleanup/DeleteEverythingIntegrationTest.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/cleanup/DeleteEverythingIntegrationTest.java index 7ed83d55722..f7bf2f996e7 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/cleanup/DeleteEverythingIntegrationTest.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/cleanup/DeleteEverythingIntegrationTest.java @@ -4,14 +4,14 @@ import static commercetools.utils.CommercetoolsTestUtils.assertEventually; import java.time.Duration; -import java.util.List; -import java.util.concurrent.*; import java.util.function.Consumer; +import com.commercetools.api.client.QueryUtils; +import com.commercetools.api.models.DomainResource; import com.commercetools.api.models.PagedQueryResourceRequest; import com.commercetools.api.models.ResourcePagedQueryResponse; import com.commercetools.api.models.category.CategoryPagedQueryResponse; -import com.commercetools.api.models.common.BaseResource; +import com.commercetools.api.models.state.*; import commercetools.cart.CartsFixtures; import commercetools.cart_discount.CartDiscountFixtures; import commercetools.category.CategoryFixtures; @@ -36,9 +36,6 @@ import commercetools.utils.CommercetoolsTestUtils; import commercetools.zone.ZoneFixtures; -import io.vrap.rmf.base.client.ApiHttpResponse; -import io.vrap.rmf.base.client.error.NotFoundException; - import org.assertj.core.api.Assertions; import org.junit.Test; @@ -47,36 +44,8 @@ */ public class DeleteEverythingIntegrationTest { - final int concurrency = 30; - final BlockingQueue blockingQueue = new ArrayBlockingQueue<>(concurrency); - final ExecutorService threadPool = Executors.newFixedThreadPool(concurrency); - - private void initWorkers() { - for (int i = 0; i < concurrency; i++) { - threadPool.execute(() -> { - try { - while (!threadPool.isTerminated()) { - Runnable runnable = blockingQueue.poll(10, TimeUnit.SECONDS); - if (runnable == null) { - break; - } - try { - runnable.run(); - } - catch (NotFoundException ignored) { - } - } - } - catch (InterruptedException e) { - e.printStackTrace(); - } - }); - } - } - @Test public void execute() { - initWorkers(); try { deleteAllExtensions(); deleteAllOrderEdits(); @@ -95,36 +64,24 @@ public void execute() { deleteAllProductDiscounts(); deleteAllCustomObjects(); deleteAllCustomers(); - deleteAllStates(); deleteAllStores(); deleteAllChannels(); deleteAllCustomerGroups(); deleteAllTypes(); deleteAllZones(); + deleteAllStates(); } catch (Exception e) { System.out.println(e); } - threadPool.shutdown(); } - private , TResult extends ResourcePagedQueryResponse, TResource extends BaseResource> void deleteAllResources( - PagedQueryResourceRequest request, Consumer deleteFn) { + private , TResult extends ResourcePagedQueryResponse, TElement extends DomainResource> void deleteAllResources( + PagedQueryResourceRequest request, Consumer deleteFn) { - ApiHttpResponse response = request.withLimit(100).withSort("id ASC").executeBlocking(); - - do { - List results = response.getBody().getResults(); - if (results.size() > 0) { - results.forEach(deleteFn); - String lastId = results.get(results.size() - 1).getId(); - response = request.withLimit(100) - .withSort("id ASC") - .withWhere("id > :lastId") - .withPredicateVar("lastId", lastId) - .executeBlocking(); - } - } while (response.getBody().getCount() >= response.getBody().getLimit()); + QueryUtils.queryAll(request, list -> { + list.forEach(deleteFn); + }, 100).toCompletableFuture().join(); } private void checkDepends(Runnable block) { @@ -132,87 +89,102 @@ private void checkDepends(Runnable block) { } private void deleteAllZones() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().zones().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().zones().get(), (zone) -> ZoneFixtures.deleteZone(zone.getId(), zone.getVersion())); } private void deleteAllOrderEdits() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().orders().edits().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().orders().edits().get(), (orderEdit) -> OrdersFixtures.deleteOrderEdit(orderEdit.getId(), orderEdit.getVersion())); } private void deleteAllOrders() { checkDepends(() -> Assertions.assertThat( - CommercetoolsTestUtils.getProjectRoot().orders().edits().get().executeBlocking().getBody().getCount()) + CommercetoolsTestUtils.getProjectApiRoot().orders().edits().get().executeBlocking().getBody().getCount()) .isZero()); - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().orders().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().orders().get(), (order) -> OrdersFixtures.deleteOrder(order.getId(), order.getVersion())); } private void deleteAllCarts() { checkDepends(() -> Assertions .assertThat( - CommercetoolsTestUtils.getProjectRoot().orders().get().executeBlocking().getBody().getCount()) + CommercetoolsTestUtils.getProjectApiRoot().orders().get().executeBlocking().getBody().getCount()) .isZero()); - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().carts().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().carts().get(), (cart) -> CartsFixtures.deleteCart(cart.getId(), cart.getVersion())); } private void deleteAllTypes() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().types().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().types().get(), (type) -> TypeFixtures.deleteType(type.getId(), type.getVersion())); } private void deleteAllStores() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().stores().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().stores().get(), (store) -> StoreFixtures.deleteStore(store.getId(), store.getVersion())); } private void deleteAllStates() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().states().get().withWhere("initial = false"), + QueryUtils.queryAll(CommercetoolsTestUtils.getProjectApiRoot().states().get(), states -> { + states.forEach(state -> { + if (state.getTransitions() != null) { + CommercetoolsTestUtils.getProjectApiRoot() + .states() + .withId(state.getId()) + .post(StateUpdateBuilder.of() + .version(state.getVersion()) + .actions(StateSetTransitionsActionBuilder.of().build()) + .build()) + .executeBlocking(); + } + }); + }, 100).toCompletableFuture().join(); + + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().states().get().withWhere("builtIn = false"), (state) -> StateFixtures.deleteState(state.getId(), state.getVersion())); } private void deleteAllShoppingLists() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().shoppingLists().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().shoppingLists().get(), (shoppingList) -> ShoppingListFixtures.deleteShoppingList(shoppingList.getId(), shoppingList.getVersion())); } private void deleteAllShippingMethods() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().shippingMethods().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().shippingMethods().get(), (shippingMethod) -> ShippingMethodFixtures.deleteShippingMethod(shippingMethod.getId(), shippingMethod.getVersion())); } private void deleteAllExtensions() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().extensions().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().extensions().get(), (extension) -> ExtensionFixtures.deleteExtension(extension.getId(), extension.getVersion())); } private void deleteAllCustomerGroups() { checkDepends(() -> Assertions .assertThat( - CommercetoolsTestUtils.getProjectRoot().customers().get().executeBlocking().getBody().getCount()) + CommercetoolsTestUtils.getProjectApiRoot().customers().get().executeBlocking().getBody().getCount()) .isZero()); - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().customerGroups().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().customerGroups().get(), (customerGroup) -> CustomerGroupFixtures.deleteCustomerGroup(customerGroup.getId(), customerGroup.getVersion())); } private void deleteAllCustomers() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().customers().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().customers().get(), (customer) -> CustomerFixtures.deleteCustomer(customer.getId(), customer.getVersion())); } private void deleteAllCustomObjects() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().customObjects().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().customObjects().get(), (customObject) -> CustomObjectFixtures.deleteCustomObject(customObject.getContainer(), customObject.getKey(), customObject.getVersion())); } private void deleteAllChannels() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().channels().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().channels().get(), (channel) -> ChannelFixtures.deleteChannel(channel.getId(), channel.getVersion())); } @@ -220,7 +192,7 @@ private void deleteAllCategories() { CategoryPagedQueryResponse response; do { - response = CommercetoolsTestUtils.getProjectRoot().categories().get().executeBlocking().getBody(); + response = CommercetoolsTestUtils.getProjectApiRoot().categories().get().executeBlocking().getBody(); response.getResults().forEach(category -> { CategoryFixtures.deleteCategory(category.getId(), category.getVersion()); }); @@ -229,49 +201,49 @@ private void deleteAllCategories() { private void deleteAllCartDiscounts() { checkDepends(() -> Assertions.assertThat( - CommercetoolsTestUtils.getProjectRoot().discountCodes().get().executeBlocking().getBody().getCount()) + CommercetoolsTestUtils.getProjectApiRoot().discountCodes().get().executeBlocking().getBody().getCount()) .isZero()); - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().cartDiscounts().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().cartDiscounts().get(), (cartDiscount) -> CartDiscountFixtures.deleteCartDiscount(cartDiscount.getId(), cartDiscount.getVersion())); } private void deleteAllInventories() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().inventory().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().inventory().get(), (inventoryEntry) -> InventoryEntryFixtures.delete(inventoryEntry.getId())); } private void deleteAllProducts() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().products().get(), ProductFixtures::deleteProduct); + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().products().get(), ProductFixtures::deleteProduct); } private void deleteAllProductDiscounts() { checkDepends(() -> Assertions .assertThat( - CommercetoolsTestUtils.getProjectRoot().products().get().executeBlocking().getBody().getCount()) + CommercetoolsTestUtils.getProjectApiRoot().products().get().executeBlocking().getBody().getCount()) .isZero()); - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().productDiscounts().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().productDiscounts().get(), (productDiscount) -> ProductDiscountFixtures.deleteProductDiscount(productDiscount.getId(), productDiscount.getVersion())); } private void deleteAllProductTypes() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().productTypes().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().productTypes().get(), (productType) -> ProductTypeFixtures.deleteProductType(productType.getId(), productType.getVersion())); } private void deleteAllReviews() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().reviews().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().reviews().get(), (review) -> ReviewFixtures.delete(review.getId(), review.getVersion())); } private void deleteAllTaxCategories() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().taxCategories().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().taxCategories().get(), (taxCategory) -> TaxCategoryFixtures.deleteTaxCategory(taxCategory.getId(), taxCategory.getVersion())); } private void deleteAllDiscountCodes() { - deleteAllResources(CommercetoolsTestUtils.getProjectRoot().discountCodes().get(), + deleteAllResources(CommercetoolsTestUtils.getProjectApiRoot().discountCodes().get(), (discountCode) -> DiscountCodeFixtures.deleteDiscountCode(discountCode.getId(), discountCode.getVersion())); } } diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java index f00063b7802..1f936fb2e85 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java @@ -260,7 +260,7 @@ public static Product deleteProduct(Product product) { .get() .getBody(); } - catch (Exception e) { + catch (Exception ignored) { } Assert.assertNotNull(rProduct); diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java index 4ec40162af1..a6bffee9c6b 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java @@ -5,6 +5,7 @@ import java.util.UUID; import com.commercetools.api.client.ByProjectKeyRequestBuilder; +import com.commercetools.api.client.ProjectApiRoot; import com.commercetools.api.defaultconfig.ApiRootBuilder; import com.commercetools.api.defaultconfig.ServiceRegion; import com.commercetools.api.models.common.LocalizedString; @@ -17,6 +18,7 @@ public class CommercetoolsTestUtils { private static final ApiHttpClient client; private static final ByProjectKeyRequestBuilder projectRoot; + private static final ProjectApiRoot projectApiRoot; static { ServiceRegion region = System.getenv("CTP_REGION") == null ? ServiceRegion.GCP_EUROPE_WEST1 @@ -31,6 +33,7 @@ public class CommercetoolsTestUtils { authURL, apiUrl); client = builder.buildClient(); projectRoot = ApiRootBuilder.createForProject(getProjectKey(), client); + projectApiRoot = builder.build(getProjectKey()); } public static String randomString() { @@ -67,6 +70,10 @@ public static ByProjectKeyRequestBuilder getProjectRoot() { return projectRoot; } + public static ProjectApiRoot getProjectApiRoot() { + return projectApiRoot; + } + public static ApiHttpClient getClient() { return client; } diff --git a/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryAll.java b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryAll.java new file mode 100644 index 00000000000..e7a48e065c9 --- /dev/null +++ b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryAll.java @@ -0,0 +1,164 @@ + +package com.commercetools.api.client; + +import static java.util.concurrent.CompletableFuture.completedFuture; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletionStage; +import java.util.function.Consumer; +import java.util.function.Function; + +import javax.annotation.Nonnull; + +import com.commercetools.api.models.DomainResource; +import com.commercetools.api.models.PagedQueryResourceRequest; +import com.commercetools.api.models.ResourcePagedQueryResponse; + +import io.vrap.rmf.base.client.ApiHttpResponse; + +final class QueryAll, TResult extends ResourcePagedQueryResponse, TElement extends DomainResource, S> { + private final PagedQueryResourceRequest baseQuery; + private final long pageSize; + + private Function, S> pageMapper; + private final List mappedResultsTillNow; + + private Consumer> pageConsumer; + + private QueryAll(@Nonnull final PagedQueryResourceRequest baseQuery, final int pageSize) { + + this.baseQuery = withDefaults(baseQuery, pageSize); + this.pageSize = pageSize; + this.mappedResultsTillNow = new ArrayList<>(); + } + + @Nonnull + private static , TResult extends ResourcePagedQueryResponse, TElement extends DomainResource> PagedQueryResourceRequest withDefaults( + @Nonnull final PagedQueryResourceRequest request, final int pageSize) { + + final PagedQueryResourceRequest withLimit = request.withLimit(pageSize).withWithTotal(false); + return !withLimit.getQueryParam("sort").isEmpty() ? withLimit : withLimit.withSort("id asc"); + } + + @Nonnull + static , TResult extends ResourcePagedQueryResponse, TElement extends DomainResource, S> QueryAll of( + @Nonnull final PagedQueryResourceRequest baseQuery, final int pageSize) { + + return new QueryAll<>(baseQuery, pageSize); + } + + /** + * Given a {@link Function} to a page of resources of type {@code TElement} that returns a mapped result + * of type {@code S}, this method sets this instance's {@code pageMapper} to the supplied value, + * then it makes requests to fetch the entire result space of the resource {@code TElement} on CTP, while + * applying the function on each fetched page. + * + * @param pageMapper the function to apply on each fetched page of the result space. + * @return a future containing a list of mapped results of type {@code S}, after the function + * applied all the pages. + */ + @Nonnull + CompletionStage> run(@Nonnull final Function, S> pageMapper) { + this.pageMapper = pageMapper; + final CompletionStage> firstPage = baseQuery.execute(); + return queryNextPages(firstPage).thenApply(voidResult -> this.mappedResultsTillNow); + } + + /** + * Given a {@link Consumer} to a page of resources of type {@code TElement}, this method sets this + * instance's {@code pageConsumer} to the supplied value, then it makes requests to fetch the + * entire result space of the resource {@code TElement} on CTP, while accepting the consumer on each + * fetched page. + * + * @param pageConsumer the consumer to accept on each fetched page of the result space. + * @return a future containing void after the consumer accepted all the pages. + */ + @Nonnull + CompletionStage run(@Nonnull final Consumer> pageConsumer) { + this.pageConsumer = pageConsumer; + final CompletionStage> firstPage = baseQuery.execute(); + return queryNextPages(firstPage).thenAccept(voidResult -> { + }); + } + + /** + * Given a completion stage {@code currentPageStage} containing a current page result {@link + * ResourcePagedQueryResponse}, this method composes the completion stage by first checking if the result is + * null or not. If it is not, then it recursivley (by calling itself with the next page's + * completion stage result) composes to the supplied stage, stages of the all next pages' + * processing. If there is no next page, then the result of the {@code currentPageStage} would be + * null and this method would just return a completed future containing containing null result, + * which in turn signals the last page of processing. + * + * @param currentPageStage a future containing a result {@link ResourcePagedQueryResponse}. + */ + @Nonnull + private CompletionStage queryNextPages( + @Nonnull final CompletionStage> currentPageStage) { + return currentPageStage.thenCompose( + currentPage -> currentPage != null ? queryNextPages(processPageAndGetNext(currentPage.getBody())) + : completedFuture(null)); + } + + /** + * Given a page result {@link ResourcePagedQueryResponse}, this method checks if there are elements in the + * result (size > 0), then it maps or consumes the resultant list using this instance's {@code + * pageMapper} or {code pageConsumer} whichever is available. Then it attempts to fetch the next + * page if it exists and returns a completion stage containing the result of the next page. If + * there is a next page, then a new future of the next page is returned. If there are no more + * results, the method returns a completed future containing null. + * + * @param page the current page result. + * @return If there is a next page, then a new future of the next page is returned. If there are + * no more results, the method returns a completed future containing null. + */ + @Nonnull + private CompletionStage> processPageAndGetNext( + @Nonnull final ResourcePagedQueryResponse page) { + final List currentPageElements = page.getResults(); + if (!currentPageElements.isEmpty()) { + mapOrConsume(currentPageElements); + return getNextPageStage(currentPageElements); + } + return completedFuture(null); + } + + /** + * Given a list of page elements of resource {@code TElement}, this method checks if this instance's + * {@code pageConsumer} or {@code pageMapper} is set (not null). The one which is set is then + * applied on the list of page elements. + * + * @param pageElements list of page elements of resource {@code T}. + */ + private void mapOrConsume(@Nonnull final List pageElements) { + if (pageConsumer != null) { + pageConsumer.accept(pageElements); + } + else { + mappedResultsTillNow.add(pageMapper.apply(pageElements)); + } + } + + /** + * Given a list of page elements of resource {@code TElement}, this method checks if this page is the + * last page or not by checking if the result size is equal to this instance's {@code pageSize}). + * If It is, then it means there might be still more results. However, if not, then it means for + * sure there are no more results and this is the last page. If there is a next page, the id of + * the last element in the list is fetched and a future is created containing the fetched results + * which have an id greater than the id of the last element in the list and this future is + * returned. If there are no more results, the method returns a completed future containing null. + * + * @param pageElements list of page elements of resource {@code TElement}. + * @return a future containing the fetched results which have an id greater than the id of the + * last element in the list. + */ + @Nonnull + private CompletionStage> getNextPageStage(@Nonnull final List pageElements) { + if (pageElements.size() == pageSize) { + final String lastElementId = pageElements.get(pageElements.size() - 1).getId(); + return baseQuery.addWhere("id > :lastId", "lastId", lastElementId).execute(); + } + return completedFuture(null); + } +} diff --git a/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryUtils.java b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryUtils.java new file mode 100644 index 00000000000..27d2ff732be --- /dev/null +++ b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/client/QueryUtils.java @@ -0,0 +1,123 @@ + +package com.commercetools.api.client; + +import java.util.List; +import java.util.concurrent.CompletionStage; +import java.util.function.Consumer; +import java.util.function.Function; + +import javax.annotation.Nonnull; + +import com.commercetools.api.models.DomainResource; +import com.commercetools.api.models.PagedQueryResourceRequest; +import com.commercetools.api.models.ResourcePagedQueryResponse; + +public class QueryUtils { + static int DEFAULT_PAGE_SIZE = 500; + /** + *

        Queries all elements matching a query by using a limit based pagination with a combination of + * id sorting and a page size 500. More on the algorithm can be found here: + * Iterating all elements.

        + * + *

        The method takes a callback {@link java.util.function.Function} that returns a result of type {@code } that + * is returned on every page of elements queried. Eventually, the method returns a {@link + * java.util.concurrent.CompletionStage} that contains a list of all the results of the callbacks returned from every + * page. + * + *

        NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in + * parallel. + * + * @param query query containing predicates and expansion paths + * @param pageMapper callback function that is called on every page queried + * @param type of one query result element + * @param type of the query + * @param type of the returned result of the callback function on every page. + * @return a completion stage containing a list of mapped pages as a result. + */ + @Nonnull + public static , TResult extends ResourcePagedQueryResponse, TElement extends DomainResource, S> CompletionStage> queryAll( + @Nonnull final PagedQueryResourceRequest query, + @Nonnull final Function, S> pageMapper) { + return queryAll(query, pageMapper, DEFAULT_PAGE_SIZE); + } + + /** + *

        Queries all elements matching a query by using a limit based pagination with a combination of + * id sorting and a page size 500. More on the algorithm can be found here: + * Iterating all elements.

        + * + *

        The method takes a consumer {@link Consumer} that is applied on every page of elements + * queried. + * + *

        NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in + * parallel. + * + * @param query query containing predicates and expansion paths + * @param pageConsumer consumer applied on every page queried + * @param type of one query result element + * @param type of the query + * @return a completion stage containing void as a result after the consumer was applied on all + * pages. + */ + @Nonnull + public static , TResult extends ResourcePagedQueryResponse, TElement extends DomainResource> CompletionStage queryAll( + @Nonnull final PagedQueryResourceRequest query, + @Nonnull final Consumer> pageConsumer) { + return queryAll(query, pageConsumer, DEFAULT_PAGE_SIZE); + } + + /** + *

        Queries all elements matching a query by using a limit based pagination with a combination of + * id sorting and the supplied {@code pageSize}. More on the algorithm can be found here: + * Iterating all elements.

        + * + *

        The method takes a callback {@link Function} that returns a result of type {@code } that + * is returned on every page of elements queried. Eventually, the method returns a {@link + * CompletionStage} that contains a list of all the results of the callbacks returned from every + * page. + * + *

        NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in + * parallel. + * + * @param query query containing predicates and expansion paths + * @param pageMapper callback function that is called on every page queried + * @param type of one query result element + * @param type of the query + * @param type of the returned result of the callback function on every page. + * @param pageSize the page size. + * @return a completion stage containing a list of mapped pages as a result. + */ + @Nonnull + public static , TResult extends ResourcePagedQueryResponse, TElement extends DomainResource, S> CompletionStage> queryAll( + @Nonnull final PagedQueryResourceRequest query, + @Nonnull final Function, S> pageMapper, final int pageSize) { + final QueryAll queryAll = QueryAll.of(query, pageSize); + return queryAll.run(pageMapper); + } + + /** + *

        Queries all elements matching a query by using a limit based pagination with a combination of + * id sorting and the supplied {@code pageSize}. More on the algorithm can be found here: + * Iterating all elements.

        + * + *

        The method takes a {@link java.util.function.Consumer} that is applied on every page of the queried elements. + * + *

        NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in + * parallel. + * + * @param query query containing predicates and expansion paths + * @param pageConsumer consumer applied on every page queried + * @param type of one query result element + * @param type of the query + * @param pageSize the page size + * @return a completion stage containing void as a result after the consumer was applied on all + * pages. + */ + @Nonnull + public static , TResult extends ResourcePagedQueryResponse, TElement extends DomainResource> CompletionStage queryAll( + @Nonnull final PagedQueryResourceRequest query, + @Nonnull final Consumer> pageConsumer, final int pageSize) { + final QueryAll queryAll = QueryAll.of(query, pageSize); + return queryAll.run(pageConsumer); + } +} diff --git a/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java index b9f81fc46dd..3603f5eacdc 100644 --- a/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java +++ b/commercetools/commercetools-sdk-java-api/src/main/java/com/commercetools/api/models/PagedQueryResourceRequest.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; +import io.vrap.rmf.base.client.ApiMethod; import io.vrap.rmf.base.client.ClientRequestCommand; import io.vrap.rmf.base.client.RequestCommand; @@ -41,6 +42,12 @@ public interface PagedQueryResourceRequest addPredicateVar(final String varName, final List predicateVar); + List> getQueryParams(); + + List getQueryParam(final String key); + + String getFirstQueryParam(final String key); + default PagedQueryResourceRequest asPagedQueryResourceRequest() { return this; } diff --git a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java index 4276d791feb..92ebc814850 100644 --- a/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java +++ b/commercetools/internal-docs/src/main/java/com/commercetools/docs/meta/Querying.java @@ -19,6 +19,10 @@ *

        Get by id/key

        * * {@include.example example.ExamplesTest#getByIdOrKey()} + * + *

        Query all

        + * + * {@link com.commercetools.api.client.QueryUtils} */ public class Querying { } From af781c50f132ae540ed0279034a355e7c03d05a3 Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Wed, 6 Oct 2021 12:52:38 +0200 Subject: [PATCH 4/5] use projectApiRoot in integration tests --- .../java/commercetools/ExceptionTest.java | 2 +- .../api_client/ApiClientFixtures.java | 4 ++-- .../api_client/ApiClientIntegrationTests.java | 4 ++-- .../commercetools/cart/CartsFixtures.java | 4 ++-- .../cart_discount/CartDiscountFixtures.java | 6 ++--- .../CartDiscountIntegrationTests.java | 14 +++++------ .../category/CategoryFixtures.java | 6 ++--- .../category/CategoryIntegrationTests.java | 12 +++++----- .../channel/ChannelFixtures.java | 4 ++-- .../channel/ChannelIntegrationTests.java | 6 ++--- .../custom_object/CustomObjectFixtures.java | 4 ++-- .../CustomObjectIntegrationTests.java | 8 +++---- .../customer/CustomerFixtures.java | 6 ++--- .../customer/CustomerIntegrationTests.java | 12 +++++----- .../customer_group/CustomerGroupFixtures.java | 4 ++-- .../CustomerGroupIntegrationTests.java | 12 +++++----- .../discount_code/DiscountCodeFixtures.java | 4 ++-- .../DiscountCodeIntegrationTests.java | 6 ++--- .../extension/ExtensionFixtures.java | 4 ++-- .../extension/ExtensionIntegrationTests.java | 12 +++++----- .../inventory/InventoryEntryFixtures.java | 4 ++-- .../inventory/InventoryIntegrationTests.java | 10 ++++---- .../commercetools/me/MyCartsFixtures.java | 2 +- .../message/MessageIntegrationTests.java | 6 ++--- .../misc/UserAgentHeaderTest.java | 2 +- ...alCustomerPasswordAuthIntegrationTest.java | 2 +- .../commercetools/order/OrdersFixtures.java | 4 ++-- .../product/ProductFixtures.java | 24 +++++++++---------- .../product/ProductIntegrationTests.java | 13 +++++----- .../ProductDiscountFixtures.java | 8 +++---- .../ProductDiscountIntegrationTests.java | 14 +++++------ .../ProductProjectionIntegrationTests.java | 10 ++++---- .../product_type/ProductTypeFixtures.java | 4 ++-- .../ProductTypeIntegrationTests.java | 12 +++++----- .../project/ProjectIntegrationTests.java | 6 ++--- ...CategoryErrorHandlingIntegrationTests.java | 8 +++---- .../commercetools/review/ReviewFixtures.java | 6 ++--- .../review/ReviewIntegrationTests.java | 14 +++++------ .../ShippingMethodFixtures.java | 4 ++-- .../ShippingMethodIntegrationTests.java | 12 +++++----- .../shopping_list/ShoppingListFixtures.java | 4 ++-- .../ShoppingListIntegrationTests.java | 10 ++++---- .../commercetools/state/StateFixtures.java | 4 ++-- .../state/StateIntegrationTests.java | 6 ++--- .../commercetools/store/StoreFixtures.java | 4 ++-- .../store/StoreIntegrationTests.java | 12 +++++----- .../subscription/SubscriptionFixtures.java | 4 ++-- .../tax_category/TaxCategoryFixtures.java | 4 ++-- .../TaxCategoryIntegrationTests.java | 14 +++++------ .../java/commercetools/type/TypeFixtures.java | 4 ++-- .../type/TypeIntegrationTests.java | 12 +++++----- .../utils/CommercetoolsTestUtils.java | 12 ---------- .../java/commercetools/zone/ZoneFixtures.java | 4 ++-- .../zone/ZoneIntegrationTests.java | 10 ++++---- 54 files changed, 196 insertions(+), 207 deletions(-) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/ExceptionTest.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/ExceptionTest.java index c8dfb82b832..6d7de5873f9 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/ExceptionTest.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/ExceptionTest.java @@ -13,7 +13,7 @@ public class ExceptionTest { @Test public void testException() { Assertions.assertThatExceptionOfType(NotFoundException.class) - .isThrownBy(() -> CommercetoolsTestUtils.getProjectRoot() + .isThrownBy(() -> CommercetoolsTestUtils.getProjectApiRoot() .categories() .withKey("unknown-category") .get() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientFixtures.java index bec84f09e84..957077e843d 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientFixtures.java @@ -24,7 +24,7 @@ public static ApiClient createApiClient() { .scope("manage_project:" + CommercetoolsTestUtils.getProjectKey()) .build(); - ApiClient apiClient = CommercetoolsTestUtils.getProjectRoot() + ApiClient apiClient = CommercetoolsTestUtils.getProjectApiRoot() .apiClients() .post(apiClientDraft) .executeBlocking() @@ -36,7 +36,7 @@ public static ApiClient createApiClient() { } public static ApiClient deleteApiClient(final String id) { - ApiClient apiClient = CommercetoolsTestUtils.getProjectRoot() + ApiClient apiClient = CommercetoolsTestUtils.getProjectApiRoot() .apiClients() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientIntegrationTests.java index 364948f485a..07f2180f48a 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/api_client/ApiClientIntegrationTests.java @@ -21,7 +21,7 @@ public void createAndDeleteById() { @Test public void getById() { ApiClientFixtures.withApiClient(apiClient -> { - ApiClient queriedApiClient = CommercetoolsTestUtils.getProjectRoot() + ApiClient queriedApiClient = CommercetoolsTestUtils.getProjectApiRoot() .apiClients() .withId(apiClient.getId()) .get() @@ -36,7 +36,7 @@ public void getById() { @Test public void query() { ApiClientFixtures.withApiClient(apiClient -> { - ApiClientPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ApiClientPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .apiClients() .get() .withWhere("id=" + "\"" + apiClient.getId() + "\"") diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart/CartsFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart/CartsFixtures.java index 0bce78c8966..2e23e3a8f35 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart/CartsFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart/CartsFixtures.java @@ -14,7 +14,7 @@ public class CartsFixtures { public static Cart deleteCart(final String id, final Long version) { - Cart cart = CommercetoolsTestUtils.getProjectRoot() + Cart cart = CommercetoolsTestUtils.getProjectApiRoot() .carts() .withId(id) .delete() @@ -59,7 +59,7 @@ public static void withUpdateableCart(final UnaryOperator operator) { } public static Cart createCart(final CartDraft cartDraft) { - Cart cart = CommercetoolsTestUtils.getProjectRoot().carts().post(cartDraft).executeBlocking().getBody(); + Cart cart = CommercetoolsTestUtils.getProjectApiRoot().carts().post(cartDraft).executeBlocking().getBody(); Assert.assertNotNull(cart); Assert.assertEquals(cart.getCountry(), cartDraft.getCountry()); diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountFixtures.java index b5b0c34c8bf..6465228bac6 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountFixtures.java @@ -31,7 +31,7 @@ public static CartDiscount createCartDiscount() { .permyriad(10L) .build(); - List cartDiscounts = CommercetoolsTestUtils.getProjectRoot() + List cartDiscounts = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .get() .withWhere("sortOrder=\"0.41\"") @@ -58,7 +58,7 @@ public static CartDiscount createCartDiscount() { .stackingMode(StackingMode.STACKING) .build(); - CartDiscount cartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount cartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .post(cartDiscountDraft) .executeBlocking() @@ -71,7 +71,7 @@ public static CartDiscount createCartDiscount() { } public static CartDiscount deleteCartDiscount(final String id, final Long version) { - CartDiscount deletedCartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount deletedCartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountIntegrationTests.java index 756c0a0a1c3..453bfcda24d 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/cart_discount/CartDiscountIntegrationTests.java @@ -35,7 +35,7 @@ public void createAndDelete() { .sortOrder("0.42") .build(); - CartDiscount cartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount cartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .post(cartDiscountDraft) .executeBlocking() @@ -44,7 +44,7 @@ public void createAndDelete() { Assert.assertNotNull(cartDiscount); Assert.assertEquals(cartDiscountDraft.getKey(), cartDiscount.getKey()); - CartDiscount deletedCartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount deletedCartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .withId(cartDiscount.getId()) .delete() @@ -58,7 +58,7 @@ public void createAndDelete() { @Test public void getById() { CartDiscountFixtures.withCartDiscount(cartDiscount -> { - CartDiscount queriedCartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount queriedCartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .withId(cartDiscount.getId()) .get() @@ -73,7 +73,7 @@ public void getById() { @Test public void getByKey() { CartDiscountFixtures.withCartDiscount(cartDiscount -> { - CartDiscount queriedCartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount queriedCartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .withKey(cartDiscount.getKey()) .get() @@ -88,7 +88,7 @@ public void getByKey() { @Test public void query() { CartDiscountFixtures.withCartDiscount(cartDiscount -> { - CartDiscountPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + CartDiscountPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .get() .withWhere("id=" + "\"" + cartDiscount.getId() + "\"") @@ -106,7 +106,7 @@ public void updateById() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(CartDiscountSetKeyActionBuilder.of().key(newKey).build()); - CartDiscount updatedCartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount updatedCartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .withId(cartDiscount.getId()) .post(CartDiscountUpdateBuilder.of() @@ -129,7 +129,7 @@ public void updateByKey() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(CartDiscountSetKeyActionBuilder.of().key(newKey).build()); - CartDiscount updatedCartDiscount = CommercetoolsTestUtils.getProjectRoot() + CartDiscount updatedCartDiscount = CommercetoolsTestUtils.getProjectApiRoot() .cartDiscounts() .withKey(cartDiscount.getKey()) .post(CartDiscountUpdateBuilder.of() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryFixtures.java index 768a7d0109c..f1748b80e00 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryFixtures.java @@ -50,7 +50,7 @@ public static Category createCategory() { .build())) .build(); - Type type = CommercetoolsTestUtils.getProjectRoot().types().post(typeDraft).executeBlocking().getBody(); + Type type = CommercetoolsTestUtils.getProjectApiRoot().types().post(typeDraft).executeBlocking().getBody(); CategoryDraft categoryDraft = CategoryDraftBuilder.of() .key(CommercetoolsTestUtils.randomKey()) @@ -72,12 +72,12 @@ public static Category createCategory() { .build())) .build(); - return CommercetoolsTestUtils.getProjectRoot().categories().post(categoryDraft).executeBlocking().getBody(); + return CommercetoolsTestUtils.getProjectApiRoot().categories().post(categoryDraft).executeBlocking().getBody(); } public static Category deleteCategory(final String id, final Long version) { - return CommercetoolsTestUtils.getProjectRoot() + return CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryIntegrationTests.java index 7eff2ea8a1a..80fab02ca99 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/category/CategoryIntegrationTests.java @@ -21,7 +21,7 @@ public void createAndDelete() { @Test public void getById() { CategoryFixtures.withCategory(category -> { - Category queriedCategory = CommercetoolsTestUtils.getProjectRoot() + Category queriedCategory = CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId(category.getId()) .get() @@ -34,7 +34,7 @@ public void getById() { @Test public void getByKey() { CategoryFixtures.withCategory(category -> { - Category queriedCategory = CommercetoolsTestUtils.getProjectRoot() + Category queriedCategory = CommercetoolsTestUtils.getProjectApiRoot() .categories() .withKey(category.getKey()) .get() @@ -48,7 +48,7 @@ public void getByKey() { @Test public void deleteById() { Category category = CategoryFixtures.createCategory(); - Category deletedCategory = CommercetoolsTestUtils.getProjectRoot() + Category deletedCategory = CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId(category.getId()) .delete() @@ -61,7 +61,7 @@ public void deleteById() { @Test public void deleteByKey() { Category category = CategoryFixtures.createCategory(); - Category deletedCategory = CommercetoolsTestUtils.getProjectRoot() + Category deletedCategory = CommercetoolsTestUtils.getProjectApiRoot() .categories() .withKey(category.getKey()) .delete() @@ -74,7 +74,7 @@ public void deleteByKey() { @Test public void queryCategories() { Category category = CategoryFixtures.createCategory(); - CategoryPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + CategoryPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .categories() .get() .withWhere("id=" + "\"" + category.getId() + "\"") @@ -95,7 +95,7 @@ public void updateCategory() { .version(category.getVersion()) .actions(CategoryChangeNameActionBuilder.of().name(newName).build()) .build(); - Category updatedCategory = CommercetoolsTestUtils.getProjectRoot() + Category updatedCategory = CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId(category.getId()) .post(categoryUpdate) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelFixtures.java index 175e88167f4..d68a0b12c81 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelFixtures.java @@ -35,7 +35,7 @@ public static Channel createChannel() { .geoLocation(GeoJsonPointBuilder.of().coordinates(Arrays.asList(13.0, 51.0)).build()) .build(); - Channel channel = CommercetoolsTestUtils.getProjectRoot() + Channel channel = CommercetoolsTestUtils.getProjectApiRoot() .channels() .post(channelDraft) .executeBlocking() @@ -48,7 +48,7 @@ public static Channel createChannel() { } public static Channel deleteChannel(final String id, final Long version) { - Channel channel = CommercetoolsTestUtils.getProjectRoot() + Channel channel = CommercetoolsTestUtils.getProjectApiRoot() .channels() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelIntegrationTests.java index a91c2d8f22f..69ce93ef30d 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/channel/ChannelIntegrationTests.java @@ -23,7 +23,7 @@ public void createAndDeleteById() { @Test public void getById() { ChannelFixtures.withChannel(channel -> { - Channel queriedChannel = CommercetoolsTestUtils.getProjectRoot() + Channel queriedChannel = CommercetoolsTestUtils.getProjectApiRoot() .channels() .withId(channel.getId()) .get() @@ -38,7 +38,7 @@ public void getById() { @Test public void query() { ChannelFixtures.withChannel(channel -> { - ChannelPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ChannelPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .channels() .get() .withWhere("id=" + "\"" + channel.getId() + "\"") @@ -56,7 +56,7 @@ public void update() { List updateActions = new ArrayList<>(); updateActions.add(ChannelSetGeoLocationActionBuilder.of().build()); - Channel updateChannel = CommercetoolsTestUtils.getProjectRoot() + Channel updateChannel = CommercetoolsTestUtils.getProjectApiRoot() .channels() .withId(channel.getId()) .post(ChannelUpdateBuilder.of().actions(updateActions).version(channel.getVersion()).build()) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectFixtures.java index edbfb068536..8f248044c29 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectFixtures.java @@ -33,7 +33,7 @@ public static CustomObject createCustomObject() { .value((ValueObject) () -> "val") .build(); - CustomObject customObject = CommercetoolsTestUtils.getProjectRoot() + CustomObject customObject = CommercetoolsTestUtils.getProjectApiRoot() .customObjects() .post(customObjectDraft) .executeBlocking() @@ -45,7 +45,7 @@ public static CustomObject createCustomObject() { } public static CustomObject deleteCustomObject(final String container, final String key, final Long version) { - CustomObject customObject = CommercetoolsTestUtils.getProjectRoot() + CustomObject customObject = CommercetoolsTestUtils.getProjectApiRoot() .customObjects() .withContainerAndKey(container, key) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectIntegrationTests.java index b392cadd628..fd2a8c24843 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/custom_object/CustomObjectIntegrationTests.java @@ -29,7 +29,7 @@ public void createAndDeleteById() { @Test public void getByContainerKey() { CustomObjectFixtures.withCustomObject(customObject -> { - CustomObject queriedCustomObject = CommercetoolsTestUtils.getProjectRoot() + CustomObject queriedCustomObject = CommercetoolsTestUtils.getProjectApiRoot() .customObjects() .withContainerAndKey(customObject.getContainer(), customObject.getKey()) .get() @@ -50,7 +50,7 @@ public void update() { .value((ValueObject) () -> "foo") .build(); - CustomObject updatedCustomObject = CommercetoolsTestUtils.getProjectRoot() + CustomObject updatedCustomObject = CommercetoolsTestUtils.getProjectApiRoot() .customObjects() .post(customObjectDraft) .executeBlocking() @@ -72,7 +72,7 @@ public void updateWithJsonNode() { .value(JsonUtils.getConfiguredObjectMapper().createObjectNode().put("value", "foo")) .build(); - CustomObject updatedCustomObject = CommercetoolsTestUtils.getProjectRoot() + CustomObject updatedCustomObject = CommercetoolsTestUtils.getProjectApiRoot() .customObjects() .post(customObjectDraft) .executeBlocking() @@ -88,7 +88,7 @@ public void updateWithJsonNode() { @Test public void query() { CustomObjectFixtures.withCustomObject(customObject -> { - CustomObjectPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + CustomObjectPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .customObjects() .get() .withWhere("id=" + "\"" + customObject.getId() + "\"") diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerFixtures.java index bbcff818802..93ad47e5317 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerFixtures.java @@ -45,7 +45,7 @@ public static Customer createCustomer() { .addresses(Arrays.asList(AddressBuilder.of().country("DE").build())) .build(); - Customer customer = CommercetoolsTestUtils.getProjectRoot() + Customer customer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .post(customerDraft) .executeBlocking() @@ -71,7 +71,7 @@ public static Customer createStoreCustomer() { .addresses(Arrays.asList(AddressBuilder.of().country("DE").build())) .build(); - Customer customer = CommercetoolsTestUtils.getProjectRoot() + Customer customer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .post(customerDraft) .executeBlocking() @@ -85,7 +85,7 @@ public static Customer createStoreCustomer() { } public static Customer deleteCustomer(final String id, final Long version) { - Customer customer = CommercetoolsTestUtils.getProjectRoot() + Customer customer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerIntegrationTests.java index 9ff5be826d4..3d5477b8ff7 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer/CustomerIntegrationTests.java @@ -22,7 +22,7 @@ public void createAndDeleteById() { @Test public void getById() { CustomerFixtures.withCustomer(customer -> { - Customer queriedCustomer = CommercetoolsTestUtils.getProjectRoot() + Customer queriedCustomer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .withId(customer.getId()) .get() @@ -37,7 +37,7 @@ public void getById() { @Test public void getByKey() { CustomerFixtures.withCustomer(customer -> { - Customer queriedCustomer = CommercetoolsTestUtils.getProjectRoot() + Customer queriedCustomer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .withKey(customer.getKey()) .get() @@ -52,7 +52,7 @@ public void getByKey() { @Test public void query() { CustomerFixtures.withCustomer(customer -> { - CustomerPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + CustomerPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .customers() .get() .withWhere("id=" + "\"" + customer.getId() + "\"") @@ -71,7 +71,7 @@ public void updateById() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(CustomerSetKeyActionBuilder.of().key(newKey).build()); - Customer updatedCustomer = CommercetoolsTestUtils.getProjectRoot() + Customer updatedCustomer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .withId(customer.getId()) .post(CustomerUpdateBuilder.of().actions(updateActions).version(customer.getVersion()).build()) @@ -92,7 +92,7 @@ public void updateByKey() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(CustomerSetKeyActionBuilder.of().key(newKey).build()); - Customer updatedCustomer = CommercetoolsTestUtils.getProjectRoot() + Customer updatedCustomer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .withKey(customer.getKey()) .post(CustomerUpdateBuilder.of().actions(updateActions).version(customer.getVersion()).build()) @@ -109,7 +109,7 @@ public void updateByKey() { @Test public void deleteByKey() { Customer customer = CustomerFixtures.createCustomer(); - Customer deletedCustomer = CommercetoolsTestUtils.getProjectRoot() + Customer deletedCustomer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .withKey(customer.getKey()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupFixtures.java index 0dd5ae89194..581876dc525 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupFixtures.java @@ -31,7 +31,7 @@ public static CustomerGroup createCustomerGroup() { .groupName(CommercetoolsTestUtils.randomString()) .build(); - CustomerGroup customerGroup = CommercetoolsTestUtils.getProjectRoot() + CustomerGroup customerGroup = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .post(customerGroupDraft) .executeBlocking() @@ -44,7 +44,7 @@ public static CustomerGroup createCustomerGroup() { } public static CustomerGroup deleteCustomerGroup(final String id, final Long version) { - CustomerGroup customerGroup = CommercetoolsTestUtils.getProjectRoot() + CustomerGroup customerGroup = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupIntegrationTests.java index 73083292628..d0e2e18d0d6 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/customer_group/CustomerGroupIntegrationTests.java @@ -26,7 +26,7 @@ public void createAndDeleteById() { @Test public void getById() { CustomerGroupFixtures.withCustomerGroup(customerGroup -> { - CustomerGroup queriedCustomerGroup = CommercetoolsTestUtils.getProjectRoot() + CustomerGroup queriedCustomerGroup = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .withId(customerGroup.getId()) .get() @@ -41,7 +41,7 @@ public void getById() { @Test public void getByKey() { CustomerGroupFixtures.withCustomerGroup(customerGroup -> { - CustomerGroup queriedCustomerGroup = CommercetoolsTestUtils.getProjectRoot() + CustomerGroup queriedCustomerGroup = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .withKey(customerGroup.getKey()) .get() @@ -56,7 +56,7 @@ public void getByKey() { @Test public void query() { CustomerGroupFixtures.withCustomerGroup(customerGroup -> { - CustomerGroupPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + CustomerGroupPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .get() .withWhere("id=" + "\"" + customerGroup.getId() + "\"") @@ -74,7 +74,7 @@ public void updateById() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(CustomerGroupSetKeyActionBuilder.of().key(newKey).build()); - CustomerGroup updatedCustomerGroup = CommercetoolsTestUtils.getProjectRoot() + CustomerGroup updatedCustomerGroup = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .withId(customerGroup.getId()) .post(CustomerGroupUpdateBuilder.of() @@ -97,7 +97,7 @@ public void updateByKey() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(CustomerGroupSetKeyActionBuilder.of().key(newKey).build()); - CustomerGroup updatedCustomerGroup = CommercetoolsTestUtils.getProjectRoot() + CustomerGroup updatedCustomerGroup = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .withKey(customerGroup.getKey()) .post(CustomerGroupUpdateBuilder.of() @@ -117,7 +117,7 @@ public void updateByKey() { @Test public void deleteByKey() { CustomerGroup customerGroup = CustomerGroupFixtures.createCustomerGroup(); - CustomerGroup deletedCustomerGroup = CommercetoolsTestUtils.getProjectRoot() + CustomerGroup deletedCustomerGroup = CommercetoolsTestUtils.getProjectApiRoot() .customerGroups() .withId(customerGroup.getId()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeFixtures.java index dafb75f834a..73d0995d1c1 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeFixtures.java @@ -52,7 +52,7 @@ public static DiscountCode createDiscountCode() { .maxApplicationsPerCustomer(1L) .build(); - DiscountCode discountCode = CommercetoolsTestUtils.getProjectRoot() + DiscountCode discountCode = CommercetoolsTestUtils.getProjectApiRoot() .discountCodes() .post(discountCodeDraft) .executeBlocking() @@ -65,7 +65,7 @@ public static DiscountCode createDiscountCode() { } public static DiscountCode deleteDiscountCode(final String id, final Long version) { - DiscountCode discountCode = CommercetoolsTestUtils.getProjectRoot() + DiscountCode discountCode = CommercetoolsTestUtils.getProjectApiRoot() .discountCodes() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeIntegrationTests.java index 33ac54f1c03..2737ba18744 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/discount_code/DiscountCodeIntegrationTests.java @@ -21,7 +21,7 @@ public void createAndDelete() { @Test public void getById() { DiscountCodeFixtures.withDiscountCode(discountCode -> { - DiscountCode queriedDiscountCode = CommercetoolsTestUtils.getProjectRoot() + DiscountCode queriedDiscountCode = CommercetoolsTestUtils.getProjectApiRoot() .discountCodes() .withId(discountCode.getId()) .get() @@ -36,7 +36,7 @@ public void getById() { @Test public void query() { DiscountCodeFixtures.withDiscountCode(discountCode -> { - DiscountCodePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + DiscountCodePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .discountCodes() .get() .withWhere("id=" + "\"" + discountCode.getId() + "\"") @@ -53,7 +53,7 @@ public void updateById() { DiscountCodeFixtures.withUpdateableDiscountCode(discountCode -> { List updateActions = new ArrayList<>(); updateActions.add(DiscountCodeSetMaxApplicationsActionBuilder.of().maxApplications(10L).build()); - DiscountCode updatedDiscountCode = CommercetoolsTestUtils.getProjectRoot() + DiscountCode updatedDiscountCode = CommercetoolsTestUtils.getProjectApiRoot() .discountCodes() .withId(discountCode.getId()) .post(DiscountCodeUpdateBuilder.of() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionFixtures.java index 2957db359c1..db5eb1e2649 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionFixtures.java @@ -34,7 +34,7 @@ public static Extension createExtension() { .build())) .build(); - Extension extension = CommercetoolsTestUtils.getProjectRoot() + Extension extension = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .post(extensionDraft) .executeBlocking() @@ -47,7 +47,7 @@ public static Extension createExtension() { } public static Extension deleteExtension(final String id, final Long version) { - Extension extension = CommercetoolsTestUtils.getProjectRoot() + Extension extension = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionIntegrationTests.java index fae9c699aaf..347518b79bd 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/extension/ExtensionIntegrationTests.java @@ -23,7 +23,7 @@ public void createAndDeleteById() { @Test public void getById() { ExtensionFixtures.withExtension(extension -> { - Extension queriedExtension = CommercetoolsTestUtils.getProjectRoot() + Extension queriedExtension = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .withId(extension.getId()) .get() @@ -38,7 +38,7 @@ public void getById() { @Test public void getByKey() { ExtensionFixtures.withExtension(extension -> { - Extension queriedExtension = CommercetoolsTestUtils.getProjectRoot() + Extension queriedExtension = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .withKey(extension.getKey()) .get() @@ -53,7 +53,7 @@ public void getByKey() { @Test public void query() { ExtensionFixtures.withExtension(extension -> { - ExtensionPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ExtensionPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .get() .withWhere("id=" + "\"" + extension.getId() + "\"") @@ -71,7 +71,7 @@ public void updateById() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ExtensionSetKeyActionBuilder.of().key(newKey).build()); - Extension updatedExtension = CommercetoolsTestUtils.getProjectRoot() + Extension updatedExtension = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .withId(extension.getId()) .post(ExtensionUpdateBuilder.of().actions(updateActions).version(extension.getVersion()).build()) @@ -91,7 +91,7 @@ public void updateByKey() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ExtensionSetKeyActionBuilder.of().key(newKey).build()); - Extension updatedExtension = CommercetoolsTestUtils.getProjectRoot() + Extension updatedExtension = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .withKey(extension.getKey()) .post(ExtensionUpdateBuilder.of().actions(updateActions).version(extension.getVersion()).build()) @@ -108,7 +108,7 @@ public void updateByKey() { @Test public void deleteByKey() { Extension extension = ExtensionFixtures.createExtension(); - Extension deletedExtension = CommercetoolsTestUtils.getProjectRoot() + Extension deletedExtension = CommercetoolsTestUtils.getProjectApiRoot() .extensions() .withId(extension.getId()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryEntryFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryEntryFixtures.java index d4fc9a2488c..93515577333 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryEntryFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryEntryFixtures.java @@ -40,7 +40,7 @@ public static InventoryEntry create() { .supplyChannel(ChannelResourceIdentifierBuilder.of().id(channel.getId()).build()) .build(); - InventoryEntry inventoryEntry = CommercetoolsTestUtils.getProjectRoot() + InventoryEntry inventoryEntry = CommercetoolsTestUtils.getProjectApiRoot() .inventory() .post(inventoryEntryDraft) .executeBlocking() @@ -54,7 +54,7 @@ public static InventoryEntry create() { } public static InventoryEntry delete(final String id) { - InventoryEntry inventoryEntry = CommercetoolsTestUtils.getProjectRoot() + InventoryEntry inventoryEntry = CommercetoolsTestUtils.getProjectApiRoot() .inventory() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryIntegrationTests.java index c4e1be1250e..720773c2bad 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/inventory/InventoryIntegrationTests.java @@ -19,7 +19,7 @@ public void createAndDelete() { .quantityOnStock(10L) .build(); - InventoryEntry inventoryEntry = CommercetoolsTestUtils.getProjectRoot() + InventoryEntry inventoryEntry = CommercetoolsTestUtils.getProjectApiRoot() .inventory() .post(inventoryEntryDraft) .executeBlocking() @@ -29,7 +29,7 @@ public void createAndDelete() { Assert.assertEquals(inventoryEntry.getSku(), inventoryEntryDraft.getSku()); Assert.assertEquals(inventoryEntry.getQuantityOnStock(), inventoryEntryDraft.getQuantityOnStock()); - InventoryEntry deletedInventoryEntry = CommercetoolsTestUtils.getProjectRoot() + InventoryEntry deletedInventoryEntry = CommercetoolsTestUtils.getProjectApiRoot() .inventory() .withId(inventoryEntry.getId()) .delete() @@ -43,7 +43,7 @@ public void createAndDelete() { @Test public void getById() { InventoryEntryFixtures.withInventoryEntry(inventoryEntry -> { - InventoryEntry queriedInventoryEntry = CommercetoolsTestUtils.getProjectRoot() + InventoryEntry queriedInventoryEntry = CommercetoolsTestUtils.getProjectApiRoot() .inventory() .withId(inventoryEntry.getId()) .get() @@ -57,7 +57,7 @@ public void getById() { @Test public void query() { InventoryEntryFixtures.withInventoryEntry(inventoryEntry -> { - InventoryPagedQueryResponse inventoryPagedQueryResponse = CommercetoolsTestUtils.getProjectRoot() + InventoryPagedQueryResponse inventoryPagedQueryResponse = CommercetoolsTestUtils.getProjectApiRoot() .inventory() .get() .withWhere("id=" + "\"" + inventoryEntry.getId() + "\"") @@ -74,7 +74,7 @@ public void update() { List updateActions = new ArrayList<>(); updateActions.add(InventoryEntrySetRestockableInDaysActionBuilder.of().restockableInDays(10L).build()); - InventoryEntry updatedInventoryEntry = CommercetoolsTestUtils.getProjectRoot() + InventoryEntry updatedInventoryEntry = CommercetoolsTestUtils.getProjectApiRoot() .inventory() .withId(inventoryEntry.getId()) .post(InventoryEntryUpdateBuilder.of() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/me/MyCartsFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/me/MyCartsFixtures.java index 9e9bfa6cee7..e69d28ca3bd 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/me/MyCartsFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/me/MyCartsFixtures.java @@ -31,7 +31,7 @@ public static void withUpdateableMeCart(final UnaryOperator operator) { } public static Cart createMeCart(final MyCartDraft myCartDraft) { - Cart myCart = CommercetoolsTestUtils.getProjectRoot() + Cart myCart = CommercetoolsTestUtils.getProjectApiRoot() .me() .carts() .post(myCartDraft) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/message/MessageIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/message/MessageIntegrationTests.java index d0ab7ebc7fd..257fc579b3d 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/message/MessageIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/message/MessageIntegrationTests.java @@ -17,7 +17,7 @@ public void query() { Product product = ProductFixtures.createProduct(); ProductFixtures.deleteProductById(product.getId(), product.getVersion()); - MessagePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + MessagePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .messages() .get() .executeBlocking() @@ -32,14 +32,14 @@ public void getById() { Product product = ProductFixtures.createProduct(); ProductFixtures.deleteProductById(product.getId(), product.getVersion()); - MessagePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + MessagePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .messages() .get() .executeBlocking() .getBody(); String messageId = response.getResults().get(0).getId(); - Message message = CommercetoolsTestUtils.getProjectRoot() + Message message = CommercetoolsTestUtils.getProjectApiRoot() .messages() .withId(messageId) .get() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/misc/UserAgentHeaderTest.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/misc/UserAgentHeaderTest.java index b58821f609a..74293d18503 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/misc/UserAgentHeaderTest.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/misc/UserAgentHeaderTest.java @@ -15,7 +15,7 @@ public class UserAgentHeaderTest { @Ignore @Test public void execute() { - ByProjectKeyCategoriesGet request = CommercetoolsTestUtils.getProjectRoot().categories().get(); + ByProjectKeyCategoriesGet request = CommercetoolsTestUtils.getProjectApiRoot().categories().get(); VrapHttpClient vrapHttpClient = HttpClientSupplier.of().get(); diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/oauth/GlobalCustomerPasswordAuthIntegrationTest.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/oauth/GlobalCustomerPasswordAuthIntegrationTest.java index 69262c3dde0..6a32247b7ad 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/oauth/GlobalCustomerPasswordAuthIntegrationTest.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/oauth/GlobalCustomerPasswordAuthIntegrationTest.java @@ -32,7 +32,7 @@ public void execute() { .password(password) .build(); - Customer customer = CommercetoolsTestUtils.getProjectRoot() + Customer customer = CommercetoolsTestUtils.getProjectApiRoot() .customers() .post(customerDraft) .executeBlocking() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/order/OrdersFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/order/OrdersFixtures.java index 3df17cc2aee..95e20e8c0e6 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/order/OrdersFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/order/OrdersFixtures.java @@ -9,7 +9,7 @@ public class OrdersFixtures { public static Order deleteOrder(final String id, final Long version) { - Order order = CommercetoolsTestUtils.getProjectRoot() + Order order = CommercetoolsTestUtils.getProjectApiRoot() .orders() .withId(id) .delete() @@ -24,7 +24,7 @@ public static Order deleteOrder(final String id, final Long version) { } public static OrderEdit deleteOrderEdit(final String id, final Long version) { - OrderEdit orderEdit = CommercetoolsTestUtils.getProjectRoot() + OrderEdit orderEdit = CommercetoolsTestUtils.getProjectApiRoot() .orders() .edits() .withId(id) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java index 1f936fb2e85..b277318eda0 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductFixtures.java @@ -105,7 +105,7 @@ public static Product createProduct() { .build()) .build(); - ProductType productType = CommercetoolsTestUtils.getProjectRoot() + ProductType productType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .post(productTypeDraft) .executeBlocking() @@ -119,7 +119,7 @@ public static Product createProduct() { CustomerGroup customerGroup = CustomerGroupFixtures.createCustomerGroup(); Channel channel = ChannelFixtures.createChannel(); - ProductDiscountPagedQueryResponse existing = CommercetoolsTestUtils.getProjectRoot() + ProductDiscountPagedQueryResponse existing = CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .get() .withWhere("sortOrder=\"0.3\"") @@ -129,7 +129,7 @@ public static Product createProduct() { if (existing.getCount() != 0) { String productDiscountId = existing.getResults().get(0).getId(); Long productDiscountVersion = existing.getResults().get(0).getVersion(); - CommercetoolsTestUtils.getProjectRoot() + CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .withId(productDiscountId) .delete() @@ -146,7 +146,7 @@ public static Product createProduct() { .isActive(true) .build(); - ProductDiscount productDiscount = CommercetoolsTestUtils.getProjectRoot() + ProductDiscount productDiscount = CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .post(productDiscountDraft) .executeBlocking() @@ -204,7 +204,7 @@ public static Product createProduct() { .key(CommercetoolsTestUtils.randomKey()) .build(); - State state = CommercetoolsTestUtils.getProjectRoot().states().post(stateDraft).executeBlocking().getBody(); + State state = CommercetoolsTestUtils.getProjectApiRoot().states().post(stateDraft).executeBlocking().getBody(); ProductDraft productDraft = ProductDraftBuilder.of() .key(randomKey) @@ -223,7 +223,7 @@ public static Product createProduct() { .publish(false) .build(); - Product product = CommercetoolsTestUtils.getProjectRoot() + Product product = CommercetoolsTestUtils.getProjectApiRoot() .products() .post(productDraft) .executeBlocking() @@ -239,7 +239,7 @@ public static Product deleteProduct(Product product) { try { rProduct = CompletableFuture.completedFuture(product).thenComposeAsync(product1 -> { if (product1.getMasterData().getPublished()) { - return CommercetoolsTestUtils.getProjectRoot() + return CommercetoolsTestUtils.getProjectApiRoot() .products() .withId(product1.getId()) .post(ProductUpdateBuilder.of() @@ -251,7 +251,7 @@ public static Product deleteProduct(Product product) { } return CompletableFuture.completedFuture(product1); }) - .thenComposeAsync(product1 -> CommercetoolsTestUtils.getProjectRoot() + .thenComposeAsync(product1 -> CommercetoolsTestUtils.getProjectApiRoot() .products() .withId(product1.getId()) .delete() @@ -271,7 +271,7 @@ public static Product deleteProduct(Product product) { public static Product deleteProductById(final String id, final Long version) { Product product = null; try { - product = CommercetoolsTestUtils.getProjectRoot() + product = CommercetoolsTestUtils.getProjectApiRoot() .products() .withId(id) .get() @@ -279,7 +279,7 @@ public static Product deleteProductById(final String id, final Long version) { .thenComposeAsync(productApiHttpResponse -> { Product product1 = productApiHttpResponse.getBody(); if (product1.getMasterData().getPublished()) { - return CommercetoolsTestUtils.getProjectRoot() + return CommercetoolsTestUtils.getProjectApiRoot() .products() .withId(product1.getId()) .post(ProductUpdateBuilder.of() @@ -290,7 +290,7 @@ public static Product deleteProductById(final String id, final Long version) { } return CompletableFuture.completedFuture(productApiHttpResponse); }) - .thenComposeAsync(productApiHttpResponse -> CommercetoolsTestUtils.getProjectRoot() + .thenComposeAsync(productApiHttpResponse -> CommercetoolsTestUtils.getProjectApiRoot() .products() .withId(productApiHttpResponse.getBody().getId()) .delete() @@ -308,7 +308,7 @@ public static Product deleteProductById(final String id, final Long version) { } public static Product deleteProductByKey(final String key, final Long version) { - Product product = CommercetoolsTestUtils.getProjectRoot() + Product product = CommercetoolsTestUtils.getProjectApiRoot() .products() .withKey(key) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java index be08f3e6581..9a5458f96f0 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java @@ -8,6 +8,7 @@ import java.util.List; import com.commercetools.api.client.ByProjectKeyRequestBuilder; +import com.commercetools.api.client.ProjectApiRoot; import com.commercetools.api.models.common.LocalizedString; import com.commercetools.api.models.product.*; import commercetools.utils.CommercetoolsTestUtils; @@ -30,7 +31,7 @@ public void createAndDeleteById() { @Test public void getById() { ProductFixtures.withProduct(product -> { - Product queriedProduct = CommercetoolsTestUtils.getProjectRoot() + Product queriedProduct = CommercetoolsTestUtils.getProjectApiRoot() .products() .withId(product.getId()) .get() @@ -44,7 +45,7 @@ public void getById() { @Test public void getByKey() { ProductFixtures.withProduct(product -> { - Product queriedProduct = CommercetoolsTestUtils.getProjectRoot() + Product queriedProduct = CommercetoolsTestUtils.getProjectApiRoot() .products() .withKey(product.getKey()) .get() @@ -62,7 +63,7 @@ public void updateById() { LocalizedString newName = CommercetoolsTestUtils.randomLocalizedString(); updateActions.add(ProductChangeNameActionBuilder.of().name(newName).build()); - Product updatedProduct = CommercetoolsTestUtils.getProjectRoot() + Product updatedProduct = CommercetoolsTestUtils.getProjectApiRoot() .products() .withId(product.getId()) .post(ProductUpdateBuilder.of().actions(updateActions).version(product.getVersion()).build()) @@ -82,7 +83,7 @@ public void updateByKey() { LocalizedString newName = CommercetoolsTestUtils.randomLocalizedString(); updateActions.add(ProductChangeNameActionBuilder.of().name(newName).build()); - Product updatedProduct = CommercetoolsTestUtils.getProjectRoot() + Product updatedProduct = CommercetoolsTestUtils.getProjectApiRoot() .products() .withKey(product.getKey()) .post(ProductUpdateBuilder.of().actions(updateActions).version(product.getVersion()).build()) @@ -98,7 +99,7 @@ public void updateByKey() { @Test public void query() { ProductFixtures.withProduct(product -> { - ProductPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ProductPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .products() .get() .withWhere("id=" + "\"" + product.getId() + "\"") @@ -126,7 +127,7 @@ public void upload() { imageFile = new File("src/integrationTest/resources/ct_logo_farbe.gif"); } - final ByProjectKeyRequestBuilder projectRoot = CommercetoolsTestUtils.getProjectRoot(); + final ProjectApiRoot projectRoot = CommercetoolsTestUtils.getProjectApiRoot(); final Product result = projectRoot.products() .withId(product.getId()) .images() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_discount/ProductDiscountFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_discount/ProductDiscountFixtures.java index 9956affdc11..f234559a126 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_discount/ProductDiscountFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_discount/ProductDiscountFixtures.java @@ -27,7 +27,7 @@ public static void withUpdateableProductDiscount(final UnaryOperator { - ProductDiscount queriedProductDiscount = CommercetoolsTestUtils.getProjectRoot() + ProductDiscount queriedProductDiscount = CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .withId(productDiscount.getId()) .get() @@ -67,7 +67,7 @@ public void getById() { @Test public void getByKey() { ProductDiscountFixtures.withProductDiscount(productDiscount -> { - ProductDiscount queriedProductDiscount = CommercetoolsTestUtils.getProjectRoot() + ProductDiscount queriedProductDiscount = CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .withKey(productDiscount.getKey()) .get() @@ -82,7 +82,7 @@ public void getByKey() { @Test public void query() { ProductDiscountFixtures.withProductDiscount(productDiscount -> { - ProductDiscountPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ProductDiscountPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .get() .withWhere("id=" + "\"" + productDiscount.getId() + "\"") @@ -100,7 +100,7 @@ public void updateById() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ProductDiscountSetKeyActionBuilder.of().key(newKey).build()); - ProductDiscount updatedProductDiscount = CommercetoolsTestUtils.getProjectRoot() + ProductDiscount updatedProductDiscount = CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .withId(productDiscount.getId()) .post(ProductDiscountUpdateBuilder.of() @@ -122,7 +122,7 @@ public void updateByKey() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ProductDiscountSetKeyActionBuilder.of().key(newKey).build()); - ProductDiscount updatedProductDiscount = CommercetoolsTestUtils.getProjectRoot() + ProductDiscount updatedProductDiscount = CommercetoolsTestUtils.getProjectApiRoot() .productDiscounts() .withKey(productDiscount.getKey()) .post(ProductDiscountUpdateBuilder.of() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_projection/ProductProjectionIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_projection/ProductProjectionIntegrationTests.java index cb61acba363..33796e8656a 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_projection/ProductProjectionIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_projection/ProductProjectionIntegrationTests.java @@ -18,7 +18,7 @@ public class ProductProjectionIntegrationTests { @Test public void getById() { ProductFixtures.withProduct(product -> { - ProductProjection productProjection = CommercetoolsTestUtils.getProjectRoot() + ProductProjection productProjection = CommercetoolsTestUtils.getProjectApiRoot() .productProjections() .withId(product.getId()) .get() @@ -33,7 +33,7 @@ public void getById() { @Test public void getByKey() { ProductFixtures.withProduct(product -> { - ProductProjection productProjection = CommercetoolsTestUtils.getProjectRoot() + ProductProjection productProjection = CommercetoolsTestUtils.getProjectApiRoot() .productProjections() .withKey(product.getKey()) .get() @@ -49,7 +49,7 @@ public void getByKey() { public void query() { ProductFixtures.withProduct(product -> { ProductProjectionPagedQueryResponse productProjectionPagedQueryResponse = CommercetoolsTestUtils - .getProjectRoot() + .getProjectApiRoot() .productProjections() .get() .withStaged(true) @@ -64,7 +64,7 @@ public void query() { @Test public void search() { ProductFixtures.withProduct(product -> { - ProductProjectionPagedSearchResponse searchResponse = CommercetoolsTestUtils.getProjectRoot() + ProductProjectionPagedSearchResponse searchResponse = CommercetoolsTestUtils.getProjectApiRoot() .productProjections() .search() .get() @@ -81,7 +81,7 @@ public void search() { @Test public void attribute() { ProductFixtures.withProduct(product -> { - ProductProjection productProjection = CommercetoolsTestUtils.getProjectRoot() + ProductProjection productProjection = CommercetoolsTestUtils.getProjectApiRoot() .productProjections() .withKey(product.getKey()) .get() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeFixtures.java index 0c56da18488..f2f0dee006a 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeFixtures.java @@ -44,7 +44,7 @@ public static ProductType createProductType() { .attributes(Arrays.asList(attributeDefinitionDraft)) .build(); - ProductType productType = CommercetoolsTestUtils.getProjectRoot() + ProductType productType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .post(productTypeDraft) .executeBlocking() @@ -58,7 +58,7 @@ public static ProductType createProductType() { } public static ProductType deleteProductType(final String id, final Long version) { - ProductType deletedProductType = CommercetoolsTestUtils.getProjectRoot() + ProductType deletedProductType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeIntegrationTests.java index 48145a7b7c9..d9ffbde88c5 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product_type/ProductTypeIntegrationTests.java @@ -24,7 +24,7 @@ public void createAndDeleteById() { @Test public void getById() { ProductTypeFixtures.withProductType(productType -> { - ProductType queriedProductType = CommercetoolsTestUtils.getProjectRoot() + ProductType queriedProductType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .withId(productType.getId()) .get() @@ -39,7 +39,7 @@ public void getById() { @Test public void getByKey() { ProductTypeFixtures.withProductType(productType -> { - ProductType queriedProductType = CommercetoolsTestUtils.getProjectRoot() + ProductType queriedProductType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .withKey(productType.getKey()) .get() @@ -54,7 +54,7 @@ public void getByKey() { @Test public void query() { ProductTypeFixtures.withProductType(productType -> { - ProductTypePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ProductTypePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .get() .withWhere("id=" + "\"" + productType.getId() + "\"") @@ -72,7 +72,7 @@ public void updateById() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ProductTypeSetKeyActionBuilder.of().key(newKey).build()); - ProductType updatedProductType = CommercetoolsTestUtils.getProjectRoot() + ProductType updatedProductType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .withId(productType.getId()) .post( @@ -93,7 +93,7 @@ public void updateByKey() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ProductTypeSetKeyActionBuilder.of().key(newKey).build()); - ProductType updatedProductType = CommercetoolsTestUtils.getProjectRoot() + ProductType updatedProductType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .withKey(productType.getKey()) .post( @@ -111,7 +111,7 @@ public void updateByKey() { @Test public void deleteByKey() { ProductType productType = ProductTypeFixtures.createProductType(); - ProductType deletedProductType = CommercetoolsTestUtils.getProjectRoot() + ProductType deletedProductType = CommercetoolsTestUtils.getProjectApiRoot() .productTypes() .withKey(productType.getKey()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/project/ProjectIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/project/ProjectIntegrationTests.java index e97ef2eefa6..1960144c91f 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/project/ProjectIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/project/ProjectIntegrationTests.java @@ -19,7 +19,7 @@ public class ProjectIntegrationTests { @Test public void byKeyGet() throws Exception { String projectKey = CommercetoolsTestUtils.getProjectKey(); - Project project = CommercetoolsTestUtils.getProjectRoot().get().executeBlocking().getBody(); + Project project = CommercetoolsTestUtils.getProjectApiRoot().get().executeBlocking().getBody(); Assert.assertNotNull(project); Assert.assertEquals(projectKey, project.getKey()); } @@ -29,8 +29,8 @@ public void updateProject() throws Exception { List countries = Arrays.asList("DE"); List updateActions = new ArrayList<>(); updateActions.add(ProjectChangeCountriesActionBuilder.of().countries(countries).build()); - Project project = CommercetoolsTestUtils.getProjectRoot().get().executeBlocking().getBody(); - Project updatedProject = CommercetoolsTestUtils.getProjectRoot() + Project project = CommercetoolsTestUtils.getProjectApiRoot().get().executeBlocking().getBody(); + Project updatedProject = CommercetoolsTestUtils.getProjectApiRoot() .post(ProjectUpdateBuilder.of().actions(updateActions).version(project.getVersion()).build()) .executeBlocking() .getBody(); diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/request_errors/CategoryErrorHandlingIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/request_errors/CategoryErrorHandlingIntegrationTests.java index aeedb56a373..5b7060e104f 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/request_errors/CategoryErrorHandlingIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/request_errors/CategoryErrorHandlingIntegrationTests.java @@ -16,7 +16,7 @@ public class CategoryErrorHandlingIntegrationTests { @Test(expected = RuntimeException.class) public void getByNonExistingIdBlocking() { CategoryFixtures.withCategory(category -> { - CommercetoolsTestUtils.getProjectRoot() + CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId("non-existing") .get() @@ -28,7 +28,7 @@ public void getByNonExistingIdBlocking() { @Test public void getByNonExistingIdNonBlocking() { CategoryFixtures.withCategory(category -> { - CommercetoolsTestUtils.getProjectRoot() + CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId("non-existing") .get() @@ -46,7 +46,7 @@ public void getByNonExistingIdNonBlocking() { @Test public void deleteWithoutVersionNonBlocking() { CategoryFixtures.withUpdateableCategory(category -> { - CommercetoolsTestUtils.getProjectRoot() + CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId(category.getId()) .delete() @@ -67,7 +67,7 @@ public void deleteWithoutVersionNonBlocking() { public void deleteWithoutVersionBlocking() { CategoryFixtures.withUpdateableCategory(category -> { try { - CommercetoolsTestUtils.getProjectRoot() + CommercetoolsTestUtils.getProjectApiRoot() .categories() .withId(category.getId()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java index 7ed331a1bf5..716afefb3d5 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java @@ -42,7 +42,7 @@ public static Review createReview() { .key(CommercetoolsTestUtils.randomKey()) .build(); - State state = CommercetoolsTestUtils.getProjectRoot().states().post(stateDraft).executeBlocking().getBody(); + State state = CommercetoolsTestUtils.getProjectApiRoot().states().post(stateDraft).executeBlocking().getBody(); ReviewDraft reviewDraft = ReviewDraftBuilder.of() .key(CommercetoolsTestUtils.randomKey()) @@ -58,7 +58,7 @@ public static Review createReview() { .customer(CustomerResourceIdentifierBuilder.of().id(customer.getId()).build()) .build(); - Review review = CommercetoolsTestUtils.getProjectRoot().reviews().post(reviewDraft).executeBlocking().getBody(); + Review review = CommercetoolsTestUtils.getProjectApiRoot().reviews().post(reviewDraft).executeBlocking().getBody(); Assert.assertNotNull(review); Assert.assertEquals(reviewDraft.getKey(), review.getKey()); @@ -67,7 +67,7 @@ public static Review createReview() { } public static Review delete(final String id, final Long version) { - Review deletedReview = CommercetoolsTestUtils.getProjectRoot() + Review deletedReview = CommercetoolsTestUtils.getProjectApiRoot() .reviews() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java index 397b19a8857..1bc214c93d5 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java @@ -19,12 +19,12 @@ public void createAndDelete() { .title("review-title-1") .build(); - Review review = CommercetoolsTestUtils.getProjectRoot().reviews().post(reviewDraft).executeBlocking().getBody(); + Review review = CommercetoolsTestUtils.getProjectApiRoot().reviews().post(reviewDraft).executeBlocking().getBody(); Assert.assertNotNull(review); Assert.assertEquals(reviewDraft.getKey(), review.getKey()); - Review deletedReview = CommercetoolsTestUtils.getProjectRoot() + Review deletedReview = CommercetoolsTestUtils.getProjectApiRoot() .reviews() .withId(review.getId()) .delete() @@ -39,7 +39,7 @@ public void createAndDelete() { @Test public void getById() { ReviewFixtures.withReview(review -> { - Review queriedReview = CommercetoolsTestUtils.getProjectRoot() + Review queriedReview = CommercetoolsTestUtils.getProjectApiRoot() .reviews() .withId(review.getId()) .get() @@ -53,7 +53,7 @@ public void getById() { @Test public void getByKey() { ReviewFixtures.withReview(review -> { - Review queriedReview = CommercetoolsTestUtils.getProjectRoot() + Review queriedReview = CommercetoolsTestUtils.getProjectApiRoot() .reviews() .withKey(review.getKey()) .get() @@ -67,7 +67,7 @@ public void getByKey() { @Test public void query() { ReviewFixtures.withReview(review -> { - ReviewPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ReviewPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .reviews() .get() .withWhere("id=" + "\"" + review.getId() + "\"") @@ -85,7 +85,7 @@ public void updateById() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ReviewSetKeyActionBuilder.of().key(newKey).build()); - Review updatedReview = CommercetoolsTestUtils.getProjectRoot() + Review updatedReview = CommercetoolsTestUtils.getProjectApiRoot() .reviews() .withId(review.getId()) .post(ReviewUpdateBuilder.of().actions(updateActions).version(review.getVersion()).build()) @@ -106,7 +106,7 @@ public void updateByKey() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ReviewSetKeyActionBuilder.of().key(newKey).build()); - Review updatedReview = CommercetoolsTestUtils.getProjectRoot() + Review updatedReview = CommercetoolsTestUtils.getProjectApiRoot() .reviews() .withKey(review.getKey()) .post(ReviewUpdateBuilder.of().actions(updateActions).version(review.getVersion()).build()) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodFixtures.java index 3d78c6e4a43..318b8629604 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodFixtures.java @@ -53,7 +53,7 @@ public static ShippingMethod createShippingMethod() { .isDefault(false) .build(); - ShippingMethod shippingMethod = CommercetoolsTestUtils.getProjectRoot() + ShippingMethod shippingMethod = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .post(shippingMethodDraft) .executeBlocking() @@ -66,7 +66,7 @@ public static ShippingMethod createShippingMethod() { } public static ShippingMethod deleteShippingMethod(final String id, final Long version) { - ShippingMethod shippingMethod = CommercetoolsTestUtils.getProjectRoot() + ShippingMethod shippingMethod = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodIntegrationTests.java index 9f1bde59e4d..a4eb98a09e3 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shipping_method/ShippingMethodIntegrationTests.java @@ -21,7 +21,7 @@ public void createAndDeleteById() { @Test public void getById() { ShippingMethodFixtures.withShippingMethod(shippingMethod -> { - ShippingMethod queriedShippingMethod = CommercetoolsTestUtils.getProjectRoot() + ShippingMethod queriedShippingMethod = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .withId(shippingMethod.getId()) .get() @@ -36,7 +36,7 @@ public void getById() { @Test public void getByKey() { ShippingMethodFixtures.withShippingMethod(shippingMethod -> { - ShippingMethod queriedShippingMethod = CommercetoolsTestUtils.getProjectRoot() + ShippingMethod queriedShippingMethod = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .withKey(shippingMethod.getKey()) .get() @@ -51,7 +51,7 @@ public void getByKey() { @Test public void query() { ShippingMethodFixtures.withShippingMethod(shippingMethod -> { - ShippingMethodPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ShippingMethodPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .get() .withWhere("id=" + "\"" + shippingMethod.getId() + "\"") @@ -70,7 +70,7 @@ public void updateById() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ShippingMethodSetKeyActionBuilder.of().key(newKey).build()); - ShippingMethod updatedShippingMethod = CommercetoolsTestUtils.getProjectRoot() + ShippingMethod updatedShippingMethod = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .withId(shippingMethod.getId()) .post(ShippingMethodUpdateBuilder.of() @@ -94,7 +94,7 @@ public void updateByKey() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ShippingMethodSetKeyActionBuilder.of().key(newKey).build()); - ShippingMethod updatedShippingMethod = CommercetoolsTestUtils.getProjectRoot() + ShippingMethod updatedShippingMethod = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .withKey(shippingMethod.getKey()) .post(ShippingMethodUpdateBuilder.of() @@ -114,7 +114,7 @@ public void updateByKey() { @Test public void deleteByKey() { ShippingMethod shippingMethod = ShippingMethodFixtures.createShippingMethod(); - ShippingMethod deletedShippingMethod = CommercetoolsTestUtils.getProjectRoot() + ShippingMethod deletedShippingMethod = CommercetoolsTestUtils.getProjectApiRoot() .shippingMethods() .withKey(shippingMethod.getKey()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListFixtures.java index 3f03177e2be..706adb863ff 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListFixtures.java @@ -51,7 +51,7 @@ public static ShoppingList createShoppingList() { .deleteDaysAfterLastModification(2L) .build(); - ShoppingList shoppingList = CommercetoolsTestUtils.getProjectRoot() + ShoppingList shoppingList = CommercetoolsTestUtils.getProjectApiRoot() .shoppingLists() .post(shoppingListDraft) .executeBlocking() @@ -64,7 +64,7 @@ public static ShoppingList createShoppingList() { } public static ShoppingList deleteShoppingList(final String id, final Long version) { - ShoppingList shoppingList = CommercetoolsTestUtils.getProjectRoot() + ShoppingList shoppingList = CommercetoolsTestUtils.getProjectApiRoot() .shoppingLists() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListIntegrationTests.java index 968ffd66baa..d90acd2c748 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/shopping_list/ShoppingListIntegrationTests.java @@ -21,7 +21,7 @@ public void createAndDeleteById() { @Test public void getById() { ShoppingListFixtures.withShoppingList(shoppingList -> { - ShoppingList queriedShoppingList = CommercetoolsTestUtils.getProjectRoot() + ShoppingList queriedShoppingList = CommercetoolsTestUtils.getProjectApiRoot() .shoppingLists() .withId(shoppingList.getId()) .get() @@ -36,7 +36,7 @@ public void getById() { @Test public void getByKey() { ShoppingListFixtures.withShoppingList(shoppingList -> { - ShoppingList queriedShoppingList = CommercetoolsTestUtils.getProjectRoot() + ShoppingList queriedShoppingList = CommercetoolsTestUtils.getProjectApiRoot() .shoppingLists() .withKey(shoppingList.getKey()) .get() @@ -51,7 +51,7 @@ public void getByKey() { @Test public void query() { ShoppingListFixtures.withShoppingList(shoppingList -> { - ShoppingListPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ShoppingListPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .shoppingLists() .get() .withWhere("id=" + "\"" + shoppingList.getId() + "\"") @@ -71,7 +71,7 @@ public void updateByKey() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ShoppingListSetKeyActionBuilder.of().key(newKey).build()); - ShoppingList updatedShoppingList = CommercetoolsTestUtils.getProjectRoot() + ShoppingList updatedShoppingList = CommercetoolsTestUtils.getProjectApiRoot() .shoppingLists() .withKey(shoppingList.getKey()) .post(ShoppingListUpdateBuilder.of() @@ -96,7 +96,7 @@ public void updateById() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ShoppingListSetKeyActionBuilder.of().key(newKey).build()); - ShoppingList updatedShoppingList = CommercetoolsTestUtils.getProjectRoot() + ShoppingList updatedShoppingList = CommercetoolsTestUtils.getProjectApiRoot() .shoppingLists() .withId(shoppingList.getId()) .post(ShoppingListUpdateBuilder.of() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateFixtures.java index 7bab0e8727e..78bbd45ee69 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateFixtures.java @@ -31,7 +31,7 @@ public static State createState() { .roles(Arrays.asList(StateRoleEnum.RETURN)) .build(); - State state = CommercetoolsTestUtils.getProjectRoot().states().post(stateDraft).executeBlocking().getBody(); + State state = CommercetoolsTestUtils.getProjectApiRoot().states().post(stateDraft).executeBlocking().getBody(); Assert.assertNotNull(state); Assert.assertEquals(stateDraft.getKey(), state.getKey()); @@ -40,7 +40,7 @@ public static State createState() { } public static State deleteState(final String id, final Long version) { - State state = CommercetoolsTestUtils.getProjectRoot() + State state = CommercetoolsTestUtils.getProjectApiRoot() .states() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateIntegrationTests.java index 41501640f12..1139dde1ce9 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/state/StateIntegrationTests.java @@ -22,7 +22,7 @@ public void createAndDeleteById() { @Test public void getById() { StateFixtures.withState(state -> { - State queriedState = CommercetoolsTestUtils.getProjectRoot() + State queriedState = CommercetoolsTestUtils.getProjectApiRoot() .states() .withId(state.getId()) .get() @@ -37,7 +37,7 @@ public void getById() { @Test public void query() { StateFixtures.withState(state -> { - StatePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + StatePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .states() .get() .withWhere("id=" + "\"" + state.getId() + "\"") @@ -55,7 +55,7 @@ public void update() { List updateActions = new ArrayList<>(); String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(StateChangeKeyActionBuilder.of().key(newKey).build()); - State updatedState = CommercetoolsTestUtils.getProjectRoot() + State updatedState = CommercetoolsTestUtils.getProjectApiRoot() .states() .withId(state.getId()) .post(StateUpdateBuilder.of().actions(updateActions).version(state.getVersion()).build()) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreFixtures.java index 55c68a425da..32aa30b6566 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreFixtures.java @@ -28,7 +28,7 @@ public static void withUpdateableStore(final UnaryOperator operator) { public static Store createStore() { StoreDraft storeDraft = StoreDraftBuilder.of().key(CommercetoolsTestUtils.randomKey()).build(); - Store store = CommercetoolsTestUtils.getProjectRoot().stores().post(storeDraft).executeBlocking().getBody(); + Store store = CommercetoolsTestUtils.getProjectApiRoot().stores().post(storeDraft).executeBlocking().getBody(); Assert.assertNotNull(store); Assert.assertEquals(storeDraft.getKey(), store.getKey()); @@ -37,7 +37,7 @@ public static Store createStore() { } public static Store deleteStore(final String id, final Long version) { - Store store = CommercetoolsTestUtils.getProjectRoot() + Store store = CommercetoolsTestUtils.getProjectApiRoot() .stores() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreIntegrationTests.java index 71f05cd917f..4e4e8bb44c8 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/store/StoreIntegrationTests.java @@ -24,7 +24,7 @@ public void createAndDeleteById() { @Test public void getById() { StoreFixtures.withStore(store -> { - Store queriedStore = CommercetoolsTestUtils.getProjectRoot() + Store queriedStore = CommercetoolsTestUtils.getProjectApiRoot() .stores() .withId(store.getId()) .get() @@ -39,7 +39,7 @@ public void getById() { @Test public void getByKey() { StoreFixtures.withStore(store -> { - Store queriedStore = CommercetoolsTestUtils.getProjectRoot() + Store queriedStore = CommercetoolsTestUtils.getProjectApiRoot() .stores() .withKey(store.getKey()) .get() @@ -54,7 +54,7 @@ public void getByKey() { @Test public void query() { StoreFixtures.withStore(store -> { - StorePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + StorePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .stores() .get() .withWhere("id=" + "\"" + store.getId() + "\"") @@ -73,7 +73,7 @@ public void updateById() { LocalizedString newName = CommercetoolsTestUtils.randomLocalizedString(); updateActions.add(StoreSetNameActionBuilder.of().name(newName).build()); - Store updatedStore = CommercetoolsTestUtils.getProjectRoot() + Store updatedStore = CommercetoolsTestUtils.getProjectApiRoot() .stores() .withId(store.getId()) .post(StoreUpdateBuilder.of().actions(updateActions).version(store.getVersion()).build()) @@ -93,7 +93,7 @@ public void updateByKey() { LocalizedString newName = CommercetoolsTestUtils.randomLocalizedString(); updateActions.add(StoreSetNameActionBuilder.of().name(newName).build()); - Store updatedStore = CommercetoolsTestUtils.getProjectRoot() + Store updatedStore = CommercetoolsTestUtils.getProjectApiRoot() .stores() .withKey(store.getKey()) .post(StoreUpdateBuilder.of().actions(updateActions).version(store.getVersion()).build()) @@ -109,7 +109,7 @@ public void updateByKey() { @Test public void deleteByKey() { Store store = StoreFixtures.createStore(); - Store deletedStore = CommercetoolsTestUtils.getProjectRoot() + Store deletedStore = CommercetoolsTestUtils.getProjectApiRoot() .stores() .withKey(store.getKey()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/subscription/SubscriptionFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/subscription/SubscriptionFixtures.java index a969f4831b5..0c18f478f0e 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/subscription/SubscriptionFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/subscription/SubscriptionFixtures.java @@ -32,7 +32,7 @@ public static Subscription createSubscription() { .messages(Arrays.asList(MessageSubscriptionBuilder.of().resourceTypeId("review").build())) .build(); - Subscription subscription = CommercetoolsTestUtils.getProjectRoot() + Subscription subscription = CommercetoolsTestUtils.getProjectApiRoot() .subscriptions() .post(subscriptionDraft) .executeBlocking() @@ -44,7 +44,7 @@ public static Subscription createSubscription() { } public static Subscription deleteSubscription(final String id, final Long version) { - Subscription subscription = CommercetoolsTestUtils.getProjectRoot() + Subscription subscription = CommercetoolsTestUtils.getProjectApiRoot() .subscriptions() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryFixtures.java index 248d6b78a1e..1f9a8282d1a 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryFixtures.java @@ -40,7 +40,7 @@ public static TaxCategory createTaxCategory() { .build()) .build(); - TaxCategory taxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory taxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .post(taxCategoryDraft) .executeBlocking() @@ -54,7 +54,7 @@ public static TaxCategory createTaxCategory() { } public static TaxCategory deleteTaxCategory(final String id, final Long version) { - TaxCategory deletedTaxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory deletedTaxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryIntegrationTests.java index b0b2b4b0221..b419fc2dd5b 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/tax_category/TaxCategoryIntegrationTests.java @@ -26,7 +26,7 @@ public void createAndDelete() { .build()) .build(); - TaxCategory taxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory taxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .post(taxCategoryDraft) .executeBlocking() @@ -36,7 +36,7 @@ public void createAndDelete() { Assert.assertEquals(taxCategoryDraft.getName(), taxCategory.getName()); Assert.assertEquals(taxCategoryDraft.getKey(), taxCategory.getKey()); - TaxCategory deletedTaxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory deletedTaxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .withId(taxCategory.getId()) .delete() @@ -51,7 +51,7 @@ public void createAndDelete() { @Test public void getById() { TaxCategoryFixtures.withTaxCategory(taxCategory -> { - TaxCategory queriedTaxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory queriedTaxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .withId(taxCategory.getId()) .get() @@ -66,7 +66,7 @@ public void getById() { @Test public void getByKey() { TaxCategoryFixtures.withTaxCategory(taxCategory -> { - TaxCategory queriedTaxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory queriedTaxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .withKey(taxCategory.getKey()) .get() @@ -81,7 +81,7 @@ public void getByKey() { @Test public void query() { TaxCategoryFixtures.withTaxCategory(taxCategory -> { - TaxCategoryPagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + TaxCategoryPagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .get() .withWhere("id=" + "\"" + taxCategory.getId() + "\"") @@ -101,7 +101,7 @@ public void updateById() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(TaxCategorySetKeyActionBuilder.of().key(newKey).build()); - TaxCategory updatedTaxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory updatedTaxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .withId(taxCategory.getId()) .post( @@ -124,7 +124,7 @@ public void updateByIKey() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(TaxCategorySetKeyActionBuilder.of().key(newKey).build()); - TaxCategory updatedTaxCategory = CommercetoolsTestUtils.getProjectRoot() + TaxCategory updatedTaxCategory = CommercetoolsTestUtils.getProjectApiRoot() .taxCategories() .withKey(taxCategory.getKey()) .post( diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeFixtures.java index c2706836dd5..853a776692b 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeFixtures.java @@ -38,7 +38,7 @@ public static Type createType() { .build())) .build(); - Type type = CommercetoolsTestUtils.getProjectRoot().types().post(typeDraft).executeBlocking().getBody(); + Type type = CommercetoolsTestUtils.getProjectApiRoot().types().post(typeDraft).executeBlocking().getBody(); Assert.assertNotNull(type); Assert.assertEquals(type.getKey(), typeDraft.getKey()); @@ -47,7 +47,7 @@ public static Type createType() { } public static Type deleteType(final String id, final Long version) { - Type type = CommercetoolsTestUtils.getProjectRoot() + Type type = CommercetoolsTestUtils.getProjectApiRoot() .types() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeIntegrationTests.java index cd1a37111ab..13bd0b85d8b 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/type/TypeIntegrationTests.java @@ -23,7 +23,7 @@ public void createAndDeleteById() { @Test public void getById() { TypeFixtures.withType(type -> { - Type queriedType = CommercetoolsTestUtils.getProjectRoot() + Type queriedType = CommercetoolsTestUtils.getProjectApiRoot() .types() .withId(type.getId()) .get() @@ -38,7 +38,7 @@ public void getById() { @Test public void getByKey() { TypeFixtures.withType(type -> { - Type queriedType = CommercetoolsTestUtils.getProjectRoot() + Type queriedType = CommercetoolsTestUtils.getProjectApiRoot() .types() .withKey(type.getKey()) .get() @@ -53,7 +53,7 @@ public void getByKey() { @Test public void query() { TypeFixtures.withType(type -> { - TypePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + TypePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .types() .get() .withWhere("id=" + "\"" + type.getId() + "\"") @@ -72,7 +72,7 @@ public void updateById() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(TypeChangeKeyActionBuilder.of().key(newKey).build()); - Type updatedType = CommercetoolsTestUtils.getProjectRoot() + Type updatedType = CommercetoolsTestUtils.getProjectApiRoot() .types() .withId(type.getId()) .post(TypeUpdateBuilder.of().actions(updateActions).version(type.getVersion()).build()) @@ -93,7 +93,7 @@ public void updateByKey() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(TypeChangeKeyActionBuilder.of().key(newKey).build()); - Type updatedType = CommercetoolsTestUtils.getProjectRoot() + Type updatedType = CommercetoolsTestUtils.getProjectApiRoot() .types() .withKey(type.getKey()) .post(TypeUpdateBuilder.of().actions(updateActions).version(type.getVersion()).build()) @@ -110,7 +110,7 @@ public void updateByKey() { @Test public void deleteByKey() { Type type = TypeFixtures.createType(); - Type deletedType = CommercetoolsTestUtils.getProjectRoot() + Type deletedType = CommercetoolsTestUtils.getProjectApiRoot() .types() .withKey(type.getKey()) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java index a6bffee9c6b..b3b6f086ee0 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java @@ -16,8 +16,6 @@ public class CommercetoolsTestUtils { - private static final ApiHttpClient client; - private static final ByProjectKeyRequestBuilder projectRoot; private static final ProjectApiRoot projectApiRoot; static { @@ -31,8 +29,6 @@ public class CommercetoolsTestUtils { .defaultClient( ClientCredentials.of().withClientId(getClientId()).withClientSecret(getClientSecret()).build(), authURL, apiUrl); - client = builder.buildClient(); - projectRoot = ApiRootBuilder.createForProject(getProjectKey(), client); projectApiRoot = builder.build(getProjectKey()); } @@ -66,18 +62,10 @@ public static String getClientSecret() { return System.getenv("CTP_CLIENT_SECRET"); } - public static ByProjectKeyRequestBuilder getProjectRoot() { - return projectRoot; - } - public static ProjectApiRoot getProjectApiRoot() { return projectApiRoot; } - public static ApiHttpClient getClient() { - return client; - } - public static void assertEventually(final Duration maxWaitTime, final Duration waitBeforeRetry, final Runnable block) { final long timeOutAt = System.currentTimeMillis() + maxWaitTime.toMillis(); diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneFixtures.java index ef766b4d495..217b338cb33 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneFixtures.java @@ -32,7 +32,7 @@ public static Zone createZone() { .description(CommercetoolsTestUtils.randomString()) .build(); - Zone zone = CommercetoolsTestUtils.getProjectRoot().zones().post(zoneDraft).executeBlocking().getBody(); + Zone zone = CommercetoolsTestUtils.getProjectApiRoot().zones().post(zoneDraft).executeBlocking().getBody(); Assert.assertNotNull(zone); Assert.assertEquals(zoneDraft.getKey(), zone.getKey()); @@ -41,7 +41,7 @@ public static Zone createZone() { } public static Zone deleteZone(final String id, final Long version) { - Zone zone = CommercetoolsTestUtils.getProjectRoot() + Zone zone = CommercetoolsTestUtils.getProjectApiRoot() .zones() .withId(id) .delete() diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneIntegrationTests.java index f7589141a43..47b744296d7 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/zone/ZoneIntegrationTests.java @@ -24,7 +24,7 @@ public void createAndDeleteById() { @Test public void getById() { ZoneFixtures.withZone(zone -> { - Zone queriedZone = CommercetoolsTestUtils.getProjectRoot() + Zone queriedZone = CommercetoolsTestUtils.getProjectApiRoot() .zones() .withId(zone.getId()) .get() @@ -39,7 +39,7 @@ public void getById() { @Test public void getByKey() { ZoneFixtures.withZone(zone -> { - Zone queriedZone = CommercetoolsTestUtils.getProjectRoot() + Zone queriedZone = CommercetoolsTestUtils.getProjectApiRoot() .zones() .withKey(zone.getKey()) .get() @@ -54,7 +54,7 @@ public void getByKey() { @Test public void query() { ZoneFixtures.withZone(zone -> { - ZonePagedQueryResponse response = CommercetoolsTestUtils.getProjectRoot() + ZonePagedQueryResponse response = CommercetoolsTestUtils.getProjectApiRoot() .zones() .get() .withWhere("id=" + "\"" + zone.getId() + "\"") @@ -73,7 +73,7 @@ public void updateById() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ZoneSetKeyActionBuilder.of().key(newKey).build()); - Zone updatedZone = CommercetoolsTestUtils.getProjectRoot() + Zone updatedZone = CommercetoolsTestUtils.getProjectApiRoot() .zones() .withId(zone.getId()) .post(ZoneUpdateBuilder.of().actions(updateActions).version(zone.getVersion()).build()) @@ -94,7 +94,7 @@ public void updateByKey() { String newKey = CommercetoolsTestUtils.randomKey(); updateActions.add(ZoneSetKeyActionBuilder.of().key(newKey).build()); - Zone updatedZone = CommercetoolsTestUtils.getProjectRoot() + Zone updatedZone = CommercetoolsTestUtils.getProjectApiRoot() .zones() .withKey(zone.getKey()) .post(ZoneUpdateBuilder.of().actions(updateActions).version(zone.getVersion()).build()) From 3ef2f7f8343d4a2fce517bab19e48ef026f8164b Mon Sep 17 00:00:00 2001 From: Auto Mation Date: Wed, 6 Oct 2021 10:54:09 +0000 Subject: [PATCH 5/5] spotless: Fix code style --- .../java/commercetools/product/ProductIntegrationTests.java | 1 - .../java/commercetools/review/ReviewFixtures.java | 6 +++++- .../java/commercetools/review/ReviewIntegrationTests.java | 6 +++++- .../java/commercetools/utils/CommercetoolsTestUtils.java | 2 -- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java index 9a5458f96f0..d6d802d84ea 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/product/ProductIntegrationTests.java @@ -7,7 +7,6 @@ import java.util.ArrayList; import java.util.List; -import com.commercetools.api.client.ByProjectKeyRequestBuilder; import com.commercetools.api.client.ProjectApiRoot; import com.commercetools.api.models.common.LocalizedString; import com.commercetools.api.models.product.*; diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java index 716afefb3d5..1efc55c7e54 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewFixtures.java @@ -58,7 +58,11 @@ public static Review createReview() { .customer(CustomerResourceIdentifierBuilder.of().id(customer.getId()).build()) .build(); - Review review = CommercetoolsTestUtils.getProjectApiRoot().reviews().post(reviewDraft).executeBlocking().getBody(); + Review review = CommercetoolsTestUtils.getProjectApiRoot() + .reviews() + .post(reviewDraft) + .executeBlocking() + .getBody(); Assert.assertNotNull(review); Assert.assertEquals(reviewDraft.getKey(), review.getKey()); diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java index 1bc214c93d5..12a831997d1 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/review/ReviewIntegrationTests.java @@ -19,7 +19,11 @@ public void createAndDelete() { .title("review-title-1") .build(); - Review review = CommercetoolsTestUtils.getProjectApiRoot().reviews().post(reviewDraft).executeBlocking().getBody(); + Review review = CommercetoolsTestUtils.getProjectApiRoot() + .reviews() + .post(reviewDraft) + .executeBlocking() + .getBody(); Assert.assertNotNull(review); Assert.assertEquals(reviewDraft.getKey(), review.getKey()); diff --git a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java index b3b6f086ee0..682ee777770 100644 --- a/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java +++ b/commercetools/commercetools-sdk-java-api/src/integrationTest/java/commercetools/utils/CommercetoolsTestUtils.java @@ -4,14 +4,12 @@ import java.time.Duration; import java.util.UUID; -import com.commercetools.api.client.ByProjectKeyRequestBuilder; import com.commercetools.api.client.ProjectApiRoot; import com.commercetools.api.defaultconfig.ApiRootBuilder; import com.commercetools.api.defaultconfig.ServiceRegion; import com.commercetools.api.models.common.LocalizedString; import com.commercetools.api.models.common.LocalizedStringImpl; -import io.vrap.rmf.base.client.ApiHttpClient; import io.vrap.rmf.base.client.oauth2.ClientCredentials; public class CommercetoolsTestUtils {