From 0095f72c832f7146c55335e2d992b9209472ddb6 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 13 Apr 2022 11:57:09 +0200 Subject: [PATCH 01/14] remove default --- .../java/libraries/okhttp-gson/api.mustache | 62 +++++++++---------- .../templates/java/forceMapGenerics.mustache | 2 +- .../templates/java/generateGenerics.mustache | 4 +- .../templates/java/maybeConvertOneOf.mustache | 2 +- .../requests/templates/java/requests.mustache | 23 +++---- .../templates/javascript/requests.mustache | 4 +- 6 files changed, 46 insertions(+), 51 deletions(-) diff --git a/templates/java/libraries/okhttp-gson/api.mustache b/templates/java/libraries/okhttp-gson/api.mustache index 7006bc5b8e..3e81da3d81 100644 --- a/templates/java/libraries/okhttp-gson/api.mustache +++ b/templates/java/libraries/okhttp-gson/api.mustache @@ -194,36 +194,36 @@ public class {{classname}} extends ApiClient { return res.getData();{{/returnType}}{{^returnType}}this.execute(call).getData();{{/returnType}} } - {{#optionalParams.0}} - public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) throws AlgoliaRuntimeException { - {{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}},{{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}{{#schema}}{{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/schema}}{{^schema}}null{{/schema}}{{^-last}},{{/-last}}{{/optionalParams}}); - } - {{/optionalParams.0}} - - /** - * (asynchronously) - * {{notes}}{{#allParams}} - * @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}} - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request body object - {{#isDeprecated}} - * @deprecated - {{/isDeprecated}} - {{#externalDocs}} - * {{&description}} - * @see {{&summary}} Documentation - {{/externalDocs}} - */ - {{#isDeprecated}} - @Deprecated - {{/isDeprecated}} - public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> callback) throws AlgoliaRuntimeException { - Call call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}callback); - {{#returnType}}Type returnType = new TypeToken<{{{returnType}}}>(){}.getType(); - this.executeAsync(call, returnType, callback);{{/returnType}}{{^returnType}}this.executeAsync(call, callback);{{/returnType}} - return call; - } - {{/operation}} + {{#optionalParams.0}} + public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) throws AlgoliaRuntimeException { + {{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}},{{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}null{{^-last}},{{/-last}}{{/optionalParams}}); + } + {{/optionalParams.0}} + + /** + * (asynchronously) + * {{notes}}{{#allParams}} + * @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}} + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request body object + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{&description}} + * @see {{&summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> callback) throws AlgoliaRuntimeException { + Call call = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}callback); + {{#returnType}}Type returnType = new TypeToken<{{{returnType}}}>(){}.getType(); + this.executeAsync(call, returnType, callback);{{/returnType}}{{^returnType}}this.executeAsync(call, callback);{{/returnType}} + return call; + } + {{/operation}} } {{/operations}} diff --git a/tests/CTS/methods/requests/templates/java/forceMapGenerics.mustache b/tests/CTS/methods/requests/templates/java/forceMapGenerics.mustache index 9280166d56..1c8b62f356 100644 --- a/tests/CTS/methods/requests/templates/java/forceMapGenerics.mustache +++ b/tests/CTS/methods/requests/templates/java/forceMapGenerics.mustache @@ -1 +1 @@ -{{#isFreeFormObject}} generateGenerics}}{{/isAnyType}}{{/value.0}}>{{/isFreeFormObject}} \ No newline at end of file +{{#isFreeFormObject}} generateGenerics}}{{/isAnyType}}{{/value.0}}>{{/isFreeFormObject}} \ No newline at end of file diff --git a/tests/CTS/methods/requests/templates/java/generateGenerics.mustache b/tests/CTS/methods/requests/templates/java/generateGenerics.mustache index c3642bbaac..0ce68fb64c 100644 --- a/tests/CTS/methods/requests/templates/java/generateGenerics.mustache +++ b/tests/CTS/methods/requests/templates/java/generateGenerics.mustache @@ -1,2 +1,2 @@ -{{#isArray}}{{#value.0}}<{{#oneOfModel}}{{classname}}{{/oneOfModel}}{{^oneOfModel}}{{objectName}}{{/oneOfModel}}{{> generateGenerics}}>{{/value.0}}{{/isArray}} -{{#isFreeFormObject}}{{^isSimpleObject}} generateGenerics}}{{/isAnyType}}{{/value.0}}>{{/isSimpleObject}}{{/isFreeFormObject}} \ No newline at end of file +{{#isArray}}{{#value.0}}<{{#oneOfModel}}{{parentClassName}}{{/oneOfModel}}{{^oneOfModel}}{{objectName}}{{/oneOfModel}}{{> generateGenerics}}>{{/value.0}}{{/isArray}} +{{#isFreeFormObject}}{{^isSimpleObject}} generateGenerics}}{{/isAnyType}}{{/value.0}}>{{/isSimpleObject}}{{/isFreeFormObject}} \ No newline at end of file diff --git a/tests/CTS/methods/requests/templates/java/maybeConvertOneOf.mustache b/tests/CTS/methods/requests/templates/java/maybeConvertOneOf.mustache index 8fbf61e976..2de7fa80c0 100644 --- a/tests/CTS/methods/requests/templates/java/maybeConvertOneOf.mustache +++ b/tests/CTS/methods/requests/templates/java/maybeConvertOneOf.mustache @@ -1 +1 @@ -{{#oneOfModel}}{{{classname}}}.of{{{name}}}({{{key}}}{{suffix}}){{/oneOfModel}}{{^oneOfModel}}{{{key}}}{{suffix}}{{/oneOfModel}} \ No newline at end of file +{{#oneOfModel}}{{{parentClassName}}}.of{{{type}}}({{{key}}}{{suffix}}){{/oneOfModel}}{{^oneOfModel}}{{{key}}}{{suffix}}{{/oneOfModel}} \ No newline at end of file diff --git a/tests/CTS/methods/requests/templates/java/requests.mustache b/tests/CTS/methods/requests/templates/java/requests.mustache index 255e83dea0..e05cc9c18a 100644 --- a/tests/CTS/methods/requests/templates/java/requests.mustache +++ b/tests/CTS/methods/requests/templates/java/requests.mustache @@ -43,25 +43,20 @@ class {{client}}Tests { assertEquals(req.getPath(), "{{{request.path}}}"); assertEquals(req.getMethod(), "{{{request.method}}}"); - {{#request.data}} + {{#request.body}} assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{{#lambda.escapequotes}}{{{request.data}}}{{/lambda.escapequotes}}", req.getBody(), JSONCompareMode.STRICT_ORDER); + JSONAssert.assertEquals("{{#lambda.escapequotes}}{{{request.body}}}{{/lambda.escapequotes}}", req.getBody(), JSONCompareMode.STRICT_ORDER); }); - {{/request.data}} + {{/request.body}} - {{#request.searchParams}} - Map expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.searchParams}}}{{/lambda.escapequotes}}", new TypeToken>() {}.getType()); + {{#request.queryParameters}} + HashMap expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.queryParameters}}}{{/lambda.escapequotes}}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if (p.getName().equals(entry.getKey()) && p.getValue().equals(entry.getValue())) { - found = true; - } - } - assertTrue(found, "Query parameter " + entry.getKey() + " not found in the actual query"); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - {{/request.searchParams}} + {{/request.queryParameters}} } {{/tests}} {{/blocks}} diff --git a/tests/CTS/methods/requests/templates/javascript/requests.mustache b/tests/CTS/methods/requests/templates/javascript/requests.mustache index 0924ec5e42..0d0c0ad195 100644 --- a/tests/CTS/methods/requests/templates/javascript/requests.mustache +++ b/tests/CTS/methods/requests/templates/javascript/requests.mustache @@ -15,8 +15,8 @@ describe('{{operationId}}', () => { expect(req.path).toEqual('{{{request.path}}}'); expect(req.method).toEqual('{{{request.method}}}'); - expect(req.data).toEqual({{#request.data}}{{{request.data}}}{{/request.data}}{{^request.data}}undefined{{/request.data}}); - expect(req.searchParams).toEqual({{#request.searchParams}}{{{request.searchParams}}}{{/request.searchParams}}{{^request.searchParams}}undefined{{/request.searchParams}}); + expect(req.data).toEqual({{#request.body}}{{{.}}}{{/request.body}}{{^request.body}}undefined{{/request.body}}); + expect(req.searchParams).toStrictEqual({{#request.queryParameters}}{{{request.queryParameters}}}{{/request.queryParameters}}{{^request.queryParameters}}undefined{{/request.queryParameters}}); }); {{/tests}} From c95dd268ba2a00c6778f69cf19bd6b73fbcfb555 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 13 Apr 2022 11:57:26 +0200 Subject: [PATCH 02/14] simplify CTS --- .../codegen/cts/AlgoliaCtsGenerator.java | 5 +- .../codegen/cts/ParametersWithDataType.java | 5 +- .../java/com/algolia/codegen/cts/Request.java | 12 +- .../requests/abtesting/addABTests.json | 3 +- .../requests/abtesting/deleteABTest.json | 1 - .../methods/requests/abtesting/getABTest.json | 1 - .../requests/abtesting/listABTests.json | 3 +- .../requests/abtesting/stopABTest.json | 1 - .../analytics/getAverageClickPosition.json | 6 +- .../requests/analytics/getClickPositions.json | 6 +- .../analytics/getClickThroughRate.json | 6 +- .../analytics/getConversationRate.json | 6 +- .../requests/analytics/getNoClickRate.json | 6 +- .../requests/analytics/getNoResultsRate.json | 6 +- .../requests/analytics/getSearchesCount.json | 6 +- .../analytics/getSearchesNoClicks.json | 6 +- .../analytics/getSearchesNoResults.json | 6 +- .../methods/requests/analytics/getStatus.json | 3 +- .../requests/analytics/getTopCountries.json | 6 +- .../analytics/getTopFilterAttributes.json | 6 +- .../analytics/getTopFilterForAttribute.json | 12 +- .../analytics/getTopFiltersNoResults.json | 6 +- .../requests/analytics/getTopHits.json | 6 +- .../requests/analytics/getTopSearches.json | 6 +- .../requests/analytics/getUsersCount.json | 6 +- .../methods/requests/insights/pushEvents.json | 3 +- .../personalization/deleteUserProfile.json | 1 - .../getPersonalizationStrategy.json | 1 - .../personalization/getUserTokenProfile.json | 1 - .../setPersonalizationStrategy.json | 3 +- .../query-suggestions/createConfig.json | 3 +- .../query-suggestions/deleteConfig.json | 1 - .../query-suggestions/getAllConfigs.json | 1 - .../requests/query-suggestions/getConfig.json | 1 - .../query-suggestions/getConfigStatus.json | 1 - .../query-suggestions/getLogFile.json | 1 - .../query-suggestions/updateConfig.json | 3 +- .../recommend/getRecommendations.json | 21 +- .../methods/requests/search/addApiKey.json | 3 +- .../requests/search/addOrUpdateObject.json | 3 +- .../methods/requests/search/appendSource.json | 3 +- .../methods/requests/search/assignUserId.json | 5 +- tests/CTS/methods/requests/search/batch.json | 3 +- .../requests/search/batchAssignUserIds.json | 5 +- .../search/batchDictionaryEntries.json | 6 +- .../methods/requests/search/batchRules.json | 5 +- tests/CTS/methods/requests/search/browse.json | 4 +- .../requests/search/clearAllSynonyms.json | 1 - .../methods/requests/search/clearObjects.json | 1 - .../methods/requests/search/clearRules.json | 1 - .../methods/requests/search/deleteApiKey.json | 1 - .../CTS/methods/requests/search/deleteBy.json | 3 +- .../methods/requests/search/deleteIndex.json | 1 - .../methods/requests/search/deleteObject.json | 1 - .../methods/requests/search/deleteRule.json | 1 - .../methods/requests/search/deleteSource.json | 1 - .../requests/search/deleteSynonym.json | 1 - .../methods/requests/search/getApiKey.json | 1 - .../search/getDictionaryLanguages.json | 1 - .../search/getDictionarySettings.json | 1 - .../CTS/methods/requests/search/getLogs.json | 3 +- .../methods/requests/search/getObject.json | 3 +- .../methods/requests/search/getObjects.json | 3 +- .../CTS/methods/requests/search/getRule.json | 1 - .../methods/requests/search/getSettings.json | 1 - .../methods/requests/search/getSources.json | 1 - .../methods/requests/search/getSynonym.json | 1 - .../CTS/methods/requests/search/getTask.json | 1 - .../requests/search/getTopUserIds.json | 1 - .../methods/requests/search/getUserId.json | 1 - .../requests/search/hasPendingMappings.json | 3 +- .../methods/requests/search/listApiKeys.json | 1 - .../methods/requests/search/listClusters.json | 1 - .../methods/requests/search/listIndices.json | 3 +- .../methods/requests/search/listUserIds.json | 3 +- .../requests/search/multipleBatch.json | 3 +- .../requests/search/multipleQueries.json | 3 +- .../requests/search/operationIndex.json | 3 +- .../requests/search/partialUpdateObject.json | 5 +- .../methods/requests/search/removeUserId.json | 1 - .../requests/search/replaceSources.json | 3 +- .../requests/search/restoreApiKey.json | 1 - .../methods/requests/search/saveObject.json | 3 +- .../CTS/methods/requests/search/saveRule.json | 5 +- .../methods/requests/search/saveSynonym.json | 5 +- .../methods/requests/search/saveSynonyms.json | 5 +- tests/CTS/methods/requests/search/search.json | 3 +- .../search/searchDictionaryEntries.json | 6 +- .../requests/search/searchForFacetValues.json | 4 +- .../methods/requests/search/searchRules.json | 3 +- .../requests/search/searchSynonyms.json | 1 - .../requests/search/searchUserIds.json | 3 +- .../search/setDictionarySettings.json | 6 +- .../methods/requests/search/setSettings.json | 5 +- .../methods/requests/search/updateApiKey.json | 3 +- .../requests/sources/postIngestUrl.json | 6 +- .../methods/requests/abtesting.test.java | 787 ++- .../methods/requests/analytics.test.java | 1502 ++--- .../methods/requests/insights.test.java | 218 +- .../requests/personalization.test.java | 250 +- .../requests/query-suggestions.test.java | 288 +- .../methods/requests/recommend.test.java | 1887 +++--- .../algolia/methods/requests/search.test.java | 5816 ++++++++++------- .../src/methods/requests/abtesting.test.ts | 10 +- .../src/methods/requests/analytics.test.ts | 70 +- .../src/methods/requests/insights.test.ts | 2 +- .../methods/requests/personalization.test.ts | 8 +- .../requests/query-suggestions.test.ts | 14 +- .../src/methods/requests/recommend.test.ts | 14 +- .../src/methods/requests/search.test.ts | 126 +- .../src/methods/requests/sources.test.ts | 4 +- 111 files changed, 5994 insertions(+), 5335 deletions(-) diff --git a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java index 30328e5c31..29cecc94b1 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -158,6 +158,7 @@ public Map postProcessSupportingFileData( List tests = new ArrayList<>(); for (int i = 0; i < entry.getValue().length; i++) { Map test = paramsType.buildJSONForRequest( + operationId, entry.getValue()[i], op, i @@ -173,12 +174,10 @@ public Map postProcessSupportingFileData( return bundle; } catch (CTSException e) { + System.out.println(e.getMessage()); if (e.isSkipable()) { - System.out.println(e.getMessage()); System.exit(0); } - - System.out.println(e.getMessage()); System.exit(1); } catch (Exception e) { e.printStackTrace(); diff --git a/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java b/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java index f76a9e5320..73a08b18f3 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java +++ b/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java @@ -29,13 +29,14 @@ public ParametersWithDataType( } public Map buildJSONForRequest( + String operationId, Request req, CodegenOperation ope, int testIndex ) throws CTSException, JsonMappingException, JsonProcessingException { Map test = new HashMap<>(); - test.put("method", req.method); - test.put("testName", req.testName == null ? req.method : req.testName); + test.put("method", operationId); + test.put("testName", req.testName == null ? operationId : req.testName); test.put("testIndex", testIndex); test.put("request", req.request); diff --git a/generators/src/main/java/com/algolia/codegen/cts/Request.java b/generators/src/main/java/com/algolia/codegen/cts/Request.java index 91a1996513..6f04044e00 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/Request.java +++ b/generators/src/main/java/com/algolia/codegen/cts/Request.java @@ -10,12 +10,9 @@ import java.util.Map; public class Request { - public String testName; - public String method; public Map parameters; - public RequestProp request; @Override @@ -23,7 +20,6 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Request {\n"); sb.append(" testName: ").append(testName).append("\n"); - sb.append(" method: ").append(method).append("\n"); sb.append(" parameters: ").append(parameters).append("\n"); sb.append(" request: ").append(request).append("\n"); sb.append("}"); @@ -37,10 +33,10 @@ class RequestProp { public String method; @JsonDeserialize(using = RawDeserializer.class) - public String data; + public String body; @JsonDeserialize(using = RawDeserializer.class) - public String searchParams; + public String queryParameters; @Override public String toString() { @@ -48,8 +44,8 @@ public String toString() { sb.append("class RequestProp {\n"); sb.append(" path: ").append(path).append("\n"); sb.append(" method: ").append(method).append("\n"); - sb.append(" data: ").append(data).append("\n"); - sb.append(" searchParams: ").append(searchParams).append("\n"); + sb.append(" body: ").append(body).append("\n"); + sb.append(" queryParameters: ").append(queryParameters).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/tests/CTS/methods/requests/abtesting/addABTests.json b/tests/CTS/methods/requests/abtesting/addABTests.json index 7081e5fe8c..715e965c17 100644 --- a/tests/CTS/methods/requests/abtesting/addABTests.json +++ b/tests/CTS/methods/requests/abtesting/addABTests.json @@ -1,6 +1,5 @@ [ { - "method": "addABTests", "testName": "addABTests with minimal parameters", "parameters": { "endAt": "2022-12-31T00:00:00.000Z", @@ -19,7 +18,7 @@ "request": { "path": "/2/abtests", "method": "POST", - "data": { + "body": { "endAt": "2022-12-31T00:00:00.000Z", "name": "myABTest", "variant": [ diff --git a/tests/CTS/methods/requests/abtesting/deleteABTest.json b/tests/CTS/methods/requests/abtesting/deleteABTest.json index 62d62e973c..a6516c1404 100644 --- a/tests/CTS/methods/requests/abtesting/deleteABTest.json +++ b/tests/CTS/methods/requests/abtesting/deleteABTest.json @@ -1,6 +1,5 @@ [ { - "method": "deleteABTest", "testName": "deleteABTest", "parameters": { "id": 42 diff --git a/tests/CTS/methods/requests/abtesting/getABTest.json b/tests/CTS/methods/requests/abtesting/getABTest.json index b72e7a2204..6b06b41205 100644 --- a/tests/CTS/methods/requests/abtesting/getABTest.json +++ b/tests/CTS/methods/requests/abtesting/getABTest.json @@ -1,6 +1,5 @@ [ { - "method": "getABTest", "testName": "getABTest", "parameters": { "id": 42 diff --git a/tests/CTS/methods/requests/abtesting/listABTests.json b/tests/CTS/methods/requests/abtesting/listABTests.json index 31fc5160ff..98ff21e260 100644 --- a/tests/CTS/methods/requests/abtesting/listABTests.json +++ b/tests/CTS/methods/requests/abtesting/listABTests.json @@ -1,6 +1,5 @@ [ { - "method": "listABTests", "testName": "listABTests with minimal parameters", "parameters": { "offset": 42, @@ -9,7 +8,7 @@ "request": { "path": "/2/abtests", "method": "GET", - "searchParams": { + "queryParameters": { "offset": "42", "limit": "21" } diff --git a/tests/CTS/methods/requests/abtesting/stopABTest.json b/tests/CTS/methods/requests/abtesting/stopABTest.json index 1c9cd09bd8..9229366545 100644 --- a/tests/CTS/methods/requests/abtesting/stopABTest.json +++ b/tests/CTS/methods/requests/abtesting/stopABTest.json @@ -1,6 +1,5 @@ [ { - "method": "stopABTest", "testName": "stopABTest", "parameters": { "id": 42 diff --git a/tests/CTS/methods/requests/analytics/getAverageClickPosition.json b/tests/CTS/methods/requests/analytics/getAverageClickPosition.json index 2a5ca62405..b12402f462 100644 --- a/tests/CTS/methods/requests/analytics/getAverageClickPosition.json +++ b/tests/CTS/methods/requests/analytics/getAverageClickPosition.json @@ -1,6 +1,5 @@ [ { - "method": "getAverageClickPosition", "testName": "get getAverageClickPosition with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/clicks/averageClickPosition", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getAverageClickPosition", "testName": "get getAverageClickPosition with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/clicks/averageClickPosition", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getClickPositions.json b/tests/CTS/methods/requests/analytics/getClickPositions.json index 173abd2798..4efff42eb9 100644 --- a/tests/CTS/methods/requests/analytics/getClickPositions.json +++ b/tests/CTS/methods/requests/analytics/getClickPositions.json @@ -1,6 +1,5 @@ [ { - "method": "getClickPositions", "testName": "get getClickPositions with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/clicks/positions", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getClickPositions", "testName": "get getClickPositions with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/clicks/positions", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getClickThroughRate.json b/tests/CTS/methods/requests/analytics/getClickThroughRate.json index 9fd79fa8bc..13726bdcb2 100644 --- a/tests/CTS/methods/requests/analytics/getClickThroughRate.json +++ b/tests/CTS/methods/requests/analytics/getClickThroughRate.json @@ -1,6 +1,5 @@ [ { - "method": "getClickThroughRate", "testName": "get getClickThroughRate with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/clicks/clickThroughRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getClickThroughRate", "testName": "get getClickThroughRate with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/clicks/clickThroughRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getConversationRate.json b/tests/CTS/methods/requests/analytics/getConversationRate.json index 10a3be49c2..441ca7bc6b 100644 --- a/tests/CTS/methods/requests/analytics/getConversationRate.json +++ b/tests/CTS/methods/requests/analytics/getConversationRate.json @@ -1,6 +1,5 @@ [ { - "method": "getConversationRate", "testName": "get getConversationRate with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/conversions/conversionRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getConversationRate", "testName": "get getConversationRate with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/conversions/conversionRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getNoClickRate.json b/tests/CTS/methods/requests/analytics/getNoClickRate.json index ad9cbb0ef4..4c6d7e4610 100644 --- a/tests/CTS/methods/requests/analytics/getNoClickRate.json +++ b/tests/CTS/methods/requests/analytics/getNoClickRate.json @@ -1,6 +1,5 @@ [ { - "method": "getNoClickRate", "testName": "get getNoClickRate with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/searches/noClickRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getNoClickRate", "testName": "get getNoClickRate with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/searches/noClickRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getNoResultsRate.json b/tests/CTS/methods/requests/analytics/getNoResultsRate.json index 0033428e77..0a28416f29 100644 --- a/tests/CTS/methods/requests/analytics/getNoResultsRate.json +++ b/tests/CTS/methods/requests/analytics/getNoResultsRate.json @@ -1,6 +1,5 @@ [ { - "method": "getNoResultsRate", "testName": "get getNoResultsRate with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/searches/noResultRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getNoResultsRate", "testName": "get getNoResultsRate with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/searches/noResultRate", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getSearchesCount.json b/tests/CTS/methods/requests/analytics/getSearchesCount.json index 3aa0651899..7e0bde5052 100644 --- a/tests/CTS/methods/requests/analytics/getSearchesCount.json +++ b/tests/CTS/methods/requests/analytics/getSearchesCount.json @@ -1,6 +1,5 @@ [ { - "method": "getSearchesCount", "testName": "get getSearchesCount with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/searches/count", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getSearchesCount", "testName": "get getSearchesCount with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/searches/count", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getSearchesNoClicks.json b/tests/CTS/methods/requests/analytics/getSearchesNoClicks.json index e55f488a51..ef4d47c3cb 100644 --- a/tests/CTS/methods/requests/analytics/getSearchesNoClicks.json +++ b/tests/CTS/methods/requests/analytics/getSearchesNoClicks.json @@ -1,6 +1,5 @@ [ { - "method": "getSearchesNoClicks", "testName": "get getSearchesNoClicks with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/searches/noClicks", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getSearchesNoClicks", "testName": "get getSearchesNoClicks with all parameters", "parameters": { "index": "index", @@ -27,7 +25,7 @@ "request": { "path": "/2/searches/noClicks", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getSearchesNoResults.json b/tests/CTS/methods/requests/analytics/getSearchesNoResults.json index f568f1ffad..b301258806 100644 --- a/tests/CTS/methods/requests/analytics/getSearchesNoResults.json +++ b/tests/CTS/methods/requests/analytics/getSearchesNoResults.json @@ -1,6 +1,5 @@ [ { - "method": "getSearchesNoResults", "testName": "get getSearchesNoResults with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/searches/noResults", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getSearchesNoResults", "testName": "get getSearchesNoResults with all parameters", "parameters": { "index": "index", @@ -27,7 +25,7 @@ "request": { "path": "/2/searches/noResults", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getStatus.json b/tests/CTS/methods/requests/analytics/getStatus.json index 48b33963c1..51c7e1bdee 100644 --- a/tests/CTS/methods/requests/analytics/getStatus.json +++ b/tests/CTS/methods/requests/analytics/getStatus.json @@ -1,6 +1,5 @@ [ { - "method": "getStatus", "testName": "get getStatus with minimal parameters", "parameters": { "index": "index" @@ -8,7 +7,7 @@ "request": { "path": "/2/status", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } diff --git a/tests/CTS/methods/requests/analytics/getTopCountries.json b/tests/CTS/methods/requests/analytics/getTopCountries.json index 679126e334..44c3c8e151 100644 --- a/tests/CTS/methods/requests/analytics/getTopCountries.json +++ b/tests/CTS/methods/requests/analytics/getTopCountries.json @@ -1,6 +1,5 @@ [ { - "method": "getTopCountries", "testName": "get getTopCountries with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/countries", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getTopCountries", "testName": "get getTopCountries with all parameters", "parameters": { "index": "index", @@ -27,7 +25,7 @@ "request": { "path": "/2/countries", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/analytics/getTopFilterAttributes.json b/tests/CTS/methods/requests/analytics/getTopFilterAttributes.json index f99e9386f7..5f63beecb6 100644 --- a/tests/CTS/methods/requests/analytics/getTopFilterAttributes.json +++ b/tests/CTS/methods/requests/analytics/getTopFilterAttributes.json @@ -1,6 +1,5 @@ [ { - "method": "getTopFilterAttributes", "testName": "get getTopFilterAttributes with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/filters", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getTopFilterAttributes", "testName": "get getTopFilterAttributes with all parameters", "parameters": { "index": "index", @@ -28,7 +26,7 @@ "request": { "path": "/2/filters", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "search": "mySearch", "startDate": "1999-09-19", diff --git a/tests/CTS/methods/requests/analytics/getTopFilterForAttribute.json b/tests/CTS/methods/requests/analytics/getTopFilterForAttribute.json index 3cbad8c0d9..51184696cd 100644 --- a/tests/CTS/methods/requests/analytics/getTopFilterForAttribute.json +++ b/tests/CTS/methods/requests/analytics/getTopFilterForAttribute.json @@ -1,6 +1,5 @@ [ { - "method": "getTopFilterForAttribute", "testName": "get getTopFilterForAttribute with minimal parameters", "parameters": { "attribute": "myAttribute", @@ -9,13 +8,12 @@ "request": { "path": "/2/filters/myAttribute", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getTopFilterForAttribute", "testName": "get getTopFilterForAttribute with minimal parameters and multiple attributes", "parameters": { "attribute": "myAttribute1,myAttribute2", @@ -24,13 +22,12 @@ "request": { "path": "/2/filters/myAttribute1%2CmyAttribute2", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getTopFilterForAttribute", "testName": "get getTopFilterForAttribute with all parameters", "parameters": { "attribute": "myAttribute", @@ -45,7 +42,7 @@ "request": { "path": "/2/filters/myAttribute", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "search": "mySearch", "startDate": "1999-09-19", @@ -57,7 +54,6 @@ } }, { - "method": "getTopFilterForAttribute", "testName": "get getTopFilterForAttribute with all parameters and multiple attributes", "parameters": { "attribute": "myAttribute1,myAttribute2", @@ -72,7 +68,7 @@ "request": { "path": "/2/filters/myAttribute1%2CmyAttribute2", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "search": "mySearch", "startDate": "1999-09-19", diff --git a/tests/CTS/methods/requests/analytics/getTopFiltersNoResults.json b/tests/CTS/methods/requests/analytics/getTopFiltersNoResults.json index 47c3b5b288..d145d8a4db 100644 --- a/tests/CTS/methods/requests/analytics/getTopFiltersNoResults.json +++ b/tests/CTS/methods/requests/analytics/getTopFiltersNoResults.json @@ -1,6 +1,5 @@ [ { - "method": "getTopFiltersNoResults", "testName": "get getTopFiltersNoResults with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/filters/noResults", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getTopFiltersNoResults", "testName": "get getTopFiltersNoResults with all parameters", "parameters": { "index": "index", @@ -28,7 +26,7 @@ "request": { "path": "/2/filters/noResults", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "search": "mySearch", "startDate": "1999-09-19", diff --git a/tests/CTS/methods/requests/analytics/getTopHits.json b/tests/CTS/methods/requests/analytics/getTopHits.json index 9fcb31162d..0873a39d64 100644 --- a/tests/CTS/methods/requests/analytics/getTopHits.json +++ b/tests/CTS/methods/requests/analytics/getTopHits.json @@ -1,6 +1,5 @@ [ { - "method": "getTopHits", "testName": "get getTopHits with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/hits", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getTopHits", "testName": "get getTopHits with all parameters", "parameters": { "index": "index", @@ -29,7 +27,7 @@ "request": { "path": "/2/hits", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "search": "mySearch", "clickAnalytics": "true", diff --git a/tests/CTS/methods/requests/analytics/getTopSearches.json b/tests/CTS/methods/requests/analytics/getTopSearches.json index d0a271c5d8..eee7776055 100644 --- a/tests/CTS/methods/requests/analytics/getTopSearches.json +++ b/tests/CTS/methods/requests/analytics/getTopSearches.json @@ -1,6 +1,5 @@ [ { - "method": "getTopSearches", "testName": "get getTopSearches with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/searches", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getTopSearches", "testName": "get getTopSearches with all parameters", "parameters": { "index": "index", @@ -30,7 +28,7 @@ "request": { "path": "/2/searches", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "clickAnalytics": "true", "startDate": "1999-09-19", diff --git a/tests/CTS/methods/requests/analytics/getUsersCount.json b/tests/CTS/methods/requests/analytics/getUsersCount.json index 113c78b30d..7ce70becbb 100644 --- a/tests/CTS/methods/requests/analytics/getUsersCount.json +++ b/tests/CTS/methods/requests/analytics/getUsersCount.json @@ -1,6 +1,5 @@ [ { - "method": "getUsersCount", "testName": "get getUsersCount with minimal parameters", "parameters": { "index": "index" @@ -8,13 +7,12 @@ "request": { "path": "/2/users/count", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index" } } }, { - "method": "getUsersCount", "testName": "get getUsersCount with all parameters", "parameters": { "index": "index", @@ -25,7 +23,7 @@ "request": { "path": "/2/users/count", "method": "GET", - "searchParams": { + "queryParameters": { "index": "index", "startDate": "1999-09-19", "endDate": "2001-01-01", diff --git a/tests/CTS/methods/requests/insights/pushEvents.json b/tests/CTS/methods/requests/insights/pushEvents.json index c7ed9b4604..b07116c7c2 100644 --- a/tests/CTS/methods/requests/insights/pushEvents.json +++ b/tests/CTS/methods/requests/insights/pushEvents.json @@ -1,6 +1,5 @@ [ { - "method": "pushEvents", "parameters": { "events": [ { @@ -47,7 +46,7 @@ "request": { "path": "/1/events", "method": "POST", - "data": { + "body": { "events": [ { "eventType": "click", diff --git a/tests/CTS/methods/requests/personalization/deleteUserProfile.json b/tests/CTS/methods/requests/personalization/deleteUserProfile.json index 01a2910834..92c5654f61 100644 --- a/tests/CTS/methods/requests/personalization/deleteUserProfile.json +++ b/tests/CTS/methods/requests/personalization/deleteUserProfile.json @@ -1,6 +1,5 @@ [ { - "method": "deleteUserProfile", "testName": "delete deleteUserProfile", "parameters": { "userToken": "UserToken" diff --git a/tests/CTS/methods/requests/personalization/getPersonalizationStrategy.json b/tests/CTS/methods/requests/personalization/getPersonalizationStrategy.json index 0a9cc009c2..572da0513e 100644 --- a/tests/CTS/methods/requests/personalization/getPersonalizationStrategy.json +++ b/tests/CTS/methods/requests/personalization/getPersonalizationStrategy.json @@ -1,6 +1,5 @@ [ { - "method": "getPersonalizationStrategy", "testName": "get getPersonalizationStrategy", "parameters": {}, "request": { diff --git a/tests/CTS/methods/requests/personalization/getUserTokenProfile.json b/tests/CTS/methods/requests/personalization/getUserTokenProfile.json index 9336135fb0..630d0edb8d 100644 --- a/tests/CTS/methods/requests/personalization/getUserTokenProfile.json +++ b/tests/CTS/methods/requests/personalization/getUserTokenProfile.json @@ -1,6 +1,5 @@ [ { - "method": "getUserTokenProfile", "testName": "get getUserTokenProfile", "parameters": { "userToken": "UserToken" diff --git a/tests/CTS/methods/requests/personalization/setPersonalizationStrategy.json b/tests/CTS/methods/requests/personalization/setPersonalizationStrategy.json index 7c1e3ef7fe..97d1fea5eb 100644 --- a/tests/CTS/methods/requests/personalization/setPersonalizationStrategy.json +++ b/tests/CTS/methods/requests/personalization/setPersonalizationStrategy.json @@ -1,6 +1,5 @@ [ { - "method": "setPersonalizationStrategy", "testName": "set setPersonalizationStrategy", "parameters": { "eventScoring": [ @@ -21,7 +20,7 @@ "request": { "path": "/1/strategies/personalization", "method": "POST", - "data": { + "body": { "eventScoring": [ { "score": 42, diff --git a/tests/CTS/methods/requests/query-suggestions/createConfig.json b/tests/CTS/methods/requests/query-suggestions/createConfig.json index 7ab1c37b44..5ea118593b 100644 --- a/tests/CTS/methods/requests/query-suggestions/createConfig.json +++ b/tests/CTS/methods/requests/query-suggestions/createConfig.json @@ -1,6 +1,5 @@ [ { - "method": "createConfig", "parameters": { "indexName": "theIndexName", "sourceIndices": [ @@ -32,7 +31,7 @@ "request": { "path": "/1/configs", "method": "POST", - "data": { + "body": { "indexName": "theIndexName", "sourceIndices": [ { diff --git a/tests/CTS/methods/requests/query-suggestions/deleteConfig.json b/tests/CTS/methods/requests/query-suggestions/deleteConfig.json index 4d07fd9d19..21e219a14b 100644 --- a/tests/CTS/methods/requests/query-suggestions/deleteConfig.json +++ b/tests/CTS/methods/requests/query-suggestions/deleteConfig.json @@ -1,6 +1,5 @@ [ { - "method": "deleteConfig", "parameters": { "indexName": "theIndexName" }, diff --git a/tests/CTS/methods/requests/query-suggestions/getAllConfigs.json b/tests/CTS/methods/requests/query-suggestions/getAllConfigs.json index 13a2deb8c7..8ac654b694 100644 --- a/tests/CTS/methods/requests/query-suggestions/getAllConfigs.json +++ b/tests/CTS/methods/requests/query-suggestions/getAllConfigs.json @@ -1,6 +1,5 @@ [ { - "method": "getAllConfigs", "parameters": {}, "request": { "path": "/1/configs", diff --git a/tests/CTS/methods/requests/query-suggestions/getConfig.json b/tests/CTS/methods/requests/query-suggestions/getConfig.json index f7e308fb9a..4bdee9b415 100644 --- a/tests/CTS/methods/requests/query-suggestions/getConfig.json +++ b/tests/CTS/methods/requests/query-suggestions/getConfig.json @@ -1,6 +1,5 @@ [ { - "method": "getConfig", "parameters": { "indexName": "theIndexName" }, diff --git a/tests/CTS/methods/requests/query-suggestions/getConfigStatus.json b/tests/CTS/methods/requests/query-suggestions/getConfigStatus.json index b9e0abc1e8..ac33d0c9ed 100644 --- a/tests/CTS/methods/requests/query-suggestions/getConfigStatus.json +++ b/tests/CTS/methods/requests/query-suggestions/getConfigStatus.json @@ -1,6 +1,5 @@ [ { - "method": "getConfigStatus", "parameters": { "indexName": "theIndexName" }, diff --git a/tests/CTS/methods/requests/query-suggestions/getLogFile.json b/tests/CTS/methods/requests/query-suggestions/getLogFile.json index caea88b93a..f6b8b8d9aa 100644 --- a/tests/CTS/methods/requests/query-suggestions/getLogFile.json +++ b/tests/CTS/methods/requests/query-suggestions/getLogFile.json @@ -1,6 +1,5 @@ [ { - "method": "getLogFile", "parameters": { "indexName": "theIndexName" }, diff --git a/tests/CTS/methods/requests/query-suggestions/updateConfig.json b/tests/CTS/methods/requests/query-suggestions/updateConfig.json index 117e5810e8..ca3cd8820e 100644 --- a/tests/CTS/methods/requests/query-suggestions/updateConfig.json +++ b/tests/CTS/methods/requests/query-suggestions/updateConfig.json @@ -1,6 +1,5 @@ [ { - "method": "updateConfig", "parameters": { "indexName": "theIndexName", "querySuggestionsIndexParam": { @@ -34,7 +33,7 @@ "request": { "path": "/1/configs/theIndexName", "method": "PUT", - "data": { + "body": { "sourceIndices": [ { "indexName": "testIndex", diff --git a/tests/CTS/methods/requests/recommend/getRecommendations.json b/tests/CTS/methods/requests/recommend/getRecommendations.json index a852f7c097..b412458755 100644 --- a/tests/CTS/methods/requests/recommend/getRecommendations.json +++ b/tests/CTS/methods/requests/recommend/getRecommendations.json @@ -1,6 +1,5 @@ [ { - "method": "getRecommendations", "testName": "get recommendations for recommend model with minimal parameters", "parameters": { "requests": [ @@ -15,7 +14,7 @@ "request": { "path": "/1/indexes/*/recommendations", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "indexName", @@ -28,7 +27,6 @@ } }, { - "method": "getRecommendations", "testName": "get recommendations for recommend model with all parameters", "parameters": { "requests": [ @@ -56,7 +54,7 @@ "request": { "path": "/1/indexes/*/recommendations", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "indexName", @@ -82,7 +80,6 @@ } }, { - "method": "getRecommendations", "testName": "get recommendations for trending model with minimal parameters", "parameters": { "requests": [ @@ -96,7 +93,7 @@ "request": { "path": "/1/indexes/*/recommendations", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "indexName", @@ -108,7 +105,6 @@ } }, { - "method": "getRecommendations", "testName": "get recommendations for trending model with all parameters", "parameters": { "requests": [ @@ -137,7 +133,7 @@ "request": { "path": "/1/indexes/*/recommendations", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "indexName", @@ -164,7 +160,6 @@ } }, { - "method": "getRecommendations", "testName": "get multiple recommendations with minimal parameters", "parameters": { "requests": [ @@ -185,7 +180,7 @@ "request": { "path": "/1/indexes/*/recommendations", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "indexName1", @@ -204,7 +199,6 @@ } }, { - "method": "getRecommendations", "testName": "get multiple recommendations with all parameters", "parameters": { "requests": [ @@ -251,7 +245,7 @@ "request": { "path": "/1/indexes/*/recommendations", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "indexName1", @@ -296,7 +290,6 @@ } }, { - "method": "getRecommendations", "testName": "get frequently bought together recommendations", "parameters": { "requests": [ @@ -311,7 +304,7 @@ "request": { "path": "/1/indexes/*/recommendations", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "indexName1", diff --git a/tests/CTS/methods/requests/search/addApiKey.json b/tests/CTS/methods/requests/search/addApiKey.json index c503c2e0bb..e342781cb5 100644 --- a/tests/CTS/methods/requests/search/addApiKey.json +++ b/tests/CTS/methods/requests/search/addApiKey.json @@ -1,6 +1,5 @@ [ { - "method": "addApiKey", "parameters": { "acl": [ "search", @@ -14,7 +13,7 @@ "request": { "path": "/1/keys", "method": "POST", - "data": { + "body": { "acl": [ "search", "addObject" diff --git a/tests/CTS/methods/requests/search/addOrUpdateObject.json b/tests/CTS/methods/requests/search/addOrUpdateObject.json index c718ec67eb..792562aa7a 100644 --- a/tests/CTS/methods/requests/search/addOrUpdateObject.json +++ b/tests/CTS/methods/requests/search/addOrUpdateObject.json @@ -1,6 +1,5 @@ [ { - "method": "addOrUpdateObject", "parameters": { "indexName": "indexName", "objectID": "uniqueID", @@ -11,7 +10,7 @@ "request": { "path": "/1/indexes/indexName/uniqueID", "method": "PUT", - "data": { + "body": { "key": "value" } } diff --git a/tests/CTS/methods/requests/search/appendSource.json b/tests/CTS/methods/requests/search/appendSource.json index 53b7a7940a..0373eae97b 100644 --- a/tests/CTS/methods/requests/search/appendSource.json +++ b/tests/CTS/methods/requests/search/appendSource.json @@ -1,6 +1,5 @@ [ { - "method": "appendSource", "parameters": { "source": "theSource", "description": "theDescription" @@ -8,7 +7,7 @@ "request": { "path": "/1/security/sources/append", "method": "POST", - "data": { + "body": { "source": "theSource", "description": "theDescription" } diff --git a/tests/CTS/methods/requests/search/assignUserId.json b/tests/CTS/methods/requests/search/assignUserId.json index 7abfe64b6c..5698b18b21 100644 --- a/tests/CTS/methods/requests/search/assignUserId.json +++ b/tests/CTS/methods/requests/search/assignUserId.json @@ -1,6 +1,5 @@ [ { - "method": "assignUserId", "parameters": { "xAlgoliaUserID": "userID", "assignUserIdParams": { @@ -10,10 +9,10 @@ "request": { "path": "/1/clusters/mapping", "method": "POST", - "data": { + "body": { "cluster": "theCluster" }, - "searchParams": { + "queryParameters": { "X-Algolia-User-ID": "userID" } } diff --git a/tests/CTS/methods/requests/search/batch.json b/tests/CTS/methods/requests/search/batch.json index fc28525200..e11f854bce 100644 --- a/tests/CTS/methods/requests/search/batch.json +++ b/tests/CTS/methods/requests/search/batch.json @@ -1,6 +1,5 @@ [ { - "method": "batch", "parameters": { "indexName": "theIndexName", "batchWriteParams": { @@ -17,7 +16,7 @@ "request": { "path": "/1/indexes/theIndexName/batch", "method": "POST", - "data": { + "body": { "requests": [ { "action": "delete", diff --git a/tests/CTS/methods/requests/search/batchAssignUserIds.json b/tests/CTS/methods/requests/search/batchAssignUserIds.json index 0ed242e835..b19ace6ea5 100644 --- a/tests/CTS/methods/requests/search/batchAssignUserIds.json +++ b/tests/CTS/methods/requests/search/batchAssignUserIds.json @@ -1,6 +1,5 @@ [ { - "method": "batchAssignUserIds", "parameters": { "xAlgoliaUserID": "userID", "batchAssignUserIdsParams": { @@ -14,14 +13,14 @@ "request": { "path": "/1/clusters/mapping/batch", "method": "POST", - "data": { + "body": { "cluster": "theCluster", "users": [ "user1", "user2" ] }, - "searchParams": { + "queryParameters": { "X-Algolia-User-ID": "userID" } } diff --git a/tests/CTS/methods/requests/search/batchDictionaryEntries.json b/tests/CTS/methods/requests/search/batchDictionaryEntries.json index c4b8dfcb0a..7f3a1a5bf7 100644 --- a/tests/CTS/methods/requests/search/batchDictionaryEntries.json +++ b/tests/CTS/methods/requests/search/batchDictionaryEntries.json @@ -1,6 +1,5 @@ [ { - "method": "batchDictionaryEntries", "testName": "get batchDictionaryEntries results with minimal parameters", "parameters": { "dictionaryName": "compounds", @@ -26,7 +25,7 @@ "request": { "path": "/1/dictionaries/compounds/batch", "method": "POST", - "data": { + "body": { "requests": [ { "action": "addEntry", @@ -47,7 +46,6 @@ } }, { - "method": "batchDictionaryEntries", "testName": "get batchDictionaryEntries results with all parameters", "parameters": { "dictionaryName": "compounds", @@ -94,7 +92,7 @@ "request": { "path": "/1/dictionaries/compounds/batch", "method": "POST", - "data": { + "body": { "clearExistingDictionaryEntries": false, "requests": [ { diff --git a/tests/CTS/methods/requests/search/batchRules.json b/tests/CTS/methods/requests/search/batchRules.json index 6d7653e0cd..a0c35010eb 100644 --- a/tests/CTS/methods/requests/search/batchRules.json +++ b/tests/CTS/methods/requests/search/batchRules.json @@ -1,6 +1,5 @@ [ { - "method": "batchRules", "parameters": { "indexName": "indexName", "rule": [ @@ -39,7 +38,7 @@ "request": { "path": "/1/indexes/indexName/rules/batch", "method": "POST", - "data": [ + "body": [ { "objectID": "a-rule-id", "conditions": [ @@ -69,7 +68,7 @@ } } ], - "searchParams": { + "queryParameters": { "forwardToReplicas": "true", "clearExistingRules": "true" } diff --git a/tests/CTS/methods/requests/search/browse.json b/tests/CTS/methods/requests/search/browse.json index 56fb3a8a25..89783f993a 100644 --- a/tests/CTS/methods/requests/search/browse.json +++ b/tests/CTS/methods/requests/search/browse.json @@ -1,6 +1,5 @@ [ { - "method": "browse", "testName": "get browse results with minimal parameters", "parameters": { "indexName": "indexName" @@ -11,7 +10,6 @@ } }, { - "method": "browse", "testName": "get browse results with all parameters", "parameters": { "indexName": "indexName", @@ -23,7 +21,7 @@ "request": { "path": "/1/indexes/indexName/browse", "method": "POST", - "data": { + "body": { "params": "query=foo&facetFilters=['bar']", "cursor": "cts" } diff --git a/tests/CTS/methods/requests/search/clearAllSynonyms.json b/tests/CTS/methods/requests/search/clearAllSynonyms.json index 61daf6c09a..9bc14a64e9 100644 --- a/tests/CTS/methods/requests/search/clearAllSynonyms.json +++ b/tests/CTS/methods/requests/search/clearAllSynonyms.json @@ -1,6 +1,5 @@ [ { - "method": "clearAllSynonyms", "parameters": { "indexName": "indexName" }, diff --git a/tests/CTS/methods/requests/search/clearObjects.json b/tests/CTS/methods/requests/search/clearObjects.json index d3c37f1ac0..84f5d681a9 100644 --- a/tests/CTS/methods/requests/search/clearObjects.json +++ b/tests/CTS/methods/requests/search/clearObjects.json @@ -1,6 +1,5 @@ [ { - "method": "clearObjects", "parameters": { "indexName": "theIndexName" }, diff --git a/tests/CTS/methods/requests/search/clearRules.json b/tests/CTS/methods/requests/search/clearRules.json index 962a2eab17..6a26473d45 100644 --- a/tests/CTS/methods/requests/search/clearRules.json +++ b/tests/CTS/methods/requests/search/clearRules.json @@ -1,6 +1,5 @@ [ { - "method": "clearRules", "parameters": { "indexName": "indexName" }, diff --git a/tests/CTS/methods/requests/search/deleteApiKey.json b/tests/CTS/methods/requests/search/deleteApiKey.json index 0836c7ab23..a3f8e8d10f 100644 --- a/tests/CTS/methods/requests/search/deleteApiKey.json +++ b/tests/CTS/methods/requests/search/deleteApiKey.json @@ -1,6 +1,5 @@ [ { - "method": "deleteApiKey", "parameters": { "key": "myTestApiKey" }, diff --git a/tests/CTS/methods/requests/search/deleteBy.json b/tests/CTS/methods/requests/search/deleteBy.json index 4510f3cdee..de7d1b5684 100644 --- a/tests/CTS/methods/requests/search/deleteBy.json +++ b/tests/CTS/methods/requests/search/deleteBy.json @@ -1,6 +1,5 @@ [ { - "method": "deleteBy", "parameters": { "indexName": "theIndexName", "searchParams": { @@ -10,7 +9,7 @@ "request": { "path": "/1/indexes/theIndexName/deleteByQuery", "method": "POST", - "data": { + "body": { "query": "testQuery" } } diff --git a/tests/CTS/methods/requests/search/deleteIndex.json b/tests/CTS/methods/requests/search/deleteIndex.json index cf7feceef6..efc7903dfa 100644 --- a/tests/CTS/methods/requests/search/deleteIndex.json +++ b/tests/CTS/methods/requests/search/deleteIndex.json @@ -1,6 +1,5 @@ [ { - "method": "deleteIndex", "parameters": { "indexName": "theIndexName" }, diff --git a/tests/CTS/methods/requests/search/deleteObject.json b/tests/CTS/methods/requests/search/deleteObject.json index 504b52237d..683d63b390 100644 --- a/tests/CTS/methods/requests/search/deleteObject.json +++ b/tests/CTS/methods/requests/search/deleteObject.json @@ -1,6 +1,5 @@ [ { - "method": "deleteObject", "parameters": { "indexName": "theIndexName", "objectID": "uniqueID" diff --git a/tests/CTS/methods/requests/search/deleteRule.json b/tests/CTS/methods/requests/search/deleteRule.json index c7e191e719..e48af1234f 100644 --- a/tests/CTS/methods/requests/search/deleteRule.json +++ b/tests/CTS/methods/requests/search/deleteRule.json @@ -1,6 +1,5 @@ [ { - "method": "deleteRule", "parameters": { "indexName": "indexName", "objectID": "id1" diff --git a/tests/CTS/methods/requests/search/deleteSource.json b/tests/CTS/methods/requests/search/deleteSource.json index 2a2dd5d7a5..9c2448a98c 100644 --- a/tests/CTS/methods/requests/search/deleteSource.json +++ b/tests/CTS/methods/requests/search/deleteSource.json @@ -1,6 +1,5 @@ [ { - "method": "deleteSource", "parameters": { "source": "theSource" }, diff --git a/tests/CTS/methods/requests/search/deleteSynonym.json b/tests/CTS/methods/requests/search/deleteSynonym.json index 2c81eb8c6e..0743086dcd 100644 --- a/tests/CTS/methods/requests/search/deleteSynonym.json +++ b/tests/CTS/methods/requests/search/deleteSynonym.json @@ -1,6 +1,5 @@ [ { - "method": "deleteSynonym", "parameters": { "indexName": "indexName", "objectID": "id1" diff --git a/tests/CTS/methods/requests/search/getApiKey.json b/tests/CTS/methods/requests/search/getApiKey.json index e19f6b510f..6fc5d0afbb 100644 --- a/tests/CTS/methods/requests/search/getApiKey.json +++ b/tests/CTS/methods/requests/search/getApiKey.json @@ -1,6 +1,5 @@ [ { - "method": "getApiKey", "parameters": { "key": "myTestApiKey" }, diff --git a/tests/CTS/methods/requests/search/getDictionaryLanguages.json b/tests/CTS/methods/requests/search/getDictionaryLanguages.json index bd7d3e76c6..d6ef8a120d 100644 --- a/tests/CTS/methods/requests/search/getDictionaryLanguages.json +++ b/tests/CTS/methods/requests/search/getDictionaryLanguages.json @@ -1,6 +1,5 @@ [ { - "method": "getDictionaryLanguages", "testName": "get getDictionaryLanguages", "parameters": {}, "request": { diff --git a/tests/CTS/methods/requests/search/getDictionarySettings.json b/tests/CTS/methods/requests/search/getDictionarySettings.json index 981fedb2bb..7e68e12522 100644 --- a/tests/CTS/methods/requests/search/getDictionarySettings.json +++ b/tests/CTS/methods/requests/search/getDictionarySettings.json @@ -1,6 +1,5 @@ [ { - "method": "getDictionarySettings", "testName": "get getDictionarySettings results", "parameters": {}, "request": { diff --git a/tests/CTS/methods/requests/search/getLogs.json b/tests/CTS/methods/requests/search/getLogs.json index ec77a53f23..d8f50a32a7 100644 --- a/tests/CTS/methods/requests/search/getLogs.json +++ b/tests/CTS/methods/requests/search/getLogs.json @@ -1,6 +1,5 @@ [ { - "method": "getLogs", "parameters": { "offset": 5, "length": 10, @@ -10,7 +9,7 @@ "request": { "path": "/1/logs", "method": "GET", - "searchParams": { + "queryParameters": { "offset": "5", "length": "10", "indexName": "theIndexName", diff --git a/tests/CTS/methods/requests/search/getObject.json b/tests/CTS/methods/requests/search/getObject.json index 00aa0e4020..6479ffb292 100644 --- a/tests/CTS/methods/requests/search/getObject.json +++ b/tests/CTS/methods/requests/search/getObject.json @@ -1,6 +1,5 @@ [ { - "method": "getObject", "parameters": { "indexName": "theIndexName", "objectID": "uniqueID", @@ -12,7 +11,7 @@ "request": { "path": "/1/indexes/theIndexName/uniqueID", "method": "GET", - "searchParams": { + "queryParameters": { "attributesToRetrieve": "attr1,attr2" } } diff --git a/tests/CTS/methods/requests/search/getObjects.json b/tests/CTS/methods/requests/search/getObjects.json index ee802641f9..a67ada0fc4 100644 --- a/tests/CTS/methods/requests/search/getObjects.json +++ b/tests/CTS/methods/requests/search/getObjects.json @@ -1,6 +1,5 @@ [ { - "method": "getObjects", "parameters": { "requests": [ { @@ -16,7 +15,7 @@ "request": { "path": "/1/indexes/*/objects", "method": "POST", - "data": { + "body": { "requests": [ { "attributesToRetrieve": [ diff --git a/tests/CTS/methods/requests/search/getRule.json b/tests/CTS/methods/requests/search/getRule.json index 55fed888dd..7d778b480b 100644 --- a/tests/CTS/methods/requests/search/getRule.json +++ b/tests/CTS/methods/requests/search/getRule.json @@ -1,6 +1,5 @@ [ { - "method": "getRule", "parameters": { "indexName": "indexName", "objectID": "id1" diff --git a/tests/CTS/methods/requests/search/getSettings.json b/tests/CTS/methods/requests/search/getSettings.json index 3a6e624a4d..9177b9abc9 100644 --- a/tests/CTS/methods/requests/search/getSettings.json +++ b/tests/CTS/methods/requests/search/getSettings.json @@ -1,6 +1,5 @@ [ { - "method": "getSettings", "parameters": { "indexName": "theIndexName" }, diff --git a/tests/CTS/methods/requests/search/getSources.json b/tests/CTS/methods/requests/search/getSources.json index 09d67466d9..d833573b56 100644 --- a/tests/CTS/methods/requests/search/getSources.json +++ b/tests/CTS/methods/requests/search/getSources.json @@ -1,6 +1,5 @@ [ { - "method": "getSources", "parameters": {}, "request": { "path": "/1/security/sources", diff --git a/tests/CTS/methods/requests/search/getSynonym.json b/tests/CTS/methods/requests/search/getSynonym.json index 80f44921fe..8492e0b9cd 100644 --- a/tests/CTS/methods/requests/search/getSynonym.json +++ b/tests/CTS/methods/requests/search/getSynonym.json @@ -1,6 +1,5 @@ [ { - "method": "getSynonym", "parameters": { "indexName": "indexName", "objectID": "id1" diff --git a/tests/CTS/methods/requests/search/getTask.json b/tests/CTS/methods/requests/search/getTask.json index f4312d9147..4714b62aa2 100644 --- a/tests/CTS/methods/requests/search/getTask.json +++ b/tests/CTS/methods/requests/search/getTask.json @@ -1,6 +1,5 @@ [ { - "method": "getTask", "parameters": { "indexName": "theIndexName", "taskID": 123 diff --git a/tests/CTS/methods/requests/search/getTopUserIds.json b/tests/CTS/methods/requests/search/getTopUserIds.json index 65f0a449fd..7521634ccd 100644 --- a/tests/CTS/methods/requests/search/getTopUserIds.json +++ b/tests/CTS/methods/requests/search/getTopUserIds.json @@ -1,6 +1,5 @@ [ { - "method": "getTopUserIds", "parameters": {}, "request": { "path": "/1/clusters/mapping/top", diff --git a/tests/CTS/methods/requests/search/getUserId.json b/tests/CTS/methods/requests/search/getUserId.json index ef369ed622..2dcd6c7be5 100644 --- a/tests/CTS/methods/requests/search/getUserId.json +++ b/tests/CTS/methods/requests/search/getUserId.json @@ -1,6 +1,5 @@ [ { - "method": "getUserId", "parameters": { "userID": "uniqueID" }, diff --git a/tests/CTS/methods/requests/search/hasPendingMappings.json b/tests/CTS/methods/requests/search/hasPendingMappings.json index 009c29d300..6c0699f83b 100644 --- a/tests/CTS/methods/requests/search/hasPendingMappings.json +++ b/tests/CTS/methods/requests/search/hasPendingMappings.json @@ -1,13 +1,12 @@ [ { - "method": "hasPendingMappings", "parameters": { "getClusters": true }, "request": { "path": "/1/clusters/mapping/pending", "method": "GET", - "searchParams": { + "queryParameters": { "getClusters": "true" } } diff --git a/tests/CTS/methods/requests/search/listApiKeys.json b/tests/CTS/methods/requests/search/listApiKeys.json index a5b48efa01..f28528a9be 100644 --- a/tests/CTS/methods/requests/search/listApiKeys.json +++ b/tests/CTS/methods/requests/search/listApiKeys.json @@ -1,6 +1,5 @@ [ { - "method": "listApiKeys", "parameters": {}, "request": { "path": "/1/keys", diff --git a/tests/CTS/methods/requests/search/listClusters.json b/tests/CTS/methods/requests/search/listClusters.json index 9d42db7df0..14b8a6afac 100644 --- a/tests/CTS/methods/requests/search/listClusters.json +++ b/tests/CTS/methods/requests/search/listClusters.json @@ -1,6 +1,5 @@ [ { - "method": "listClusters", "parameters": {}, "request": { "path": "/1/clusters", diff --git a/tests/CTS/methods/requests/search/listIndices.json b/tests/CTS/methods/requests/search/listIndices.json index a56bb3b286..177d480699 100644 --- a/tests/CTS/methods/requests/search/listIndices.json +++ b/tests/CTS/methods/requests/search/listIndices.json @@ -1,13 +1,12 @@ [ { - "method": "listIndices", "parameters": { "page": 8 }, "request": { "path": "/1/indexes", "method": "GET", - "searchParams": { + "queryParameters": { "page": "8" } } diff --git a/tests/CTS/methods/requests/search/listUserIds.json b/tests/CTS/methods/requests/search/listUserIds.json index ba710bea9e..ceeda7a1e1 100644 --- a/tests/CTS/methods/requests/search/listUserIds.json +++ b/tests/CTS/methods/requests/search/listUserIds.json @@ -1,6 +1,5 @@ [ { - "method": "listUserIds", "parameters": { "page": 8, "hitsPerPage": 100 @@ -8,7 +7,7 @@ "request": { "path": "/1/clusters/mapping", "method": "GET", - "searchParams": { + "queryParameters": { "page": "8", "hitsPerPage": "100" } diff --git a/tests/CTS/methods/requests/search/multipleBatch.json b/tests/CTS/methods/requests/search/multipleBatch.json index 71326b5669..7acceef5bf 100644 --- a/tests/CTS/methods/requests/search/multipleBatch.json +++ b/tests/CTS/methods/requests/search/multipleBatch.json @@ -1,6 +1,5 @@ [ { - "method": "multipleBatch", "parameters": { "requests": [ { @@ -15,7 +14,7 @@ "request": { "path": "/1/indexes/*/batch", "method": "POST", - "data": { + "body": { "requests": [ { "action": "addObject", diff --git a/tests/CTS/methods/requests/search/multipleQueries.json b/tests/CTS/methods/requests/search/multipleQueries.json index d994520843..187ca6ccc4 100644 --- a/tests/CTS/methods/requests/search/multipleQueries.json +++ b/tests/CTS/methods/requests/search/multipleQueries.json @@ -1,6 +1,5 @@ [ { - "method": "multipleQueries", "parameters": { "requests": [ { @@ -16,7 +15,7 @@ "request": { "path": "/1/indexes/*/queries", "method": "POST", - "data": { + "body": { "requests": [ { "indexName": "theIndexName", diff --git a/tests/CTS/methods/requests/search/operationIndex.json b/tests/CTS/methods/requests/search/operationIndex.json index b8584dbdf6..8690e8fdea 100644 --- a/tests/CTS/methods/requests/search/operationIndex.json +++ b/tests/CTS/methods/requests/search/operationIndex.json @@ -1,6 +1,5 @@ [ { - "method": "operationIndex", "parameters": { "indexName": "theIndexName", "operationIndexParams": { @@ -15,7 +14,7 @@ "request": { "path": "/1/indexes/theIndexName/operation", "method": "POST", - "data": { + "body": { "operation": "copy", "destination": "dest", "scope": [ diff --git a/tests/CTS/methods/requests/search/partialUpdateObject.json b/tests/CTS/methods/requests/search/partialUpdateObject.json index 9cfcf77523..eb5c527afa 100644 --- a/tests/CTS/methods/requests/search/partialUpdateObject.json +++ b/tests/CTS/methods/requests/search/partialUpdateObject.json @@ -1,6 +1,5 @@ [ { - "method": "partialUpdateObject", "parameters": { "indexName": "theIndexName", "objectID": "uniqueID", @@ -18,7 +17,7 @@ "request": { "path": "/1/indexes/theIndexName/uniqueID/partial", "method": "POST", - "data": [ + "body": [ { "id1": "test", "id2": { @@ -27,7 +26,7 @@ } } ], - "searchParams": { + "queryParameters": { "createIfNotExists": "true" } } diff --git a/tests/CTS/methods/requests/search/removeUserId.json b/tests/CTS/methods/requests/search/removeUserId.json index a932f36528..4b0d7a27ee 100644 --- a/tests/CTS/methods/requests/search/removeUserId.json +++ b/tests/CTS/methods/requests/search/removeUserId.json @@ -1,6 +1,5 @@ [ { - "method": "removeUserId", "parameters": { "userID": "uniqueID" }, diff --git a/tests/CTS/methods/requests/search/replaceSources.json b/tests/CTS/methods/requests/search/replaceSources.json index 11d64ae1f2..009a5003f1 100644 --- a/tests/CTS/methods/requests/search/replaceSources.json +++ b/tests/CTS/methods/requests/search/replaceSources.json @@ -1,6 +1,5 @@ [ { - "method": "replaceSources", "parameters": { "source": [ { @@ -12,7 +11,7 @@ "request": { "path": "/1/security/sources", "method": "PUT", - "data": [ + "body": [ { "source": "theSource", "description": "theDescription" diff --git a/tests/CTS/methods/requests/search/restoreApiKey.json b/tests/CTS/methods/requests/search/restoreApiKey.json index 9d6048bd1f..cb0a8b24dc 100644 --- a/tests/CTS/methods/requests/search/restoreApiKey.json +++ b/tests/CTS/methods/requests/search/restoreApiKey.json @@ -1,6 +1,5 @@ [ { - "method": "restoreApiKey", "parameters": { "key": "myApiKey" }, diff --git a/tests/CTS/methods/requests/search/saveObject.json b/tests/CTS/methods/requests/search/saveObject.json index 529ecbc6fa..bf0f0259d5 100644 --- a/tests/CTS/methods/requests/search/saveObject.json +++ b/tests/CTS/methods/requests/search/saveObject.json @@ -1,6 +1,5 @@ [ { - "method": "saveObject", "parameters": { "indexName": "theIndexName", "body": { @@ -11,7 +10,7 @@ "request": { "path": "/1/indexes/theIndexName", "method": "POST", - "data": { + "body": { "objectID": "id", "test": "val" } diff --git a/tests/CTS/methods/requests/search/saveRule.json b/tests/CTS/methods/requests/search/saveRule.json index 5dbb735fb9..474fe76e0c 100644 --- a/tests/CTS/methods/requests/search/saveRule.json +++ b/tests/CTS/methods/requests/search/saveRule.json @@ -1,6 +1,5 @@ [ { - "method": "saveRule", "parameters": { "indexName": "indexName", "objectID": "id1", @@ -23,7 +22,7 @@ "request": { "path": "/1/indexes/indexName/rules/id1", "method": "PUT", - "data": { + "body": { "objectID": "id1", "conditions": [ { @@ -37,7 +36,7 @@ } } }, - "searchParams": { + "queryParameters": { "forwardToReplicas": "true" } } diff --git a/tests/CTS/methods/requests/search/saveSynonym.json b/tests/CTS/methods/requests/search/saveSynonym.json index a812b9d08e..3a2329da14 100644 --- a/tests/CTS/methods/requests/search/saveSynonym.json +++ b/tests/CTS/methods/requests/search/saveSynonym.json @@ -1,6 +1,5 @@ [ { - "method": "saveSynonym", "parameters": { "indexName": "indexName", "objectID": "id1", @@ -18,7 +17,7 @@ "request": { "path": "/1/indexes/indexName/synonyms/id1", "method": "PUT", - "data": { + "body": { "objectID": "id1", "type": "synonym", "synonyms": [ @@ -27,7 +26,7 @@ "auto" ] }, - "searchParams": { + "queryParameters": { "forwardToReplicas": "true" } } diff --git a/tests/CTS/methods/requests/search/saveSynonyms.json b/tests/CTS/methods/requests/search/saveSynonyms.json index 37eb61cea6..16e1b65fea 100644 --- a/tests/CTS/methods/requests/search/saveSynonyms.json +++ b/tests/CTS/methods/requests/search/saveSynonyms.json @@ -1,6 +1,5 @@ [ { - "method": "saveSynonyms", "parameters": { "indexName": "indexName", "synonymHit": [ @@ -30,7 +29,7 @@ "request": { "path": "/1/indexes/indexName/synonyms/batch", "method": "POST", - "data": [ + "body": [ { "objectID": "id1", "type": "synonym", @@ -51,7 +50,7 @@ ] } ], - "searchParams": { + "queryParameters": { "forwardToReplicas": "true", "replaceExistingSynonyms": "false" } diff --git a/tests/CTS/methods/requests/search/search.json b/tests/CTS/methods/requests/search/search.json index 4f7f0c1317..d279a668ce 100644 --- a/tests/CTS/methods/requests/search/search.json +++ b/tests/CTS/methods/requests/search/search.json @@ -1,6 +1,5 @@ [ { - "method": "search", "testName": "search with minimal parameters", "parameters": { "indexName": "indexName", @@ -11,7 +10,7 @@ "request": { "path": "/1/indexes/indexName/query", "method": "POST", - "data": { + "body": { "query": "myQuery" } } diff --git a/tests/CTS/methods/requests/search/searchDictionaryEntries.json b/tests/CTS/methods/requests/search/searchDictionaryEntries.json index ed44e1b463..7021cfda72 100644 --- a/tests/CTS/methods/requests/search/searchDictionaryEntries.json +++ b/tests/CTS/methods/requests/search/searchDictionaryEntries.json @@ -1,6 +1,5 @@ [ { - "method": "searchDictionaryEntries", "testName": "get searchDictionaryEntries results with minimal parameters", "parameters": { "dictionaryName": "compounds", @@ -11,13 +10,12 @@ "request": { "path": "/1/dictionaries/compounds/search", "method": "POST", - "data": { + "body": { "query": "foo" } } }, { - "method": "searchDictionaryEntries", "testName": "get searchDictionaryEntries results with all parameters", "parameters": { "dictionaryName": "compounds", @@ -31,7 +29,7 @@ "request": { "path": "/1/dictionaries/compounds/search", "method": "POST", - "data": { + "body": { "query": "foo", "page": 4, "hitsPerPage": 2, diff --git a/tests/CTS/methods/requests/search/searchForFacetValues.json b/tests/CTS/methods/requests/search/searchForFacetValues.json index 56d7627fc5..8dd92948f2 100644 --- a/tests/CTS/methods/requests/search/searchForFacetValues.json +++ b/tests/CTS/methods/requests/search/searchForFacetValues.json @@ -1,6 +1,5 @@ [ { - "method": "searchForFacetValues", "testName": "get searchForFacetValues results with minimal parameters", "parameters": { "indexName": "indexName", @@ -12,7 +11,6 @@ } }, { - "method": "searchForFacetValues", "testName": "get searchForFacetValues results with all parameters", "parameters": { "indexName": "indexName", @@ -26,7 +24,7 @@ "request": { "path": "/1/indexes/indexName/facets/facetName/query", "method": "POST", - "data": { + "body": { "params": "query=foo&facetFilters=['bar']", "facetQuery": "foo", "maxFacetHits": 42 diff --git a/tests/CTS/methods/requests/search/searchRules.json b/tests/CTS/methods/requests/search/searchRules.json index 8c9a181bcd..a83e199c84 100644 --- a/tests/CTS/methods/requests/search/searchRules.json +++ b/tests/CTS/methods/requests/search/searchRules.json @@ -1,6 +1,5 @@ [ { - "method": "searchRules", "parameters": { "indexName": "indexName", "searchRulesParams": { @@ -10,7 +9,7 @@ "request": { "path": "/1/indexes/indexName/rules/search", "method": "POST", - "data": { + "body": { "query": "something" } } diff --git a/tests/CTS/methods/requests/search/searchSynonyms.json b/tests/CTS/methods/requests/search/searchSynonyms.json index 1a8d39c909..0a1895602a 100644 --- a/tests/CTS/methods/requests/search/searchSynonyms.json +++ b/tests/CTS/methods/requests/search/searchSynonyms.json @@ -1,6 +1,5 @@ [ { - "method": "searchSynonyms", "parameters": { "indexName": "indexName" }, diff --git a/tests/CTS/methods/requests/search/searchUserIds.json b/tests/CTS/methods/requests/search/searchUserIds.json index 48f9ead386..79d681f0a5 100644 --- a/tests/CTS/methods/requests/search/searchUserIds.json +++ b/tests/CTS/methods/requests/search/searchUserIds.json @@ -1,6 +1,5 @@ [ { - "method": "searchUserIds", "parameters": { "query": "test", "clusterName": "theClusterName", @@ -10,7 +9,7 @@ "request": { "path": "/1/clusters/mapping/search", "method": "POST", - "data": { + "body": { "query": "test", "clusterName": "theClusterName", "page": 5, diff --git a/tests/CTS/methods/requests/search/setDictionarySettings.json b/tests/CTS/methods/requests/search/setDictionarySettings.json index af1148b5c0..d152b2e734 100644 --- a/tests/CTS/methods/requests/search/setDictionarySettings.json +++ b/tests/CTS/methods/requests/search/setDictionarySettings.json @@ -1,6 +1,5 @@ [ { - "method": "setDictionarySettings", "testName": "get setDictionarySettings results with minimal parameters", "parameters": { "disableStandardEntries": { @@ -14,7 +13,7 @@ "request": { "path": "/1/dictionaries/*/settings", "method": "PUT", - "data": { + "body": { "disableStandardEntries": { "plurals": { "fr": false, @@ -26,7 +25,6 @@ } }, { - "method": "setDictionarySettings", "testName": "get setDictionarySettings results with all parameters", "parameters": { "disableStandardEntries": { @@ -46,7 +44,7 @@ "request": { "path": "/1/dictionaries/*/settings", "method": "PUT", - "data": { + "body": { "disableStandardEntries": { "plurals": { "fr": false, diff --git a/tests/CTS/methods/requests/search/setSettings.json b/tests/CTS/methods/requests/search/setSettings.json index ec4a635343..db6e25f3fd 100644 --- a/tests/CTS/methods/requests/search/setSettings.json +++ b/tests/CTS/methods/requests/search/setSettings.json @@ -1,6 +1,5 @@ [ { - "method": "setSettings", "parameters": { "indexName": "theIndexName", "indexSettings": { @@ -11,10 +10,10 @@ "request": { "path": "/1/indexes/theIndexName/settings", "method": "PUT", - "data": { + "body": { "paginationLimitedTo": 10 }, - "searchParams": { + "queryParameters": { "forwardToReplicas": "true" } } diff --git a/tests/CTS/methods/requests/search/updateApiKey.json b/tests/CTS/methods/requests/search/updateApiKey.json index f4d1a65486..ec12c580a4 100644 --- a/tests/CTS/methods/requests/search/updateApiKey.json +++ b/tests/CTS/methods/requests/search/updateApiKey.json @@ -1,6 +1,5 @@ [ { - "method": "updateApiKey", "parameters": { "key": "myApiKey", "apiKey": { @@ -16,7 +15,7 @@ "request": { "path": "/1/keys/myApiKey", "method": "PUT", - "data": { + "body": { "acl": [ "search", "addObject" diff --git a/tests/CTS/methods/requests/sources/postIngestUrl.json b/tests/CTS/methods/requests/sources/postIngestUrl.json index 7bb6c1fed1..a247289d8a 100644 --- a/tests/CTS/methods/requests/sources/postIngestUrl.json +++ b/tests/CTS/methods/requests/sources/postIngestUrl.json @@ -1,6 +1,5 @@ [ { - "method": "postIngestUrl", "testName": "post postIngestUrl with minimal parameters", "parameters": { "type": "csv", @@ -16,7 +15,7 @@ "request": { "path": "/1/ingest/url", "method": "POST", - "data": { + "body": { "type": "csv", "input": { "url": "https://example.com/file.csv" @@ -30,7 +29,6 @@ } }, { - "method": "postIngestUrl", "testName": "post postIngestUrl with all parameters", "parameters": { "type": "csv", @@ -53,7 +51,7 @@ "request": { "path": "/1/ingest/url", "method": "POST", - "data": { + "body": { "type": "csv", "uniqueIDColumn": "foobar", "input": { diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java index 0185285041..96fdf1b9d7 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java @@ -1,421 +1,494 @@ package com.algolia.methods.requests; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import com.algolia.JSON; -import com.algolia.Pair; -import com.algolia.api.AbtestingClient; -import com.algolia.model.abtesting.*; -import com.algolia.utils.echo.*; -import com.google.gson.reflect.TypeToken; import java.util.*; -import org.junit.jupiter.api.BeforeAll; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.BeforeAll; +import com.google.gson.reflect.TypeToken; + +import com.algolia.JSON; +import com.algolia.Pair; +import com.algolia.model.abtesting.*; +import com.algolia.api.AbtestingClient; +import com.algolia.utils.echo.*; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class AbtestingClientTests { + private AbtestingClient client; - private AbtestingClient client; + @BeforeAll + void init() { + client = new AbtestingClient("appId", "apiKey", new EchoRequester()); + } - @BeforeAll - void init() { - client = new AbtestingClient("appId", "apiKey", new EchoRequester()); - } + @Test + @DisplayName("addABTests with minimal parameters") + void addABTestsTest0() { + - @Test - @DisplayName("addABTests with minimal parameters") - void addABTestsTest0() { - AddABTestsRequest addABTestsRequest0 = new AddABTestsRequest(); - { - String endAt1 = "2022-12-31T00:00:00.000Z"; - addABTestsRequest0.setEndAt(endAt1); - String name1 = "myABTest"; - addABTestsRequest0.setName(name1); - List variant1 = new ArrayList<>(); - { - AbTestsVariant variant_02 = new AbTestsVariant(); - { - String index3 = "AB_TEST_1"; - variant_02.setIndex(index3); - int trafficPercentage3 = 30; +AddABTestsRequest addABTestsRequest0 = new AddABTestsRequest(); +{ String endAt1 = "2022-12-31T00:00:00.000Z"; - variant_02.setTrafficPercentage(trafficPercentage3); - } - variant1.add(AddABTestsVariant.ofAbTestsVariant(variant_02)); - AbTestsVariant variant_12 = new AbTestsVariant(); - { - String index3 = "AB_TEST_2"; - variant_12.setIndex(index3); - int trafficPercentage3 = 50; - variant_12.setTrafficPercentage(trafficPercentage3); - } - variant1.add(AddABTestsVariant.ofAbTestsVariant(variant_12)); - } - addABTestsRequest0.setVariant(variant1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addABTests(addABTestsRequest0); - } - ); - - assertEquals(req.getPath(), "/2/abtests"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - } - ); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; - - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - - parameters0.put("query", query1); +addABTestsRequest0.setEndAt(endAt1); +String name1 = "myABTest"; + + + + + + +addABTestsRequest0.setName(name1); + + + + + + +List< +> + variant1 = new ArrayList<>(); { + + + + + + +AbTestsVariant variant_02 = new AbTestsVariant(); +{ String index3 = "AB_TEST_1"; + + + + + + +variant_02.setIndex(index3); + +int trafficPercentage3 = 30; + + + + + +variant_02.setTrafficPercentage(trafficPercentage3); + }variant1.add(.of(variant_02)); + + + + + + +AbTestsVariant variant_12 = new AbTestsVariant(); +{ String index3 = "AB_TEST_2"; + + + + + + +variant_12.setIndex(index3); + +int trafficPercentage3 = 50; + + + + + +variant_12.setTrafficPercentage(trafficPercentage3); + }variant1.add(.of(variant_12)); } +addABTestsRequest0.setVariant(variant1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.addABTests(addABTestsRequest0); + }); + + assertEquals(req.getPath(), "/2/abtests"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + } + @Test + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); } - } - - @Test - @DisplayName("deleteABTest") - void deleteABTestTest0() { - int id0 = 42; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteABTest(id0); - } - ); - - assertEquals(req.getPath(), "/2/abtests/42"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; - - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - - parameters0.put("query", query1); + @Test + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0,parameters0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); + + } + @Test + @DisplayName("deleteABTest") + void deleteABTestTest0() { + +int id0 = 42; + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteABTest(id0); + }); + + assertEquals(req.getPath(), "/2/abtests/42"); + assertEquals(req.getMethod(), "DELETE"); + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); } - } - - @Test - @DisplayName("getABTest") - void getABTestTest0() { - int id0 = 42; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getABTest(id0); - } - ); - - assertEquals(req.getPath(), "/2/abtests/42"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("listABTests with minimal parameters") - void listABTestsTest0() { - int offset0 = 42; - - int limit0 = 21; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listABTests(offset0, limit0); - } - ); - - assertEquals(req.getPath(), "/2/abtests"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"offset\":\"42\",\"limit\":\"21\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + @Test + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + + } - } + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; + + - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { - String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - } - ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); - } - @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { - String path0 = "/test/all"; - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - parameters0.put("query", query1); + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0,parameters0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "GET"); + + } + @Test + @DisplayName("getABTest") + void getABTestTest0() { + +int id0 = 42; + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getABTest(id0); + }); + + assertEquals(req.getPath(), "/2/abtests/42"); + assertEquals(req.getMethod(), "GET"); - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; - body0.put("body", body1); } + @Test + @DisplayName("listABTests with minimal parameters") + void listABTestsTest0() { + +int offset0 = 42; + + + + + + +int limit0 = 21; + + + + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listABTests(offset0,limit0); + }); + + assertEquals(req.getPath(), "/2/abtests"); + assertEquals(req.getMethod(), "GET"); + + + HashMap expectedQuery = JSON.deserialize("{\"offset\":\"42\",\"limit\":\"21\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); } - } + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; + + + + - @Test - @DisplayName("allow put method for a custom path with minimal parameters") - void putTest0() { - String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - } - ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "PUT"); - } - @Test - @DisplayName("allow put method for a custom path with all parameters") - void putTest1() { - String path0 = "/test/all"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "POST"); - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - parameters0.put("query", query1); } + @Test + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + + + + + +Map body0 = new HashMap<>(); +{ String body1 = "parameters"; + + + + + + +body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0,parameters0,body0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "POST"); - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; - body0.put("body", body1); } + @Test + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); } - } + @Test + @DisplayName("allow put method for a custom path with all parameters") + void putTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + - @Test - @DisplayName("stopABTest") - void stopABTestTest0() { - int id0 = 42; +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.stopABTest(id0); - } - ); - assertEquals(req.getPath(), "/2/abtests/42/stop"); - assertEquals(req.getMethod(), "POST"); - } + + + + +parameters0.put("query", query1); + } + + + + + + +Map body0 = new HashMap<>(); +{ String body1 = "parameters"; + + + + + + +body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0,parameters0,body0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + + + } + @Test + @DisplayName("stopABTest") + void stopABTestTest0() { + +int id0 = 42; + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.stopABTest(id0); + }); + + assertEquals(req.getPath(), "/2/abtests/42/stop"); + assertEquals(req.getMethod(), "POST"); + + + } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java index 9b353c7f8e..0b27bae702 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import com.algolia.JSON; import com.algolia.Pair; @@ -15,12 +14,9 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class AnalyticsClientTests { - private AnalyticsClient client; @BeforeAll @@ -33,10 +29,12 @@ void init() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -54,34 +52,15 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -89,10 +68,12 @@ void delTest1() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -110,34 +91,15 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -145,33 +107,23 @@ void getTest1() { void getAverageClickPositionTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAverageClickPosition(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getAverageClickPosition(index0); + }); assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -186,38 +138,24 @@ void getAverageClickPositionTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAverageClickPosition( - index0, - startDate0, - endDate0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getAverageClickPosition(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -226,33 +164,23 @@ void getAverageClickPositionTest1() { void getClickPositionsTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickPositions(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getClickPositions(index0); + }); assertEquals(req.getPath(), "/2/clicks/positions"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -267,33 +195,24 @@ void getClickPositionsTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickPositions(index0, startDate0, endDate0, tags0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getClickPositions(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/clicks/positions"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -302,33 +221,23 @@ void getClickPositionsTest1() { void getClickThroughRateTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickThroughRate(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getClickThroughRate(index0); + }); assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -343,33 +252,24 @@ void getClickThroughRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickThroughRate(index0, startDate0, endDate0, tags0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getClickThroughRate(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -378,33 +278,23 @@ void getClickThroughRateTest1() { void getConversationRateTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConversationRate(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getConversationRate(index0); + }); assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -419,33 +309,24 @@ void getConversationRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConversationRate(index0, startDate0, endDate0, tags0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getConversationRate(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -454,33 +335,23 @@ void getConversationRateTest1() { void getNoClickRateTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoClickRate(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getNoClickRate(index0); + }); assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -495,33 +366,24 @@ void getNoClickRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoClickRate(index0, startDate0, endDate0, tags0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getNoClickRate(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -530,33 +392,23 @@ void getNoClickRateTest1() { void getNoResultsRateTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoResultsRate(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getNoResultsRate(index0); + }); assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -571,33 +423,24 @@ void getNoResultsRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoResultsRate(index0, startDate0, endDate0, tags0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getNoResultsRate(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -606,33 +449,23 @@ void getNoResultsRateTest1() { void getSearchesCountTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesCount(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getSearchesCount(index0); + }); assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -647,33 +480,24 @@ void getSearchesCountTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesCount(index0, startDate0, endDate0, tags0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getSearchesCount(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -682,33 +506,23 @@ void getSearchesCountTest1() { void getSearchesNoClicksTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoClicks(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getSearchesNoClicks(index0); + }); assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -727,40 +541,25 @@ void getSearchesNoClicksTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoClicks( - index0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getSearchesNoClicks( + index0, startDate0, endDate0, limit0, offset0, tags0); + }); assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -769,33 +568,23 @@ void getSearchesNoClicksTest1() { void getSearchesNoResultsTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoResults(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getSearchesNoResults(index0); + }); assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -814,40 +603,25 @@ void getSearchesNoResultsTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoResults( - index0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getSearchesNoResults( + index0, startDate0, endDate0, limit0, offset0, tags0); + }); assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -856,33 +630,23 @@ void getSearchesNoResultsTest1() { void getStatusTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getStatus(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getStatus(index0); + }); assertEquals(req.getPath(), "/2/status"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -891,33 +655,23 @@ void getStatusTest0() { void getTopCountriesTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopCountries(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopCountries(index0); + }); assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -936,40 +690,25 @@ void getTopCountriesTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopCountries( - index0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopCountries( + index0, startDate0, endDate0, limit0, offset0, tags0); + }); assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -978,33 +717,23 @@ void getTopCountriesTest1() { void getTopFilterAttributesTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterAttributes(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFilterAttributes(index0); + }); assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1025,41 +754,25 @@ void getTopFilterAttributesTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterAttributes( - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFilterAttributes( + index0, search0, startDate0, endDate0, limit0, offset0, tags0); + }); assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1070,72 +783,50 @@ void getTopFilterForAttributeTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute(attribute0, index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFilterForAttribute(attribute0, index0); + }); assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @Test - @DisplayName( - "get getTopFilterForAttribute with minimal parameters and multiple attributes" - ) + @DisplayName("get getTopFilterForAttribute with minimal parameters and multiple attributes") void getTopFilterForAttributeTest1() { String attribute0 = "myAttribute1,myAttribute2"; String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute(attribute0, index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFilterForAttribute(attribute0, index0); + }); assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1158,49 +849,30 @@ void getTopFilterForAttributeTest2() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute( - attribute0, - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFilterForAttribute( + attribute0, index0, search0, startDate0, endDate0, limit0, offset0, tags0); + }); assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @Test - @DisplayName( - "get getTopFilterForAttribute with all parameters and multiple attributes" - ) + @DisplayName("get getTopFilterForAttribute with all parameters and multiple attributes") void getTopFilterForAttributeTest3() { String attribute0 = "myAttribute1,myAttribute2"; @@ -1218,42 +890,25 @@ void getTopFilterForAttributeTest3() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute( - attribute0, - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFilterForAttribute( + attribute0, index0, search0, startDate0, endDate0, limit0, offset0, tags0); + }); assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1262,33 +917,23 @@ void getTopFilterForAttributeTest3() { void getTopFiltersNoResultsTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFiltersNoResults(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFiltersNoResults(index0); + }); assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1309,41 +954,25 @@ void getTopFiltersNoResultsTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFiltersNoResults( - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopFiltersNoResults( + index0, search0, startDate0, endDate0, limit0, offset0, tags0); + }); assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1352,33 +981,23 @@ void getTopFiltersNoResultsTest1() { void getTopHitsTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopHits(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopHits(index0); + }); assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1401,42 +1020,32 @@ void getTopHitsTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopHits( - index0, - search0, - clickAnalytics0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopHits( + index0, + search0, + clickAnalytics0, + startDate0, + endDate0, + limit0, + offset0, + tags0); + }); assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1445,33 +1054,23 @@ void getTopHitsTest1() { void getTopSearchesTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopSearches(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopSearches(index0); + }); assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1496,43 +1095,33 @@ void getTopSearchesTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopSearches( - index0, - clickAnalytics0, - startDate0, - endDate0, - orderBy0, - direction0, - limit0, - offset0, - tags0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getTopSearches( + index0, + clickAnalytics0, + startDate0, + endDate0, + orderBy0, + direction0, + limit0, + offset0, + tags0); + }); assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1541,33 +1130,23 @@ void getTopSearchesTest1() { void getUsersCountTest0() { String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUsersCount(index0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getUsersCount(index0); + }); assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\"}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1582,33 +1161,24 @@ void getUsersCountTest1() { String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUsersCount(index0, startDate0, endDate0, tags0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getUsersCount(index0, startDate0, endDate0, tags0); + }); assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); - Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType() - ); + HashMap expectedQuery = + JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } } @@ -1617,10 +1187,12 @@ void getUsersCountTest1() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -1645,42 +1217,15 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -1688,10 +1233,12 @@ void postTest1() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -1716,41 +1263,14 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java index 426a5b7c76..427b8407e0 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java @@ -2,14 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import com.algolia.JSON; -import com.algolia.Pair; import com.algolia.api.InsightsClient; import com.algolia.model.insights.*; import com.algolia.utils.echo.*; -import com.google.gson.reflect.TypeToken; import java.util.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -20,7 +16,6 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class InsightsClientTests { - private InsightsClient client; @BeforeAll @@ -33,10 +28,12 @@ void init() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -54,34 +51,15 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -89,10 +67,12 @@ void delTest1() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -110,34 +90,15 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -145,10 +106,12 @@ void getTest1() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -173,47 +136,21 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @DisplayName("pushEvents") void pushEventsTest0() { + InsightEvents insightEvents0 = new InsightEvents(); { List events1 = new ArrayList<>(); @@ -334,25 +271,27 @@ void pushEventsTest0() { insightEvents0.setEvents(events1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.pushEvents(insightEvents0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.pushEvents(insightEvents0); + }); assertEquals(req.getPath(), "/1/events"); assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"events\":[{\"eventType\":\"click\",\"eventName\":\"Product" + - " Clicked\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\",\"positions\":[7,6]},{\"eventType\":\"view\",\"eventName\":\"Product" + - " Detail Page" + - " Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]},{\"eventType\":\"conversion\",\"eventName\":\"Product" + - " Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertDoesNotThrow( + () -> { + JSONAssert.assertEquals( + "{\"events\":[{\"eventType\":\"click\",\"eventName\":\"Product" + + " Clicked\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\",\"positions\":[7,6]},{\"eventType\":\"view\",\"eventName\":\"Product" + + " Detail Page" + + " Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]},{\"eventType\":\"conversion\",\"eventName\":\"Product" + + " Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER); + }); } @Test @@ -360,10 +299,12 @@ void pushEventsTest0() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -388,41 +329,14 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java index 0d53385e91..bc235fe93f 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java @@ -2,14 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import com.algolia.JSON; -import com.algolia.Pair; import com.algolia.api.PersonalizationClient; import com.algolia.model.personalization.*; import com.algolia.utils.echo.*; -import com.google.gson.reflect.TypeToken; import java.util.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -20,7 +16,6 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class PersonalizationClientTests { - private PersonalizationClient client; @BeforeAll @@ -33,10 +28,12 @@ void init() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -54,34 +51,15 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -89,10 +67,12 @@ void delTest1() { void deleteUserProfileTest0() { String userToken0 = "UserToken"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteUserProfile(userToken0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.deleteUserProfile(userToken0); + }); assertEquals(req.getPath(), "/1/profiles/UserToken"); assertEquals(req.getMethod(), "DELETE"); @@ -103,10 +83,12 @@ void deleteUserProfileTest0() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -124,43 +106,27 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @DisplayName("get getPersonalizationStrategy") void getPersonalizationStrategyTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getPersonalizationStrategy(); - } - ); + + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getPersonalizationStrategy(); + }); assertEquals(req.getPath(), "/1/strategies/personalization"); assertEquals(req.getMethod(), "GET"); @@ -171,10 +137,12 @@ void getPersonalizationStrategyTest0() { void getUserTokenProfileTest0() { String userToken0 = "UserToken"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUserTokenProfile(userToken0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getUserTokenProfile(userToken0); + }); assertEquals(req.getPath(), "/1/profiles/personalization/UserToken"); assertEquals(req.getMethod(), "GET"); @@ -185,10 +153,12 @@ void getUserTokenProfileTest0() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -213,42 +183,15 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -256,10 +199,12 @@ void postTest1() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -284,48 +229,23 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @DisplayName("set setPersonalizationStrategy") void setPersonalizationStrategyTest0() { - PersonalizationStrategyParams personalizationStrategyParams0 = new PersonalizationStrategyParams(); + + PersonalizationStrategyParams personalizationStrategyParams0 = + new PersonalizationStrategyParams(); { List eventScoring1 = new ArrayList<>(); { @@ -362,27 +282,25 @@ void setPersonalizationStrategyTest0() { int personalizationImpact1 = 42; - personalizationStrategyParams0.setPersonalizationImpact( - personalizationImpact1 - ); + personalizationStrategyParams0.setPersonalizationImpact(personalizationImpact1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setPersonalizationStrategy( - personalizationStrategyParams0 - ); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.setPersonalizationStrategy(personalizationStrategyParams0); + }); assertEquals(req.getPath(), "/1/strategies/personalization"); assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertDoesNotThrow( + () -> { + JSONAssert.assertEquals( + "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}", + req.getBody(), + JSONCompareMode.STRICT_ORDER); + }); } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java index a0fd0c2093..540ad6ceda 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java @@ -2,14 +2,10 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import com.algolia.JSON; -import com.algolia.Pair; import com.algolia.api.QuerySuggestionsClient; import com.algolia.model.querySuggestions.*; import com.algolia.utils.echo.*; -import com.google.gson.reflect.TypeToken; import java.util.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -20,7 +16,6 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class QuerySuggestionsClientTests { - private QuerySuggestionsClient client; @BeforeAll @@ -31,7 +26,9 @@ void init() { @Test @DisplayName("createConfig") void createConfigTest0() { - QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = new QuerySuggestionsIndexWithIndexParam(); + + QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = + new QuerySuggestionsIndexWithIndexParam(); { String indexName1 = "theIndexName"; @@ -101,21 +98,23 @@ void createConfigTest0() { querySuggestionsIndexWithIndexParam0.setExclude(exclude1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.createConfig(querySuggestionsIndexWithIndexParam0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.createConfig(querySuggestionsIndexWithIndexParam0); + }); assertEquals(req.getPath(), "/1/configs"); assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertDoesNotThrow( + () -> { + JSONAssert.assertEquals( + "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER); + }); } @Test @@ -123,10 +122,12 @@ void createConfigTest0() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -144,34 +145,15 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.del(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -179,10 +161,12 @@ void delTest1() { void deleteConfigTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteConfig(indexName0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.deleteConfig(indexName0); + }); assertEquals(req.getPath(), "/1/configs/theIndexName"); assertEquals(req.getMethod(), "DELETE"); @@ -193,10 +177,12 @@ void deleteConfigTest0() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -214,43 +200,27 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.get(path0, parameters0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @DisplayName("getAllConfigs") void getAllConfigsTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAllConfigs(); - } - ); + + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getAllConfigs(); + }); assertEquals(req.getPath(), "/1/configs"); assertEquals(req.getMethod(), "GET"); @@ -261,10 +231,12 @@ void getAllConfigsTest0() { void getConfigTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConfig(indexName0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getConfig(indexName0); + }); assertEquals(req.getPath(), "/1/configs/theIndexName"); assertEquals(req.getMethod(), "GET"); @@ -275,10 +247,12 @@ void getConfigTest0() { void getConfigStatusTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConfigStatus(indexName0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getConfigStatus(indexName0); + }); assertEquals(req.getPath(), "/1/configs/theIndexName/status"); assertEquals(req.getMethod(), "GET"); @@ -289,10 +263,12 @@ void getConfigStatusTest0() { void getLogFileTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogFile(indexName0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.getLogFile(indexName0); + }); assertEquals(req.getPath(), "/1/logs/theIndexName"); assertEquals(req.getMethod(), "GET"); @@ -303,10 +279,12 @@ void getLogFileTest0() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -331,42 +309,15 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.post(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -374,10 +325,12 @@ void postTest1() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0); + }); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -402,42 +355,15 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.put(path0, parameters0, body0); + }); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } } @Test @@ -511,20 +437,22 @@ void updateConfigTest0() { querySuggestionsIndexParam0.setExclude(exclude1); } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.updateConfig(indexName0, querySuggestionsIndexParam0); - } - ); + EchoResponseInterface req = + (EchoResponseInterface) + assertDoesNotThrow( + () -> { + return client.updateConfig(indexName0, querySuggestionsIndexParam0); + }); assertEquals(req.getPath(), "/1/configs/theIndexName"); assertEquals(req.getMethod(), "PUT"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertDoesNotThrow( + () -> { + JSONAssert.assertEquals( + "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER); + }); } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java index bbc86aeda7..d3f05a9814 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java @@ -1,834 +1,1207 @@ package com.algolia.methods.requests; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import com.algolia.JSON; -import com.algolia.Pair; -import com.algolia.api.RecommendClient; -import com.algolia.model.recommend.*; -import com.algolia.utils.echo.*; -import com.google.gson.reflect.TypeToken; import java.util.*; -import org.junit.jupiter.api.BeforeAll; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.BeforeAll; +import com.google.gson.reflect.TypeToken; + +import com.algolia.JSON; +import com.algolia.Pair; +import com.algolia.model.recommend.*; +import com.algolia.api.RecommendClient; +import com.algolia.utils.echo.*; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class RecommendClientTests { + private RecommendClient client; - private RecommendClient client; + @BeforeAll + void init() { + client = new RecommendClient("appId", "apiKey", new EchoRequester()); + } - @BeforeAll - void init() { - client = new RecommendClient("appId", "apiKey", new EchoRequester()); - } + @Test + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; - @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - } - ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); - } - @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - parameters0.put("query", query1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); + + } - } + @Test + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; + + + - @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - } - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - parameters0.put("query", query1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName( - "get recommendations for recommend model with minimal parameters" - ) - void getRecommendationsTest0() { - GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); - { - List requests1 = new ArrayList<>(); - { - RecommendationRequest requests_02 = new RecommendationRequest(); - { - String indexName3 = "indexName"; - - requests_02.setIndexName(indexName3); - String objectID3 = "objectID"; - - requests_02.setObjectID(objectID3); - - RecommendationModels model3 = RecommendationModels.fromValue( - "related-products" - ); - - requests_02.setModel(model3); - - int threshold3 = 42; - - requests_02.setThreshold(threshold3); - } - requests1.add( - RecommendationsRequest.ofRecommendationRequest(requests_02) - ); - } - getRecommendationsParams0.setRequests(requests1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get recommendations for recommend model with all parameters") - void getRecommendationsTest1() { - GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); - { - List requests1 = new ArrayList<>(); - { - RecommendationRequest requests_02 = new RecommendationRequest(); - { - String indexName3 = "indexName"; - - requests_02.setIndexName(indexName3); - String objectID3 = "objectID"; - - requests_02.setObjectID(objectID3); - - RecommendationModels model3 = RecommendationModels.fromValue( - "related-products" - ); - - requests_02.setModel(model3); - - int threshold3 = 42; - - requests_02.setThreshold(threshold3); - - int maxRecommendations3 = 10; - - requests_02.setMaxRecommendations(maxRecommendations3); - - SearchParamsObject queryParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; - - queryParameters3.setQuery(query4); - - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "query"; - - facetFilters4.add(facetFilters_05); - } - queryParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_02.setQueryParameters(queryParameters3); - - SearchParamsObject fallbackParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; - - fallbackParameters3.setQuery(query4); - - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "fallback"; - - facetFilters4.add(facetFilters_05); - } - fallbackParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_02.setFallbackParameters(fallbackParameters3); - } - requests1.add( - RecommendationsRequest.ofRecommendationRequest(requests_02) - ); - } - getRecommendationsParams0.setRequests(requests1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get recommendations for trending model with minimal parameters") - void getRecommendationsTest2() { - GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); - { - List requests1 = new ArrayList<>(); - { - TrendingRequest requests_02 = new TrendingRequest(); - { - String indexName3 = "indexName"; - - requests_02.setIndexName(indexName3); - - TrendingModels model3 = TrendingModels.fromValue("trending-items"); - - requests_02.setModel(model3); - - int threshold3 = 42; - - requests_02.setThreshold(threshold3); - } - requests1.add(RecommendationsRequest.ofTrendingRequest(requests_02)); - } - getRecommendationsParams0.setRequests(requests1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get recommendations for trending model with all parameters") - void getRecommendationsTest3() { - GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); - { - List requests1 = new ArrayList<>(); - { - TrendingRequest requests_02 = new TrendingRequest(); - { - String indexName3 = "indexName"; - - requests_02.setIndexName(indexName3); - - TrendingModels model3 = TrendingModels.fromValue("trending-items"); - - requests_02.setModel(model3); - - int threshold3 = 42; - - requests_02.setThreshold(threshold3); - - int maxRecommendations3 = 10; - - requests_02.setMaxRecommendations(maxRecommendations3); - String facetName3 = "myFacetName"; - - requests_02.setFacetName(facetName3); - String facetValue3 = "myFacetValue"; - - requests_02.setFacetValue(facetValue3); - - SearchParamsObject queryParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; - - queryParameters3.setQuery(query4); - - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "query"; - - facetFilters4.add(facetFilters_05); - } - queryParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_02.setQueryParameters(queryParameters3); - - SearchParamsObject fallbackParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; - - fallbackParameters3.setQuery(query4); - - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "fallback"; - - facetFilters4.add(facetFilters_05); - } - fallbackParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_02.setFallbackParameters(fallbackParameters3); - } - requests1.add(RecommendationsRequest.ofTrendingRequest(requests_02)); - } - getRecommendationsParams0.setRequests(requests1); +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0,parameters0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); + + } + @Test + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42,\"maxRecommendations\":10,\"facetName\":\"myFacetName\",\"facetValue\":\"myFacetValue\",\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get multiple recommendations with minimal parameters") - void getRecommendationsTest4() { - GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); - { - List requests1 = new ArrayList<>(); - { - RecommendationRequest requests_02 = new RecommendationRequest(); - { - String indexName3 = "indexName1"; - - requests_02.setIndexName(indexName3); - String objectID3 = "objectID1"; - - requests_02.setObjectID(objectID3); - - RecommendationModels model3 = RecommendationModels.fromValue( - "related-products" - ); - - requests_02.setModel(model3); - - int threshold3 = 21; - - requests_02.setThreshold(threshold3); - } - requests1.add( - RecommendationsRequest.ofRecommendationRequest(requests_02) - ); - - RecommendationRequest requests_12 = new RecommendationRequest(); - { - String indexName3 = "indexName2"; - - requests_12.setIndexName(indexName3); - String objectID3 = "objectID2"; - - requests_12.setObjectID(objectID3); - - RecommendationModels model3 = RecommendationModels.fromValue( - "related-products" - ); - - requests_12.setModel(model3); - - int threshold3 = 21; - - requests_12.setThreshold(threshold3); - } - requests1.add( - RecommendationsRequest.ofRecommendationRequest(requests_12) - ); - } - getRecommendationsParams0.setRequests(requests1); } + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - } - ); - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("get multiple recommendations with all parameters") - void getRecommendationsTest5() { - GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); - { - List requests1 = new ArrayList<>(); - { - RecommendationRequest requests_02 = new RecommendationRequest(); - { - String indexName3 = "indexName1"; - requests_02.setIndexName(indexName3); - String objectID3 = "objectID1"; - requests_02.setObjectID(objectID3); - RecommendationModels model3 = RecommendationModels.fromValue( - "related-products" - ); - requests_02.setModel(model3); - int threshold3 = 21; - requests_02.setThreshold(threshold3); - int maxRecommendations3 = 10; - requests_02.setMaxRecommendations(maxRecommendations3); - SearchParamsObject queryParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; - - queryParameters3.setQuery(query4); - - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "query1"; - - facetFilters4.add(facetFilters_05); - } - queryParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_02.setQueryParameters(queryParameters3); - - SearchParamsObject fallbackParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; - - fallbackParameters3.setQuery(query4); - - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "fallback1"; - - facetFilters4.add(facetFilters_05); - } - fallbackParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_02.setFallbackParameters(fallbackParameters3); - } - requests1.add( - RecommendationsRequest.ofRecommendationRequest(requests_02) - ); - - RecommendationRequest requests_12 = new RecommendationRequest(); - { - String indexName3 = "indexName2"; - - requests_12.setIndexName(indexName3); - String objectID3 = "objectID2"; - - requests_12.setObjectID(objectID3); - - RecommendationModels model3 = RecommendationModels.fromValue( - "related-products" - ); - - requests_12.setModel(model3); - - int threshold3 = 21; - - requests_12.setThreshold(threshold3); - - int maxRecommendations3 = 10; - - requests_12.setMaxRecommendations(maxRecommendations3); - - SearchParamsObject queryParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; - queryParameters3.setQuery(query4); - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "query2"; - facetFilters4.add(facetFilters_05); - } - queryParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_12.setQueryParameters(queryParameters3); - SearchParamsObject fallbackParameters3 = new SearchParamsObject(); - { - String query4 = "myQuery"; - fallbackParameters3.setQuery(query4); - List facetFilters4 = new ArrayList<>(); - { - String facetFilters_05 = "fallback2"; +parameters0.put("query", query1); + } - facetFilters4.add(facetFilters_05); - } - fallbackParameters3.setFacetFilters( - FacetFilters.ofListString(facetFilters4) - ); - } - requests_12.setFallbackParameters(fallbackParameters3); - } - requests1.add( - RecommendationsRequest.ofRecommendationRequest(requests_12) - ); - } - getRecommendationsParams0.setRequests(requests1); - } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0,parameters0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "GET"); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query1\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback1\"]}},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query2\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback2\"]}}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get frequently bought together recommendations") - void getRecommendationsTest6() { - GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); - { - List requests1 = new ArrayList<>(); - { - RecommendationRequest requests_02 = new RecommendationRequest(); - { - String indexName3 = "indexName1"; - - requests_02.setIndexName(indexName3); - String objectID3 = "objectID1"; - - requests_02.setObjectID(objectID3); - - RecommendationModels model3 = RecommendationModels.fromValue( - "bought-together" - ); - - requests_02.setModel(model3); - - int threshold3 = 42; - - requests_02.setThreshold(threshold3); - } - requests1.add( - RecommendationsRequest.ofRecommendationRequest(requests_02) - ); - } - getRecommendationsParams0.setRequests(requests1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"bought-together\",\"threshold\":42}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { - String path0 = "/test/minimal"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - } - ); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); - } - - @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { - String path0 = "/test/all"; - - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - - parameters0.put("query", query1); } + @Test + @DisplayName("get recommendations for recommend model with minimal parameters") + void getRecommendationsTest0() { + + + + + + + +GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); +{ + + - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; - body0.put("body", body1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); +List< +> + requests1 = new ArrayList<>(); { + + + + + + +RecommendationRequest requests_02 = new RecommendationRequest(); +{ String indexName3 = "indexName"; + + + + + + +requests_02.setIndexName(indexName3); +String objectID3 = "objectID"; + + + + + + +requests_02.setObjectID(objectID3); + + + + + +RecommendationModels model3 = RecommendationModels.fromValue("related-products"); + +requests_02.setModel(model3); + +int threshold3 = 42; + + + + + +requests_02.setThreshold(threshold3); + }requests1.add(.of(requests_02)); } +getRecommendationsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + } - } + @Test + @DisplayName("get recommendations for recommend model with all parameters") + void getRecommendationsTest1() { + + + + + + + +GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); +{ + + + + + +List< +> + requests1 = new ArrayList<>(); { + + + + + + +RecommendationRequest requests_02 = new RecommendationRequest(); +{ String indexName3 = "indexName"; + + + + + + +requests_02.setIndexName(indexName3); +String objectID3 = "objectID"; + + + + + + +requests_02.setObjectID(objectID3); + - @Test - @DisplayName("allow put method for a custom path with minimal parameters") - void putTest0() { - String path0 = "/test/minimal"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - } - ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "PUT"); - } - @Test - @DisplayName("allow put method for a custom path with all parameters") - void putTest1() { - String path0 = "/test/all"; +RecommendationModels model3 = RecommendationModels.fromValue("related-products"); - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; +requests_02.setModel(model3); + +int threshold3 = 42; + + + + + +requests_02.setThreshold(threshold3); + +int maxRecommendations3 = 10; + + + + + +requests_02.setMaxRecommendations(maxRecommendations3); + + + + + + + +SearchParamsObject queryParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +queryParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query"; + + + + + + +facetFilters4.add(facetFilters_05); } +queryParameters3.setFacetFilters(.of(facetFilters4)); + }requests_02.setQueryParameters(queryParameters3); + + + + + + + +SearchParamsObject fallbackParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +fallbackParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback"; + + + + + + +facetFilters4.add(facetFilters_05); } +fallbackParameters3.setFacetFilters(.of(facetFilters4)); + }requests_02.setFallbackParameters(fallbackParameters3); + }requests1.add(.of(requests_02)); } +getRecommendationsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); - parameters0.put("query", query1); } + @Test + @DisplayName("get recommendations for trending model with minimal parameters") + void getRecommendationsTest2() { + + + + + + + +GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); +{ + + + + + +List< +> + requests1 = new ArrayList<>(); { + + + + + + +TrendingRequest requests_02 = new TrendingRequest(); +{ String indexName3 = "indexName"; + + + + + + +requests_02.setIndexName(indexName3); + + + + + +TrendingModels model3 = TrendingModels.fromValue("trending-items"); + +requests_02.setModel(model3); + +int threshold3 = 42; + - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; - body0.put("body", body1); + + +requests_02.setThreshold(threshold3); + }requests1.add(.of(requests_02)); } +getRecommendationsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + } + @Test + @DisplayName("get recommendations for trending model with all parameters") + void getRecommendationsTest3() { + + + + + + + +GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); +{ + + + + + +List< +> + requests1 = new ArrayList<>(); { + + + + + + +TrendingRequest requests_02 = new TrendingRequest(); +{ String indexName3 = "indexName"; + + + + + + +requests_02.setIndexName(indexName3); + + + + + +TrendingModels model3 = TrendingModels.fromValue("trending-items"); + +requests_02.setModel(model3); + +int threshold3 = 42; + + + + + +requests_02.setThreshold(threshold3); + +int maxRecommendations3 = 10; + + + + + +requests_02.setMaxRecommendations(maxRecommendations3); +String facetName3 = "myFacetName"; + + + + + + +requests_02.setFacetName(facetName3); +String facetValue3 = "myFacetValue"; + + + + + + +requests_02.setFacetValue(facetValue3); + + + + + + + +SearchParamsObject queryParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +queryParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query"; + + + + + + +facetFilters4.add(facetFilters_05); } +queryParameters3.setFacetFilters(.of(facetFilters4)); + }requests_02.setQueryParameters(queryParameters3); + + + + + + + +SearchParamsObject fallbackParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +fallbackParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback"; + + + + + + +facetFilters4.add(facetFilters_05); } +fallbackParameters3.setFacetFilters(.of(facetFilters4)); + }requests_02.setFallbackParameters(fallbackParameters3); + }requests1.add(.of(requests_02)); } +getRecommendationsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42,\"maxRecommendations\":10,\"facetName\":\"myFacetName\",\"facetValue\":\"myFacetValue\",\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("get multiple recommendations with minimal parameters") + void getRecommendationsTest4() { + + + + + + + +GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); +{ + + + + + +List< +> + requests1 = new ArrayList<>(); { + + + + + + +RecommendationRequest requests_02 = new RecommendationRequest(); +{ String indexName3 = "indexName1"; + + + + + + +requests_02.setIndexName(indexName3); +String objectID3 = "objectID1"; + + + + + + +requests_02.setObjectID(objectID3); + + + + + +RecommendationModels model3 = RecommendationModels.fromValue("related-products"); + +requests_02.setModel(model3); + +int threshold3 = 21; + + + + + +requests_02.setThreshold(threshold3); + }requests1.add(.of(requests_02)); + + + + + + +RecommendationRequest requests_12 = new RecommendationRequest(); +{ String indexName3 = "indexName2"; + + + + + + +requests_12.setIndexName(indexName3); +String objectID3 = "objectID2"; + + + + + + +requests_12.setObjectID(objectID3); + + + + + +RecommendationModels model3 = RecommendationModels.fromValue("related-products"); + +requests_12.setModel(model3); + +int threshold3 = 21; + + + + + +requests_12.setThreshold(threshold3); + }requests1.add(.of(requests_12)); } +getRecommendationsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("get multiple recommendations with all parameters") + void getRecommendationsTest5() { + + + + + + + +GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); +{ + + + + + +List< +> + requests1 = new ArrayList<>(); { + + + + + + +RecommendationRequest requests_02 = new RecommendationRequest(); +{ String indexName3 = "indexName1"; + + + + + + +requests_02.setIndexName(indexName3); +String objectID3 = "objectID1"; + + + + + + +requests_02.setObjectID(objectID3); + + + + + +RecommendationModels model3 = RecommendationModels.fromValue("related-products"); + +requests_02.setModel(model3); + +int threshold3 = 21; + + + + + +requests_02.setThreshold(threshold3); + +int maxRecommendations3 = 10; + + + + + +requests_02.setMaxRecommendations(maxRecommendations3); + + + + + + + +SearchParamsObject queryParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +queryParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query1"; + + + + + + +facetFilters4.add(facetFilters_05); } +queryParameters3.setFacetFilters(.of(facetFilters4)); + }requests_02.setQueryParameters(queryParameters3); + + + + + + + +SearchParamsObject fallbackParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +fallbackParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback1"; + + + + + + +facetFilters4.add(facetFilters_05); } +fallbackParameters3.setFacetFilters(.of(facetFilters4)); + }requests_02.setFallbackParameters(fallbackParameters3); + }requests1.add(.of(requests_02)); + + + + + + +RecommendationRequest requests_12 = new RecommendationRequest(); +{ String indexName3 = "indexName2"; + + + + + + +requests_12.setIndexName(indexName3); +String objectID3 = "objectID2"; + + + + + + +requests_12.setObjectID(objectID3); + + + + + +RecommendationModels model3 = RecommendationModels.fromValue("related-products"); + +requests_12.setModel(model3); + +int threshold3 = 21; + + + + + +requests_12.setThreshold(threshold3); + +int maxRecommendations3 = 10; + + + + + +requests_12.setMaxRecommendations(maxRecommendations3); + + + + + + + +SearchParamsObject queryParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +queryParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query2"; + + + + + + +facetFilters4.add(facetFilters_05); } +queryParameters3.setFacetFilters(.of(facetFilters4)); + }requests_12.setQueryParameters(queryParameters3); + + + + + + + +SearchParamsObject fallbackParameters3 = new SearchParamsObject(); +{ String query4 = "myQuery"; + + + + + + +fallbackParameters3.setQuery(query4); + + + + + + +List + facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback2"; + + + + + + +facetFilters4.add(facetFilters_05); } +fallbackParameters3.setFacetFilters(.of(facetFilters4)); + }requests_12.setFallbackParameters(fallbackParameters3); + }requests1.add(.of(requests_12)); } +getRecommendationsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query1\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback1\"]}},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query2\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback2\"]}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("get frequently bought together recommendations") + void getRecommendationsTest6() { + + + + + + + +GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); +{ + + + + + +List< +> + requests1 = new ArrayList<>(); { + + + + + + +RecommendationRequest requests_02 = new RecommendationRequest(); +{ String indexName3 = "indexName1"; + + + + + + +requests_02.setIndexName(indexName3); +String objectID3 = "objectID1"; + + + + + + +requests_02.setObjectID(objectID3); + + + + + +RecommendationModels model3 = RecommendationModels.fromValue("bought-together"); + +requests_02.setModel(model3); + +int threshold3 = 42; + + + + + +requests_02.setThreshold(threshold3); + }requests1.add(.of(requests_02)); } +getRecommendationsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"bought-together\",\"threshold\":42}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + + + + + +Map body0 = new HashMap<>(); +{ String body1 = "parameters"; + + + + + + +body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0,parameters0,body0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + + + } + @Test + @DisplayName("allow put method for a custom path with all parameters") + void putTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + + + + + +Map body0 = new HashMap<>(); +{ String body1 = "parameters"; + + + + + + +body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0,parameters0,body0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); } - } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index dafbcceb5e..c311f4757e 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -1,2596 +1,3654 @@ package com.algolia.methods.requests; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import com.algolia.JSON; -import com.algolia.Pair; -import com.algolia.api.SearchClient; -import com.algolia.model.search.*; -import com.algolia.utils.echo.*; -import com.google.gson.reflect.TypeToken; import java.util.*; -import org.junit.jupiter.api.BeforeAll; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.BeforeAll; +import com.google.gson.reflect.TypeToken; + +import com.algolia.JSON; +import com.algolia.Pair; +import com.algolia.model.search.*; +import com.algolia.api.SearchClient; +import com.algolia.utils.echo.*; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class SearchClientTests { + private SearchClient client; - private SearchClient client; + @BeforeAll + void init() { + client = new SearchClient("appId", "apiKey", new EchoRequester()); + } - @BeforeAll - void init() { - client = new SearchClient("appId", "apiKey", new EchoRequester()); - } + @Test + @DisplayName("addApiKey") + void addApiKeyTest0() { + - @Test - @DisplayName("addApiKey") - void addApiKeyTest0() { - ApiKey apiKey0 = new ApiKey(); - { - List acl1 = new ArrayList<>(); - { - Acl acl_02 = Acl.fromValue("search"); - acl1.add(acl_02); - Acl acl_12 = Acl.fromValue("addObject"); - acl1.add(acl_12); - } - apiKey0.setAcl(acl1); - String description1 = "my new api key"; - apiKey0.setDescription(description1); - int validity1 = 300; +ApiKey apiKey0 = new ApiKey(); +{ - apiKey0.setValidity(validity1); - int maxQueriesPerIPPerHour1 = 100; - apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); - int maxHitsPerQuery1 = 20; - apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); - } +List + acl1 = new ArrayList<>(); { + + + + +Acl acl_02 = Acl.fromValue("search"); + +acl1.add(acl_02); + + + + +Acl acl_12 = Acl.fromValue("addObject"); + +acl1.add(acl_12); } +apiKey0.setAcl(acl1); +String description1 = "my new api key"; + + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addApiKey(apiKey0); - } - ); - assertEquals(req.getPath(), "/1/keys"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api" + - " key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("addOrUpdateObject") - void addOrUpdateObjectTest0() { - String indexName0 = "indexName"; +apiKey0.setDescription(description1); - String objectID0 = "uniqueID"; +int validity1 = 300; - Map body0 = new HashMap<>(); - { - String key1 = "value"; - body0.put("key", key1); + + + +apiKey0.setValidity(validity1); + +int maxQueriesPerIPPerHour1 = 100; + + + + + +apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); + +int maxHitsPerQuery1 = 20; + + + + + +apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.addApiKey(apiKey0); + }); + + assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + } + @Test + @DisplayName("addOrUpdateObject") + void addOrUpdateObjectTest0() { + String indexName0 = "indexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addOrUpdateObject(indexName0, objectID0, body0); - } - ); - assertEquals(req.getPath(), "/1/indexes/indexName/uniqueID"); - assertEquals(req.getMethod(), "PUT"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"key\":\"value\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("appendSource") - void appendSourceTest0() { - Source source0 = new Source(); - { - String source1 = "theSource"; - source0.setSource(source1); - String description1 = "theDescription"; - source0.setDescription(description1); - } +String objectID0 = "uniqueID"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.appendSource(source0); - } - ); - assertEquals(req.getPath(), "/1/security/sources/append"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"source\":\"theSource\",\"description\":\"theDescription\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("assignUserId") - void assignUserIdTest0() { - String xAlgoliaUserID0 = "userID"; - AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); - { - String cluster1 = "theCluster"; - - assignUserIdParams0.setCluster(cluster1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.assignUserId(xAlgoliaUserID0, assignUserIdParams0); - } - ); - - assertEquals(req.getPath(), "/1/clusters/mapping"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"cluster\":\"theCluster\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"X-Algolia-User-ID\":\"userID\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("batch") - void batchTest0() { - String indexName0 = "theIndexName"; - - BatchWriteParams batchWriteParams0 = new BatchWriteParams(); - { - List requests1 = new ArrayList<>(); - { - BatchOperation requests_02 = new BatchOperation(); - { - Action action3 = Action.fromValue("delete"); - - requests_02.setAction(action3); - - Map body3 = new HashMap<>(); - { - String key4 = "value"; - - body3.put("key", key4); - } - requests_02.setBody(body3); - } - requests1.add(requests_02); - } - batchWriteParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batch(indexName0, batchWriteParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("batchAssignUserIds") - void batchAssignUserIdsTest0() { - String xAlgoliaUserID0 = "userID"; - - BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); - { - String cluster1 = "theCluster"; - - batchAssignUserIdsParams0.setCluster(cluster1); - - List users1 = new ArrayList<>(); - { - String users_02 = "user1"; - - users1.add(users_02); - String users_12 = "user2"; - - users1.add(users_12); - } - batchAssignUserIdsParams0.setUsers(users1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchAssignUserIds( - xAlgoliaUserID0, - batchAssignUserIdsParams0 - ); - } - ); - - assertEquals(req.getPath(), "/1/clusters/mapping/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"X-Algolia-User-ID\":\"userID\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("get batchDictionaryEntries results with minimal parameters") - void batchDictionaryEntriesTest0() { - DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); - { - List requests1 = new ArrayList<>(); - { - BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); - { - DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); - - requests_02.setAction(action3); - - DictionaryEntry body3 = new DictionaryEntry(); - { - String objectID4 = "1"; - - body3.setObjectID(objectID4); - String language4 = "en"; - - body3.setLanguage(language4); - } - requests_02.setBody(body3); - } - requests1.add(requests_02); - BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); - { - DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); - requests_12.setAction(action3); - DictionaryEntry body3 = new DictionaryEntry(); - { - String objectID4 = "2"; - body3.setObjectID(objectID4); - String language4 = "fr"; - body3.setLanguage(language4); - } - requests_12.setBody(body3); - } - requests1.add(requests_12); - } - batchDictionaryEntriesParams0.setRequests(requests1); + + + +Map body0 = new HashMap<>(); +{ String key1 = "value"; + + + + + + +body0.put("key", key1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.addOrUpdateObject(indexName0,objectID0,body0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/uniqueID"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"key\":\"value\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + } + @Test + @DisplayName("appendSource") + void appendSourceTest0() { + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchDictionaryEntries( - dictionaryName0, - batchDictionaryEntriesParams0 - ); - } - ); - assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\"}}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("get batchDictionaryEntries results with all parameters") - void batchDictionaryEntriesTest1() { - DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); - { - boolean clearExistingDictionaryEntries1 = false; - batchDictionaryEntriesParams0.setClearExistingDictionaryEntries( - clearExistingDictionaryEntries1 - ); +Source source0 = new Source(); +{ String source1 = "theSource"; - List requests1 = new ArrayList<>(); - { - BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); - { - DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); - requests_02.setAction(action3); - DictionaryEntry body3 = new DictionaryEntry(); - { - String objectID4 = "1"; - body3.setObjectID(objectID4); - String language4 = "en"; - body3.setLanguage(language4); - String word4 = "fancy"; - body3.setWord(word4); +source0.setSource(source1); +String description1 = "theDescription"; - List words4 = new ArrayList<>(); - { - String words_05 = "believe"; - words4.add(words_05); - String words_15 = "algolia"; - words4.add(words_15); - } - body3.setWords(words4); - List decomposition4 = new ArrayList<>(); - { - String decomposition_05 = "trust"; - decomposition4.add(decomposition_05); - String decomposition_15 = "algolia"; - decomposition4.add(decomposition_15); - } - body3.setDecomposition(decomposition4); +source0.setDescription(description1); + } - DictionaryEntryState state4 = DictionaryEntryState.fromValue( - "enabled" - ); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.appendSource(source0); + }); - body3.setState(state4); - } - requests_02.setBody(body3); - } - requests1.add(requests_02); + assertEquals(req.getPath(), "/1/security/sources/append"); + assertEquals(req.getMethod(), "POST"); - BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); - { - DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"source\":\"theSource\",\"description\":\"theDescription\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); - requests_12.setAction(action3); + } + @Test + @DisplayName("assignUserId") + void assignUserIdTest0() { + String xAlgoliaUserID0 = "userID"; - DictionaryEntry body3 = new DictionaryEntry(); - { - String objectID4 = "2"; - body3.setObjectID(objectID4); - String language4 = "fr"; - body3.setLanguage(language4); - String word4 = "humility"; - body3.setWord(word4); - List words4 = new ArrayList<>(); - { - String words_05 = "candor"; - words4.add(words_05); - String words_15 = "algolia"; - words4.add(words_15); - } - body3.setWords(words4); - List decomposition4 = new ArrayList<>(); - { - String decomposition_05 = "grit"; - decomposition4.add(decomposition_05); - String decomposition_15 = "algolia"; - decomposition4.add(decomposition_15); - } - body3.setDecomposition(decomposition4); - DictionaryEntryState state4 = DictionaryEntryState.fromValue( - "enabled" - ); - body3.setState(state4); - } - requests_12.setBody(body3); - } - requests1.add(requests_12); - } - batchDictionaryEntriesParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchDictionaryEntries( - dictionaryName0, - batchDictionaryEntriesParams0 - ); - } - ); - - assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"clearExistingDictionaryEntries\":false,\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\",\"word\":\"fancy\",\"words\":[\"believe\",\"algolia\"],\"decomposition\":[\"trust\",\"algolia\"],\"state\":\"enabled\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\",\"word\":\"humility\",\"words\":[\"candor\",\"algolia\"],\"decomposition\":[\"grit\",\"algolia\"],\"state\":\"enabled\"}}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("batchRules") - void batchRulesTest0() { - String indexName0 = "indexName"; - - List rule0 = new ArrayList<>(); - { - Rule rule_01 = new Rule(); - { - String objectID2 = "a-rule-id"; - - rule_01.setObjectID(objectID2); - - List conditions2 = new ArrayList<>(); - { - Condition conditions_03 = new Condition(); - { - String pattern4 = "smartphone"; - - conditions_03.setPattern(pattern4); - - Anchoring anchoring4 = Anchoring.fromValue("contains"); - - conditions_03.setAnchoring(anchoring4); - } - conditions2.add(conditions_03); - } - rule_01.setConditions(conditions2); - Consequence consequence2 = new Consequence(); - { - ConsequenceParams params3 = new ConsequenceParams(); - { - String filters4 = "category:smartphone"; +AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); +{ String cluster1 = "theCluster"; - params3.setFilters(filters4); - } - consequence2.setParams(params3); - } - rule_01.setConsequence(consequence2); - } - rule0.add(rule_01); - Rule rule_11 = new Rule(); - { - String objectID2 = "a-second-rule-id"; - rule_11.setObjectID(objectID2); - List conditions2 = new ArrayList<>(); - { - Condition conditions_03 = new Condition(); - { - String pattern4 = "apple"; - conditions_03.setPattern(pattern4); - Anchoring anchoring4 = Anchoring.fromValue("contains"); +assignUserIdParams0.setCluster(cluster1); + } - conditions_03.setAnchoring(anchoring4); - } - conditions2.add(conditions_03); - } - rule_11.setConditions(conditions2); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.assignUserId(xAlgoliaUserID0,assignUserIdParams0); + }); - Consequence consequence2 = new Consequence(); - { - ConsequenceParams params3 = new ConsequenceParams(); - { - String filters4 = "brand:apple"; + assertEquals(req.getPath(), "/1/clusters/mapping"); + assertEquals(req.getMethod(), "POST"); - params3.setFilters(filters4); - } - consequence2.setParams(params3); - } - rule_11.setConsequence(consequence2); - } - rule0.add(rule_11); - } - - boolean forwardToReplicas0 = true; - - boolean clearExistingRules0 = true; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchRules( - indexName0, - rule0, - forwardToReplicas0, - clearExistingRules0 - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "[{\"objectID\":\"a-rule-id\",\"conditions\":[{\"pattern\":\"smartphone\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"category:smartphone\"}}},{\"objectID\":\"a-second-rule-id\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}]", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\",\"clearExistingRules\":\"true\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("get browse results with minimal parameters") - void browseTest0() { - String indexName0 = "indexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.browse(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/browse"); - assertEquals(req.getMethod(), "POST"); - } - - @Test - @DisplayName("get browse results with all parameters") - void browseTest1() { - String indexName0 = "indexName"; - - BrowseRequest browseRequest0 = new BrowseRequest(); - { - String params1 = "query=foo&facetFilters=['bar']"; - - browseRequest0.setParams(params1); - String cursor1 = "cts"; - - browseRequest0.setCursor(cursor1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.browse(indexName0, browseRequest0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/browse"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("clearAllSynonyms") - void clearAllSynonymsTest0() { - String indexName0 = "indexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearAllSynonyms(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/clear"); - assertEquals(req.getMethod(), "POST"); - } - - @Test - @DisplayName("clearObjects") - void clearObjectsTest0() { - String indexName0 = "theIndexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearObjects(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/clear"); - assertEquals(req.getMethod(), "POST"); - } - - @Test - @DisplayName("clearRules") - void clearRulesTest0() { - String indexName0 = "indexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearRules(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/clear"); - assertEquals(req.getMethod(), "POST"); - } - - @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - } - ); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; - - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - - parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("deleteApiKey") - void deleteApiKeyTest0() { - String key0 = "myTestApiKey"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteApiKey(key0); - } - ); - - assertEquals(req.getPath(), "/1/keys/myTestApiKey"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("deleteBy") - void deleteByTest0() { - String indexName0 = "theIndexName"; - - SearchParamsObject searchParams0 = new SearchParamsObject(); - { - String query1 = "testQuery"; - - searchParams0.setQuery(query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteBy( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"testQuery\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("deleteIndex") - void deleteIndexTest0() { - String indexName0 = "theIndexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteIndex(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("deleteObject") - void deleteObjectTest0() { - String indexName0 = "theIndexName"; - - String objectID0 = "uniqueID"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteObject(indexName0, objectID0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("deleteRule") - void deleteRuleTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteRule(indexName0, objectID0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("deleteSource") - void deleteSourceTest0() { - String source0 = "theSource"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSource(source0); - } - ); - - assertEquals(req.getPath(), "/1/security/sources/theSource"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("deleteSynonym") - void deleteSynonymTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSynonym(indexName0, objectID0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; - - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - - parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("getApiKey") - void getApiKeyTest0() { - String key0 = "myTestApiKey"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getApiKey(key0); - } - ); - - assertEquals(req.getPath(), "/1/keys/myTestApiKey"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("get getDictionaryLanguages") - void getDictionaryLanguagesTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getDictionaryLanguages(); - } - ); - - assertEquals(req.getPath(), "/1/dictionaries/*/languages"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("get getDictionarySettings results") - void getDictionarySettingsTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getDictionarySettings(); - } - ); - - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getLogs") - void getLogsTest0() { - int offset0 = 5; - - int length0 = 10; - - String indexName0 = "theIndexName"; - - LogType type0 = LogType.fromValue("all"); - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogs(offset0, length0, indexName0, type0); - } - ); - - assertEquals(req.getPath(), "/1/logs"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("getObject") - void getObjectTest0() { - String indexName0 = "theIndexName"; - - String objectID0 = "uniqueID"; - - List attributesToRetrieve0 = new ArrayList<>(); - { - String attributesToRetrieve_01 = "attr1"; - - attributesToRetrieve0.add(attributesToRetrieve_01); - String attributesToRetrieve_11 = "attr2"; - - attributesToRetrieve0.add(attributesToRetrieve_11); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObject(indexName0, objectID0, attributesToRetrieve0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"attributesToRetrieve\":\"attr1,attr2\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("getObjects") - void getObjectsTest0() { - GetObjectsParams getObjectsParams0 = new GetObjectsParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); - { - List attributesToRetrieve3 = new ArrayList<>(); - { - String attributesToRetrieve_04 = "attr1"; - - attributesToRetrieve3.add(attributesToRetrieve_04); - String attributesToRetrieve_14 = "attr2"; - - attributesToRetrieve3.add(attributesToRetrieve_14); - } - requests_02.setAttributesToRetrieve(attributesToRetrieve3); - String objectID3 = "uniqueID"; - - requests_02.setObjectID(objectID3); - String indexName3 = "theIndexName"; - - requests_02.setIndexName(indexName3); - } - requests1.add(requests_02); - } - getObjectsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObjects(getObjectsParams0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/*/objects"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"attributesToRetrieve\":[\"attr1\",\"attr2\"],\"objectID\":\"uniqueID\",\"indexName\":\"theIndexName\"}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("getRule") - void getRuleTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRule(indexName0, objectID0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getSettings") - void getSettingsTest0() { - String indexName0 = "theIndexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSettings(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getSources") - void getSourcesTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSources(); - } - ); - - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getSynonym") - void getSynonymTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSynonym(indexName0, objectID0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getTask") - void getTaskTest0() { - String indexName0 = "theIndexName"; - - int taskID0 = 123; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTask(indexName0, taskID0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/task/123"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getTopUserIds") - void getTopUserIdsTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopUserIds(); - } - ); - - assertEquals(req.getPath(), "/1/clusters/mapping/top"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getUserId") - void getUserIdTest0() { - String userID0 = "uniqueID"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUserId(userID0); - } - ); - - assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("hasPendingMappings") - void hasPendingMappingsTest0() { - boolean getClusters0 = true; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.hasPendingMappings(getClusters0); - } - ); - - assertEquals(req.getPath(), "/1/clusters/mapping/pending"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"getClusters\":\"true\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("listApiKeys") - void listApiKeysTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listApiKeys(); - } - ); - - assertEquals(req.getPath(), "/1/keys"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("listClusters") - void listClustersTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listClusters(); - } - ); - - assertEquals(req.getPath(), "/1/clusters"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("listIndices") - void listIndicesTest0() { - int page0 = 8; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listIndices(page0); - } - ); - - assertEquals(req.getPath(), "/1/indexes"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"page\":\"8\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("listUserIds") - void listUserIdsTest0() { - int page0 = 8; - - int hitsPerPage0 = 100; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listUserIds(page0, hitsPerPage0); - } - ); - - assertEquals(req.getPath(), "/1/clusters/mapping"); - assertEquals(req.getMethod(), "GET"); - - Map expectedQuery = JSON.deserialize( - "{\"page\":\"8\",\"hitsPerPage\":\"100\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("multipleBatch") - void multipleBatchTest0() { - BatchParams batchParams0 = new BatchParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleBatchOperation requests_02 = new MultipleBatchOperation(); - { - Action action3 = Action.fromValue("addObject"); - - requests_02.setAction(action3); - - Map body3 = new HashMap<>(); - { - String key4 = "value"; - - body3.put("key", key4); - } - requests_02.setBody(body3); - String indexName3 = "theIndexName"; - - requests_02.setIndexName(indexName3); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"cluster\":\"theCluster\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - requests1.add(requests_02); - } - batchParams0.setRequests(requests1); } + @Test + @DisplayName("batch") + void batchTest0() { + String indexName0 = "theIndexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.multipleBatch(batchParams0); - } - ); - assertEquals(req.getPath(), "/1/indexes/*/batch"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("multipleQueries") - void multipleQueriesTest0() { - MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleQueries requests_02 = new MultipleQueries(); - { - String indexName3 = "theIndexName"; - requests_02.setIndexName(indexName3); - String query3 = "test"; - requests_02.setQuery(query3); - MultipleQueriesType type3 = MultipleQueriesType.fromValue("facet"); - requests_02.setType(type3); - String facet3 = "theFacet"; - requests_02.setFacet(facet3); - String params3 = "testParam"; - requests_02.setParams(params3); - } - requests1.add(requests_02); - } - multipleQueriesParams0.setRequests(requests1); - MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue( - "stopIfEnoughMatches" - ); - multipleQueriesParams0.setStrategy(strategy1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.multipleQueries(multipleQueriesParams0); - } - ); +BatchWriteParams batchWriteParams0 = new BatchWriteParams(); +{ + + + + + +List + requests1 = new ArrayList<>(); { + + + - assertEquals(req.getPath(), "/1/indexes/*/queries"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("operationIndex") - void operationIndexTest0() { - String indexName0 = "theIndexName"; +BatchOperation requests_02 = new BatchOperation(); +{ - OperationIndexParams operationIndexParams0 = new OperationIndexParams(); - { - OperationType operation1 = OperationType.fromValue("copy"); - operationIndexParams0.setOperation(operation1); - String destination1 = "dest"; - operationIndexParams0.setDestination(destination1); - List scope1 = new ArrayList<>(); - { - ScopeType scope_02 = ScopeType.fromValue("rules"); +Action action3 = Action.fromValue("delete"); - scope1.add(scope_02); +requests_02.setAction(action3); - ScopeType scope_12 = ScopeType.fromValue("settings"); - scope1.add(scope_12); - } - operationIndexParams0.setScope(scope1); + + + + + +Map body3 = new HashMap<>(); +{ String key4 = "value"; + + + + + + +body3.put("key", key4); + }requests_02.setBody(body3); + }requests1.add(requests_02); } +batchWriteParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batch(indexName0,batchWriteParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + } + @Test + @DisplayName("batchAssignUserIds") + void batchAssignUserIdsTest0() { + String xAlgoliaUserID0 = "userID"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.operationIndex(indexName0, operationIndexParams0); - } - ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("partialUpdateObject") - void partialUpdateObjectTest0() { - String indexName0 = "theIndexName"; - String objectID0 = "uniqueID"; - List> attributeOrBuiltInOperation0 = new ArrayList<>(); - { - Map attributeOrBuiltInOperation_01 = new HashMap<>(); - { - String id12 = "test"; - attributeOrBuiltInOperation_01.put( - "id1", - AttributeOrBuiltInOperation.ofString(id12) - ); - BuiltInOperation id22 = new BuiltInOperation(); - { - BuiltInOperationType operation3 = BuiltInOperationType.fromValue( - "AddUnique" - ); - id22.setOperation(operation3); - String value3 = "test2"; - id22.setValue(value3); - } - attributeOrBuiltInOperation_01.put( - "id2", - AttributeOrBuiltInOperation.ofBuiltInOperation(id22) - ); - } - attributeOrBuiltInOperation0.add(attributeOrBuiltInOperation_01); - } - - boolean createIfNotExists0 = true; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.partialUpdateObject( - indexName0, - objectID0, - attributeOrBuiltInOperation0, - createIfNotExists0 - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID/partial"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"createIfNotExists\":\"true\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { - String path0 = "/test/minimal"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - } - ); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); - } - - @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { - String path0 = "/test/all"; - - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - - parameters0.put("query", query1); - } - - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; - - body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("allow put method for a custom path with minimal parameters") - void putTest0() { - String path0 = "/test/minimal"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - } - ); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "PUT"); - } - - @Test - @DisplayName("allow put method for a custom path with all parameters") - void putTest1() { - String path0 = "/test/all"; - - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; - - parameters0.put("query", query1); - } - - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; - - body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); - } - ); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("removeUserId") - void removeUserIdTest0() { - String userID0 = "uniqueID"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.removeUserId(userID0); - } - ); - - assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("replaceSources") - void replaceSourcesTest0() { - List source0 = new ArrayList<>(); - { - Source source_01 = new Source(); - { - String source2 = "theSource"; - - source_01.setSource(source2); - String description2 = "theDescription"; - - source_01.setDescription(description2); - } - source0.add(source_01); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.replaceSources(source0); - } - ); - - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("restoreApiKey") - void restoreApiKeyTest0() { - String key0 = "myApiKey"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.restoreApiKey(key0); - } - ); - - assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); - assertEquals(req.getMethod(), "POST"); - } - - @Test - @DisplayName("saveObject") - void saveObjectTest0() { - String indexName0 = "theIndexName"; - - Map body0 = new HashMap<>(); - { - String objectID1 = "id"; - - body0.put("objectID", objectID1); - String test1 = "val"; - - body0.put("test", test1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveObject(indexName0, body0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"objectID\":\"id\",\"test\":\"val\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("saveRule") - void saveRuleTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; - - Rule rule0 = new Rule(); - { - String objectID1 = "id1"; - rule0.setObjectID(objectID1); - - List conditions1 = new ArrayList<>(); - { - Condition conditions_02 = new Condition(); - { - String pattern3 = "apple"; - conditions_02.setPattern(pattern3); - - Anchoring anchoring3 = Anchoring.fromValue("contains"); - conditions_02.setAnchoring(anchoring3); - } - conditions1.add(conditions_02); - } - rule0.setConditions(conditions1); +BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); +{ String cluster1 = "theCluster"; - Consequence consequence1 = new Consequence(); - { - ConsequenceParams params2 = new ConsequenceParams(); - { - String filters3 = "brand:apple"; - params2.setFilters(filters3); - } - consequence1.setParams(params2); - } - rule0.setConsequence(consequence1); - } - - boolean forwardToReplicas0 = true; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveRule( - indexName0, - objectID0, - rule0, - forwardToReplicas0 - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"objectID\":\"id1\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("saveSynonym") - void saveSynonymTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; - - SynonymHit synonymHit0 = new SynonymHit(); - { - String objectID1 = "id1"; - - synonymHit0.setObjectID(objectID1); - - SynonymType type1 = SynonymType.fromValue("synonym"); - - synonymHit0.setType(type1); - - List synonyms1 = new ArrayList<>(); - { - String synonyms_02 = "car"; - - synonyms1.add(synonyms_02); - String synonyms_12 = "vehicule"; - - synonyms1.add(synonyms_12); - String synonyms_22 = "auto"; - - synonyms1.add(synonyms_22); - } - synonymHit0.setSynonyms(synonyms1); - } - - boolean forwardToReplicas0 = true; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonym( - indexName0, - objectID0, - synonymHit0, - forwardToReplicas0 - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; + + + + +batchAssignUserIdsParams0.setCluster(cluster1); + + + + + + +List + users1 = new ArrayList<>(); { String users_02 = "user1"; + + + + + + +users1.add(users_02);String users_12 = "user2"; + + + + + + +users1.add(users_12); } +batchAssignUserIdsParams0.setUsers(users1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchAssignUserIds(xAlgoliaUserID0,batchAssignUserIdsParams0); + }); + + assertEquals(req.getPath(), "/1/clusters/mapping/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); } - } + @Test + @DisplayName("get batchDictionaryEntries results with minimal parameters") + void batchDictionaryEntriesTest0() { + - @Test - @DisplayName("saveSynonyms") - void saveSynonymsTest0() { - String indexName0 = "indexName"; - List synonymHit0 = new ArrayList<>(); - { - SynonymHit synonymHit_01 = new SynonymHit(); - { - String objectID2 = "id1"; - synonymHit_01.setObjectID(objectID2); - SynonymType type2 = SynonymType.fromValue("synonym"); +DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - synonymHit_01.setType(type2); - List synonyms2 = new ArrayList<>(); - { - String synonyms_03 = "car"; - synonyms2.add(synonyms_03); - String synonyms_13 = "vehicule"; - synonyms2.add(synonyms_13); - String synonyms_23 = "auto"; - synonyms2.add(synonyms_23); - } - synonymHit_01.setSynonyms(synonyms2); - } - synonymHit0.add(synonymHit_01); - SynonymHit synonymHit_11 = new SynonymHit(); - { - String objectID2 = "id2"; - synonymHit_11.setObjectID(objectID2); - SynonymType type2 = SynonymType.fromValue("onewaysynonym"); +BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); +{ - synonymHit_11.setType(type2); - String input2 = "iphone"; - synonymHit_11.setInput(input2); - List synonyms2 = new ArrayList<>(); - { - String synonyms_03 = "ephone"; - synonyms2.add(synonyms_03); - String synonyms_13 = "aphone"; - synonyms2.add(synonyms_13); - String synonyms_23 = "yphone"; +List + requests1 = new ArrayList<>(); { - synonyms2.add(synonyms_23); - } - synonymHit_11.setSynonyms(synonyms2); - } - synonymHit0.add(synonymHit_11); - } - - boolean forwardToReplicas0 = true; - - boolean replaceExistingSynonyms0 = false; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonyms( - indexName0, - synonymHit0, - forwardToReplicas0, - replaceExistingSynonyms0 - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - - @Test - @DisplayName("search with minimal parameters") - void searchTest0() { - String indexName0 = "indexName"; - - SearchParamsObject searchParams0 = new SearchParamsObject(); - { - String query1 = "myQuery"; - - searchParams0.setQuery(query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/query"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"myQuery\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("search with facetFilters") - void searchTest1() { - String indexName0 = "indexName"; - - SearchParamsObject searchParams0 = new SearchParamsObject(); - { - String query1 = "myQuery"; - - searchParams0.setQuery(query1); - - List facetFilters1 = new ArrayList<>(); - { - String facetFilters_02 = "tags:algolia"; - - facetFilters1.add(facetFilters_02); - } - searchParams0.setFacetFilters(FacetFilters.ofListString(facetFilters1)); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/query"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get searchDictionaryEntries results with minimal parameters") - void searchDictionaryEntriesTest0() { - DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); - { - String query1 = "foo"; - searchDictionaryEntriesParams0.setQuery(query1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchDictionaryEntries( - dictionaryName0, - searchDictionaryEntriesParams0 - ); - } - ); - - assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"foo\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get searchDictionaryEntries results with all parameters") - void searchDictionaryEntriesTest1() { - DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); - { - String query1 = "foo"; - - searchDictionaryEntriesParams0.setQuery(query1); - - int page1 = 4; - searchDictionaryEntriesParams0.setPage(page1); - int hitsPerPage1 = 2; - - searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); - String language1 = "fr"; - - searchDictionaryEntriesParams0.setLanguage(language1); - } +BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); +{ - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchDictionaryEntries( - dictionaryName0, - searchDictionaryEntriesParams0 - ); - } - ); - assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"foo\",\"page\":4,\"hitsPerPage\":2,\"language\":\"fr\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get searchForFacetValues results with minimal parameters") - void searchForFacetValuesTest0() { - String indexName0 = "indexName"; - - String facetName0 = "facetName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchForFacetValues(indexName0, facetName0); - } - ); - - assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); - assertEquals(req.getMethod(), "POST"); - } - @Test - @DisplayName("get searchForFacetValues results with all parameters") - void searchForFacetValuesTest1() { - String indexName0 = "indexName"; - String facetName0 = "facetName"; +DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); - SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); - { - String params1 = "query=foo&facetFilters=['bar']"; +requests_02.setAction(action3); - searchForFacetValuesRequest0.setParams(params1); - String facetQuery1 = "foo"; - searchForFacetValuesRequest0.setFacetQuery(facetQuery1); - int maxFacetHits1 = 42; - searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchForFacetValues( - indexName0, - facetName0, - searchForFacetValuesRequest0 - ); - } - ); - assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("searchRules") - void searchRulesTest0() { - String indexName0 = "indexName"; +DictionaryEntry body3 = new DictionaryEntry(); +{ String objectID4 = "1"; - SearchRulesParams searchRulesParams0 = new SearchRulesParams(); - { - String query1 = "something"; - searchRulesParams0.setQuery(query1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchRules(indexName0, searchRulesParams0); - } - ); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"something\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - @Test - @DisplayName("searchSynonyms") - void searchSynonymsTest0() { - String indexName0 = "indexName"; +body3.setObjectID(objectID4); +String language4 = "en"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchSynonyms(indexName0); - } - ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/search"); - assertEquals(req.getMethod(), "POST"); - } - @Test - @DisplayName("searchUserIds") - void searchUserIdsTest0() { - SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); - { - String query1 = "test"; - searchUserIdsParams0.setQuery(query1); - String clusterName1 = "theClusterName"; - searchUserIdsParams0.setClusterName(clusterName1); - int page1 = 5; +body3.setLanguage(language4); + }requests_02.setBody(body3); + }requests1.add(requests_02); - searchUserIdsParams0.setPage(page1); - int hitsPerPage1 = 10; - searchUserIdsParams0.setHitsPerPage(hitsPerPage1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchUserIds(searchUserIdsParams0); - } - ); - assertEquals(req.getPath(), "/1/clusters/mapping/search"); - assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get setDictionarySettings results with minimal parameters") - void setDictionarySettingsTest0() { - DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); - { - StandardEntries disableStandardEntries1 = new StandardEntries(); - { - Map plurals2 = new HashMap<>(); - { - boolean fr3 = false; +BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); +{ - plurals2.put("fr", fr3); - boolean en3 = false; - plurals2.put("en", en3); - boolean ru3 = true; +DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); + +requests_12.setAction(action3); + - plurals2.put("ru", ru3); - } - disableStandardEntries1.setPlurals(plurals2); - } - dictionarySettingsParams0.setDisableStandardEntries( - disableStandardEntries1 - ); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(dictionarySettingsParams0); - } - ); - - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("get setDictionarySettings results with all parameters") - void setDictionarySettingsTest1() { - DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); - { - StandardEntries disableStandardEntries1 = new StandardEntries(); - { - Map plurals2 = new HashMap<>(); - { - boolean fr3 = false; - - plurals2.put("fr", fr3); - - boolean en3 = false; - - plurals2.put("en", en3); - - boolean ru3 = true; - - plurals2.put("ru", ru3); - } - disableStandardEntries1.setPlurals(plurals2); - Map stopwords2 = new HashMap<>(); - { - boolean fr3 = false; - stopwords2.put("fr", fr3); - } - disableStandardEntries1.setStopwords(stopwords2); - Map compounds2 = new HashMap<>(); - { - boolean ru3 = true; - compounds2.put("ru", ru3); - } - disableStandardEntries1.setCompounds(compounds2); - } - dictionarySettingsParams0.setDisableStandardEntries( - disableStandardEntries1 - ); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(dictionarySettingsParams0); - } - ); - - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } - - @Test - @DisplayName("setSettings") - void setSettingsTest0() { - String indexName0 = "theIndexName"; - - IndexSettings indexSettings0 = new IndexSettings(); - { - int paginationLimitedTo1 = 10; - - indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); - } - - boolean forwardToReplicas0 = true; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setSettings( - indexName0, - indexSettings0, - forwardToReplicas0 - ); - } - ); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"paginationLimitedTo\":10}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - - Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\"}", - new TypeToken>() {}.getType() - ); - List actualQuery = req.getQueryParams(); - for (Map.Entry entry : expectedQuery.entrySet()) { - boolean found = false; - for (Pair p : actualQuery) { - if ( - p.getName().equals(entry.getKey()) && - p.getValue().equals(entry.getValue()) - ) { - found = true; - } - } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } - } - @Test - @DisplayName("updateApiKey") - void updateApiKeyTest0() { - String key0 = "myApiKey"; +DictionaryEntry body3 = new DictionaryEntry(); +{ String objectID4 = "2"; - ApiKey apiKey0 = new ApiKey(); - { - List acl1 = new ArrayList<>(); - { - Acl acl_02 = Acl.fromValue("search"); - acl1.add(acl_02); - Acl acl_12 = Acl.fromValue("addObject"); - acl1.add(acl_12); - } - apiKey0.setAcl(acl1); - int validity1 = 300; - apiKey0.setValidity(validity1); +body3.setObjectID(objectID4); +String language4 = "fr"; - int maxQueriesPerIPPerHour1 = 100; - apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); - int maxHitsPerQuery1 = 20; - apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); + + +body3.setLanguage(language4); + }requests_12.setBody(body3); + }requests1.add(requests_12); } +batchDictionaryEntriesParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchDictionaryEntries(dictionaryName0,batchDictionaryEntriesParams0); + }); + + assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + } + @Test + @DisplayName("get batchDictionaryEntries results with all parameters") + void batchDictionaryEntriesTest1() { + + + + + +DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + + + + + + + + +BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); +{ + + + +boolean clearExistingDictionaryEntries1 = false; + + +batchDictionaryEntriesParams0.setClearExistingDictionaryEntries(clearExistingDictionaryEntries1); + + + + + + +List + requests1 = new ArrayList<>(); { + + + + + + +BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); +{ + + + + +DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); + +requests_02.setAction(action3); + + + + + + + +DictionaryEntry body3 = new DictionaryEntry(); +{ String objectID4 = "1"; + + + + + + +body3.setObjectID(objectID4); +String language4 = "en"; + + + + + + +body3.setLanguage(language4); +String word4 = "fancy"; + + + + + + +body3.setWord(word4); + + + + + + +List + words4 = new ArrayList<>(); { String words_05 = "believe"; + + + + + + +words4.add(words_05);String words_15 = "algolia"; + + + + + + +words4.add(words_15); } +body3.setWords(words4); + + + + + + +List + decomposition4 = new ArrayList<>(); { String decomposition_05 = "trust"; + + + + + + +decomposition4.add(decomposition_05);String decomposition_15 = "algolia"; + - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.updateApiKey(key0, apiKey0); - } - ); - assertEquals(req.getPath(), "/1/keys/myApiKey"); - assertEquals(req.getMethod(), "PUT"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); - } + + +decomposition4.add(decomposition_15); } +body3.setDecomposition(decomposition4); + + + + + +DictionaryEntryState state4 = DictionaryEntryState.fromValue("enabled"); + +body3.setState(state4); + }requests_02.setBody(body3); + }requests1.add(requests_02); + + + + + + +BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); +{ + + + + +DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); + +requests_12.setAction(action3); + + + + + + + +DictionaryEntry body3 = new DictionaryEntry(); +{ String objectID4 = "2"; + + + + + + +body3.setObjectID(objectID4); +String language4 = "fr"; + + + + + + +body3.setLanguage(language4); +String word4 = "humility"; + + + + + + +body3.setWord(word4); + + + + + + +List + words4 = new ArrayList<>(); { String words_05 = "candor"; + + + + + + +words4.add(words_05);String words_15 = "algolia"; + + + + + + +words4.add(words_15); } +body3.setWords(words4); + + + + + + +List + decomposition4 = new ArrayList<>(); { String decomposition_05 = "grit"; + + + + + + +decomposition4.add(decomposition_05);String decomposition_15 = "algolia"; + + + + + + +decomposition4.add(decomposition_15); } +body3.setDecomposition(decomposition4); + + + + + +DictionaryEntryState state4 = DictionaryEntryState.fromValue("enabled"); + +body3.setState(state4); + }requests_12.setBody(body3); + }requests1.add(requests_12); } +batchDictionaryEntriesParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchDictionaryEntries(dictionaryName0,batchDictionaryEntriesParams0); + }); + + assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"clearExistingDictionaryEntries\":false,\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\",\"word\":\"fancy\",\"words\":[\"believe\",\"algolia\"],\"decomposition\":[\"trust\",\"algolia\"],\"state\":\"enabled\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\",\"word\":\"humility\",\"words\":[\"candor\",\"algolia\"],\"decomposition\":[\"grit\",\"algolia\"],\"state\":\"enabled\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("batchRules") + void batchRulesTest0() { + String indexName0 = "indexName"; + + + + + + + + + + + + +List + rule0 = new ArrayList<>(); { + + + + + + +Rule rule_01 = new Rule(); +{ String objectID2 = "a-rule-id"; + + + + + + +rule_01.setObjectID(objectID2); + + + + + + +List + conditions2 = new ArrayList<>(); { + + + + + + +Condition conditions_03 = new Condition(); +{ String pattern4 = "smartphone"; + + + + + + +conditions_03.setPattern(pattern4); + + + + + +Anchoring anchoring4 = Anchoring.fromValue("contains"); + +conditions_03.setAnchoring(anchoring4); + }conditions2.add(conditions_03); } +rule_01.setConditions(conditions2); + + + + + + + +Consequence consequence2 = new Consequence(); +{ + + + + + + +ConsequenceParams params3 = new ConsequenceParams(); +{ String filters4 = "category:smartphone"; + + + + + + +params3.setFilters(filters4); + }consequence2.setParams(params3); + }rule_01.setConsequence(consequence2); + }rule0.add(rule_01); + + + + + + +Rule rule_11 = new Rule(); +{ String objectID2 = "a-second-rule-id"; + + + + + + +rule_11.setObjectID(objectID2); + + + + + + +List + conditions2 = new ArrayList<>(); { + + + + + + +Condition conditions_03 = new Condition(); +{ String pattern4 = "apple"; + + + + + + +conditions_03.setPattern(pattern4); + + + + + +Anchoring anchoring4 = Anchoring.fromValue("contains"); + +conditions_03.setAnchoring(anchoring4); + }conditions2.add(conditions_03); } +rule_11.setConditions(conditions2); + + + + + + + +Consequence consequence2 = new Consequence(); +{ + + + + + + +ConsequenceParams params3 = new ConsequenceParams(); +{ String filters4 = "brand:apple"; + + + + + + +params3.setFilters(filters4); + }consequence2.setParams(params3); + }rule_11.setConsequence(consequence2); + }rule0.add(rule_11); } + + + + +boolean forwardToReplicas0 = true; + + + + + + +boolean clearExistingRules0 = true; + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchRules(indexName0,rule0,forwardToReplicas0,clearExistingRules0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("[{\"objectID\":\"a-rule-id\",\"conditions\":[{\"pattern\":\"smartphone\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"category:smartphone\"}}},{\"objectID\":\"a-second-rule-id\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}]", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\",\"clearExistingRules\":\"true\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("get browse results with minimal parameters") + void browseTest0() { + String indexName0 = "indexName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.browse(indexName0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/browse"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("get browse results with all parameters") + void browseTest1() { + String indexName0 = "indexName"; + + + + + + + + + + + + + +BrowseRequest browseRequest0 = new BrowseRequest(); +{ String params1 = "query=foo&facetFilters=['bar']"; + + + + + + +browseRequest0.setParams(params1); +String cursor1 = "cts"; + + + + + + +browseRequest0.setCursor(cursor1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.browse(indexName0,browseRequest0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/browse"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("clearAllSynonyms") + void clearAllSynonymsTest0() { + String indexName0 = "indexName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.clearAllSynonyms(indexName0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/clear"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("clearObjects") + void clearObjectsTest0() { + String indexName0 = "theIndexName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.clearObjects(indexName0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/clear"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("clearRules") + void clearRulesTest0() { + String indexName0 = "indexName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.clearRules(indexName0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/clear"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0,parameters0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("deleteApiKey") + void deleteApiKeyTest0() { + String key0 = "myTestApiKey"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteApiKey(key0); + }); + + assertEquals(req.getPath(), "/1/keys/myTestApiKey"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("deleteBy") + void deleteByTest0() { + String indexName0 = "theIndexName"; + + + + + + + + + + + + + +SearchParamsObject searchParams0 = new SearchParamsObject(); +{ String query1 = "testQuery"; + + + + + + +searchParams0.setQuery(query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteBy(indexName0,.of(searchParams0)); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"query\":\"testQuery\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("deleteIndex") + void deleteIndexTest0() { + String indexName0 = "theIndexName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteIndex(indexName0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("deleteObject") + void deleteObjectTest0() { + String indexName0 = "theIndexName"; + + + + + + +String objectID0 = "uniqueID"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteObject(indexName0,objectID0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("deleteRule") + void deleteRuleTest0() { + String indexName0 = "indexName"; + + + + + + +String objectID0 = "id1"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteRule(indexName0,objectID0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("deleteSource") + void deleteSourceTest0() { + String source0 = "theSource"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteSource(source0); + }); + + assertEquals(req.getPath(), "/1/security/sources/theSource"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("deleteSynonym") + void deleteSynonymTest0() { + String indexName0 = "indexName"; + + + + + + +String objectID0 = "id1"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteSynonym(indexName0,objectID0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0,parameters0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getApiKey") + void getApiKeyTest0() { + String key0 = "myTestApiKey"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getApiKey(key0); + }); + + assertEquals(req.getPath(), "/1/keys/myTestApiKey"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("get getDictionaryLanguages") + void getDictionaryLanguagesTest0() { + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getDictionaryLanguages(); + }); + + assertEquals(req.getPath(), "/1/dictionaries/*/languages"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("get getDictionarySettings results") + void getDictionarySettingsTest0() { + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getDictionarySettings(); + }); + + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getLogs") + void getLogsTest0() { + +int offset0 = 5; + + + + + + +int length0 = 10; + + + + + +String indexName0 = "theIndexName"; + + + + + + + + + + + +LogType type0 = LogType.fromValue("all"); + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getLogs(offset0,length0,indexName0,type0); + }); + + assertEquals(req.getPath(), "/1/logs"); + assertEquals(req.getMethod(), "GET"); + + + HashMap expectedQuery = JSON.deserialize("{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("getObject") + void getObjectTest0() { + String indexName0 = "theIndexName"; + + + + + + +String objectID0 = "uniqueID"; + + + + + + + + + + + + +List + attributesToRetrieve0 = new ArrayList<>(); { String attributesToRetrieve_01 = "attr1"; + + + + + + +attributesToRetrieve0.add(attributesToRetrieve_01);String attributesToRetrieve_11 = "attr2"; + + + + + + +attributesToRetrieve0.add(attributesToRetrieve_11); } + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getObject(indexName0,objectID0,attributesToRetrieve0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); + assertEquals(req.getMethod(), "GET"); + + + HashMap expectedQuery = JSON.deserialize("{\"attributesToRetrieve\":\"attr1,attr2\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("getObjects") + void getObjectsTest0() { + + + + + + + +GetObjectsParams getObjectsParams0 = new GetObjectsParams(); +{ + + + + + +List + requests1 = new ArrayList<>(); { + + + + + + +MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); +{ + + + + + +List + attributesToRetrieve3 = new ArrayList<>(); { String attributesToRetrieve_04 = "attr1"; + + + + + + +attributesToRetrieve3.add(attributesToRetrieve_04);String attributesToRetrieve_14 = "attr2"; + + + + + + +attributesToRetrieve3.add(attributesToRetrieve_14); } +requests_02.setAttributesToRetrieve(attributesToRetrieve3); +String objectID3 = "uniqueID"; + + + + + + +requests_02.setObjectID(objectID3); +String indexName3 = "theIndexName"; + + + + + + +requests_02.setIndexName(indexName3); + }requests1.add(requests_02); } +getObjectsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getObjects(getObjectsParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/objects"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"attributesToRetrieve\":[\"attr1\",\"attr2\"],\"objectID\":\"uniqueID\",\"indexName\":\"theIndexName\"}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("getRule") + void getRuleTest0() { + String indexName0 = "indexName"; + + + + + + +String objectID0 = "id1"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRule(indexName0,objectID0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getSettings") + void getSettingsTest0() { + String indexName0 = "theIndexName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSettings(indexName0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getSources") + void getSourcesTest0() { + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSources(); + }); + + assertEquals(req.getPath(), "/1/security/sources"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getSynonym") + void getSynonymTest0() { + String indexName0 = "indexName"; + + + + + + +String objectID0 = "id1"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSynonym(indexName0,objectID0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getTask") + void getTaskTest0() { + String indexName0 = "theIndexName"; + + + + + + + +int taskID0 = 123; + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTask(indexName0,taskID0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/task/123"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getTopUserIds") + void getTopUserIdsTest0() { + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopUserIds(); + }); + + assertEquals(req.getPath(), "/1/clusters/mapping/top"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("getUserId") + void getUserIdTest0() { + String userID0 = "uniqueID"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getUserId(userID0); + }); + + assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("hasPendingMappings") + void hasPendingMappingsTest0() { + + + + +boolean getClusters0 = true; + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.hasPendingMappings(getClusters0); + }); + + assertEquals(req.getPath(), "/1/clusters/mapping/pending"); + assertEquals(req.getMethod(), "GET"); + + + HashMap expectedQuery = JSON.deserialize("{\"getClusters\":\"true\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("listApiKeys") + void listApiKeysTest0() { + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listApiKeys(); + }); + + assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("listClusters") + void listClustersTest0() { + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listClusters(); + }); + + assertEquals(req.getPath(), "/1/clusters"); + assertEquals(req.getMethod(), "GET"); + + + } + @Test + @DisplayName("listIndices") + void listIndicesTest0() { + +int page0 = 8; + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listIndices(page0); + }); + + assertEquals(req.getPath(), "/1/indexes"); + assertEquals(req.getMethod(), "GET"); + + + HashMap expectedQuery = JSON.deserialize("{\"page\":\"8\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("listUserIds") + void listUserIdsTest0() { + +int page0 = 8; + + + + + + +int hitsPerPage0 = 100; + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listUserIds(page0,hitsPerPage0); + }); + + assertEquals(req.getPath(), "/1/clusters/mapping"); + assertEquals(req.getMethod(), "GET"); + + + HashMap expectedQuery = JSON.deserialize("{\"page\":\"8\",\"hitsPerPage\":\"100\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("multipleBatch") + void multipleBatchTest0() { + + + + + + + +BatchParams batchParams0 = new BatchParams(); +{ + + + + + +List + requests1 = new ArrayList<>(); { + + + + + + +MultipleBatchOperation requests_02 = new MultipleBatchOperation(); +{ + + + + +Action action3 = Action.fromValue("addObject"); + +requests_02.setAction(action3); + + + + + + + +Map body3 = new HashMap<>(); +{ String key4 = "value"; + + + + + + +body3.put("key", key4); + }requests_02.setBody(body3); +String indexName3 = "theIndexName"; + + + + + + +requests_02.setIndexName(indexName3); + }requests1.add(requests_02); } +batchParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.multipleBatch(batchParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("multipleQueries") + void multipleQueriesTest0() { + + + + + + + +MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); +{ + + + + + +List + requests1 = new ArrayList<>(); { + + + + + + +MultipleQueries requests_02 = new MultipleQueries(); +{ String indexName3 = "theIndexName"; + + + + + + +requests_02.setIndexName(indexName3); +String query3 = "test"; + + + + + + +requests_02.setQuery(query3); + + + + + +MultipleQueriesType type3 = MultipleQueriesType.fromValue("facet"); + +requests_02.setType(type3); +String facet3 = "theFacet"; + + + + + + +requests_02.setFacet(facet3); +String params3 = "testParam"; + + + + + + +requests_02.setParams(params3); + }requests1.add(requests_02); } +multipleQueriesParams0.setRequests(requests1); + + + + + +MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue("stopIfEnoughMatches"); + +multipleQueriesParams0.setStrategy(strategy1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.multipleQueries(multipleQueriesParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/*/queries"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("operationIndex") + void operationIndexTest0() { + String indexName0 = "theIndexName"; + + + + + + + + + + + + + +OperationIndexParams operationIndexParams0 = new OperationIndexParams(); +{ + + + + +OperationType operation1 = OperationType.fromValue("copy"); + +operationIndexParams0.setOperation(operation1); +String destination1 = "dest"; + + + + + + +operationIndexParams0.setDestination(destination1); + + + + + + +List + scope1 = new ArrayList<>(); { + + + + +ScopeType scope_02 = ScopeType.fromValue("rules"); + +scope1.add(scope_02); + + + + +ScopeType scope_12 = ScopeType.fromValue("settings"); + +scope1.add(scope_12); } +operationIndexParams0.setScope(scope1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.operationIndex(indexName0,operationIndexParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("partialUpdateObject") + void partialUpdateObjectTest0() { + String indexName0 = "theIndexName"; + + + + + + +String objectID0 = "uniqueID"; + + + + + + + + + + + + +List> + attributeOrBuiltInOperation0 = new ArrayList<>(); { + + + + + + +Map attributeOrBuiltInOperation_01 = new HashMap<>(); +{ String id12 = "test"; + + + + + + +attributeOrBuiltInOperation_01.put("id1", .of(id12)); + + + + + + + +BuiltInOperation id22 = new BuiltInOperation(); +{ + + + + +BuiltInOperationType operation3 = BuiltInOperationType.fromValue("AddUnique"); + +id22.setOperation(operation3); +String value3 = "test2"; + + + + + + +id22.setValue(value3); + }attributeOrBuiltInOperation_01.put("id2", .of(id22)); + }attributeOrBuiltInOperation0.add(attributeOrBuiltInOperation_01); } + + + + +boolean createIfNotExists0 = true; + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.partialUpdateObject(indexName0,objectID0,attributeOrBuiltInOperation0,createIfNotExists0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID/partial"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"createIfNotExists\":\"true\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + + + + + +Map body0 = new HashMap<>(); +{ String body1 = "parameters"; + + + + + + +body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0,parameters0,body0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + }); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + + + } + @Test + @DisplayName("allow put method for a custom path with all parameters") + void putTest1() { + String path0 = "/test/all"; + + + + + + + + + + + + + +Map parameters0 = new HashMap<>(); +{ String query1 = "parameters"; + + + + + + +parameters0.put("query", query1); + } + + + + + + +Map body0 = new HashMap<>(); +{ String body1 = "parameters"; + + + + + + +body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0,parameters0,body0); + }); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + + + } + @Test + @DisplayName("removeUserId") + void removeUserIdTest0() { + String userID0 = "uniqueID"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.removeUserId(userID0); + }); + + assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); + assertEquals(req.getMethod(), "DELETE"); + + + } + @Test + @DisplayName("replaceSources") + void replaceSourcesTest0() { + + + + + + +List + source0 = new ArrayList<>(); { + + + + + + +Source source_01 = new Source(); +{ String source2 = "theSource"; + + + + + + +source_01.setSource(source2); +String description2 = "theDescription"; + + + + + + +source_01.setDescription(description2); + }source0.add(source_01); } + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.replaceSources(source0); + }); + + assertEquals(req.getPath(), "/1/security/sources"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("restoreApiKey") + void restoreApiKeyTest0() { + String key0 = "myApiKey"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.restoreApiKey(key0); + }); + + assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("saveObject") + void saveObjectTest0() { + String indexName0 = "theIndexName"; + + + + + + + + + + + + + +Map body0 = new HashMap<>(); +{ String objectID1 = "id"; + + + + + + +body0.put("objectID", objectID1); +String test1 = "val"; + + + + + + +body0.put("test", test1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveObject(indexName0,body0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"objectID\":\"id\",\"test\":\"val\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("saveRule") + void saveRuleTest0() { + String indexName0 = "indexName"; + + + + + + +String objectID0 = "id1"; + + + + + + + + + + + + + +Rule rule0 = new Rule(); +{ String objectID1 = "id1"; + + + + + + +rule0.setObjectID(objectID1); + + + + + + +List + conditions1 = new ArrayList<>(); { + + + + + + +Condition conditions_02 = new Condition(); +{ String pattern3 = "apple"; + + + + + + +conditions_02.setPattern(pattern3); + + + + + +Anchoring anchoring3 = Anchoring.fromValue("contains"); + +conditions_02.setAnchoring(anchoring3); + }conditions1.add(conditions_02); } +rule0.setConditions(conditions1); + + + + + + + +Consequence consequence1 = new Consequence(); +{ + + + + + + +ConsequenceParams params2 = new ConsequenceParams(); +{ String filters3 = "brand:apple"; + + + + + + +params2.setFilters(filters3); + }consequence1.setParams(params2); + }rule0.setConsequence(consequence1); + } + + + +boolean forwardToReplicas0 = true; + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveRule(indexName0,objectID0,rule0,forwardToReplicas0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"objectID\":\"id1\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("saveSynonym") + void saveSynonymTest0() { + String indexName0 = "indexName"; + + + + + + +String objectID0 = "id1"; + + + + + + + + + + + + + +SynonymHit synonymHit0 = new SynonymHit(); +{ String objectID1 = "id1"; + + + + + + +synonymHit0.setObjectID(objectID1); + + + + + +SynonymType type1 = SynonymType.fromValue("synonym"); + +synonymHit0.setType(type1); + + + + + + +List + synonyms1 = new ArrayList<>(); { String synonyms_02 = "car"; + + + + + + +synonyms1.add(synonyms_02);String synonyms_12 = "vehicule"; + + + + + + +synonyms1.add(synonyms_12);String synonyms_22 = "auto"; + + + + + + +synonyms1.add(synonyms_22); } +synonymHit0.setSynonyms(synonyms1); + } + + + +boolean forwardToReplicas0 = true; + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveSynonym(indexName0,objectID0,synonymHit0,forwardToReplicas0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("saveSynonyms") + void saveSynonymsTest0() { + String indexName0 = "indexName"; + + + + + + + + + + + + +List + synonymHit0 = new ArrayList<>(); { + + + + + + +SynonymHit synonymHit_01 = new SynonymHit(); +{ String objectID2 = "id1"; + + + + + + +synonymHit_01.setObjectID(objectID2); + + + + + +SynonymType type2 = SynonymType.fromValue("synonym"); + +synonymHit_01.setType(type2); + + + + + + +List + synonyms2 = new ArrayList<>(); { String synonyms_03 = "car"; + + + + + + +synonyms2.add(synonyms_03);String synonyms_13 = "vehicule"; + + + + + + +synonyms2.add(synonyms_13);String synonyms_23 = "auto"; + + + + + + +synonyms2.add(synonyms_23); } +synonymHit_01.setSynonyms(synonyms2); + }synonymHit0.add(synonymHit_01); + + + + + + +SynonymHit synonymHit_11 = new SynonymHit(); +{ String objectID2 = "id2"; + + + + + + +synonymHit_11.setObjectID(objectID2); + + + + + +SynonymType type2 = SynonymType.fromValue("onewaysynonym"); + +synonymHit_11.setType(type2); +String input2 = "iphone"; + + + + + + +synonymHit_11.setInput(input2); + + + + + + +List + synonyms2 = new ArrayList<>(); { String synonyms_03 = "ephone"; + + + + + + +synonyms2.add(synonyms_03);String synonyms_13 = "aphone"; + + + + + + +synonyms2.add(synonyms_13);String synonyms_23 = "yphone"; + + + + + + +synonyms2.add(synonyms_23); } +synonymHit_11.setSynonyms(synonyms2); + }synonymHit0.add(synonymHit_11); } + + + + +boolean forwardToReplicas0 = true; + + + + + + +boolean replaceExistingSynonyms0 = false; + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveSynonyms(indexName0,synonymHit0,forwardToReplicas0,replaceExistingSynonyms0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("search with minimal parameters") + void searchTest0() { + String indexName0 = "indexName"; + + + + + + + + + + + + + +SearchParamsObject searchParams0 = new SearchParamsObject(); +{ String query1 = "myQuery"; + + + + + + +searchParams0.setQuery(query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.search(indexName0,.of(searchParams0)); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"query\":\"myQuery\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("search with facetFilters") + void searchTest1() { + String indexName0 = "indexName"; + + + + + + + + + + + + + +SearchParamsObject searchParams0 = new SearchParamsObject(); +{ String query1 = "myQuery"; + + + + + + +searchParams0.setQuery(query1); + + + + + + +List + facetFilters1 = new ArrayList<>(); { String facetFilters_02 = "tags:algolia"; + + + + + + +facetFilters1.add(facetFilters_02); } +searchParams0.setFacetFilters(.of(facetFilters1)); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.search(indexName0,.of(searchParams0)); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("get searchDictionaryEntries results with minimal parameters") + void searchDictionaryEntriesTest0() { + + + + + +DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + + + + + + + + +SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); +{ String query1 = "foo"; + + + + + + +searchDictionaryEntriesParams0.setQuery(query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchDictionaryEntries(dictionaryName0,searchDictionaryEntriesParams0); + }); + + assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"query\":\"foo\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("get searchDictionaryEntries results with all parameters") + void searchDictionaryEntriesTest1() { + + + + + +DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + + + + + + + + +SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); +{ String query1 = "foo"; + + + + + + +searchDictionaryEntriesParams0.setQuery(query1); + +int page1 = 4; + + + + + +searchDictionaryEntriesParams0.setPage(page1); + +int hitsPerPage1 = 2; + + + + + +searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); +String language1 = "fr"; + + + + + + +searchDictionaryEntriesParams0.setLanguage(language1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchDictionaryEntries(dictionaryName0,searchDictionaryEntriesParams0); + }); + + assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"query\":\"foo\",\"page\":4,\"hitsPerPage\":2,\"language\":\"fr\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("get searchForFacetValues results with minimal parameters") + void searchForFacetValuesTest0() { + String indexName0 = "indexName"; + + + + + + +String facetName0 = "facetName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchForFacetValues(indexName0,facetName0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("get searchForFacetValues results with all parameters") + void searchForFacetValuesTest1() { + String indexName0 = "indexName"; + + + + + + +String facetName0 = "facetName"; + + + + + + + + + + + + + +SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); +{ String params1 = "query=foo&facetFilters=['bar']"; + + + + + + +searchForFacetValuesRequest0.setParams(params1); +String facetQuery1 = "foo"; + + + + + + +searchForFacetValuesRequest0.setFacetQuery(facetQuery1); + +int maxFacetHits1 = 42; + + + + + +searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchForFacetValues(indexName0,facetName0,searchForFacetValuesRequest0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("searchRules") + void searchRulesTest0() { + String indexName0 = "indexName"; + + + + + + + + + + + + + +SearchRulesParams searchRulesParams0 = new SearchRulesParams(); +{ String query1 = "something"; + + + + + + +searchRulesParams0.setQuery(query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchRules(indexName0,searchRulesParams0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"query\":\"something\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("searchSynonyms") + void searchSynonymsTest0() { + String indexName0 = "indexName"; + + + + + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchSynonyms(indexName0); + }); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/search"); + assertEquals(req.getMethod(), "POST"); + + + } + @Test + @DisplayName("searchUserIds") + void searchUserIdsTest0() { + + + + + + + +SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); +{ String query1 = "test"; + + + + + + +searchUserIdsParams0.setQuery(query1); +String clusterName1 = "theClusterName"; + + + + + + +searchUserIdsParams0.setClusterName(clusterName1); + +int page1 = 5; + + + + + +searchUserIdsParams0.setPage(page1); + +int hitsPerPage1 = 10; + + + + + +searchUserIdsParams0.setHitsPerPage(hitsPerPage1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchUserIds(searchUserIdsParams0); + }); + + assertEquals(req.getPath(), "/1/clusters/mapping/search"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("get setDictionarySettings results with minimal parameters") + void setDictionarySettingsTest0() { + + + + + + + +DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); +{ + + + + + + +StandardEntries disableStandardEntries1 = new StandardEntries(); +{ + + + + + + +Map plurals2 = new HashMap<>(); +{ + + + +boolean fr3 = false; + + +plurals2.put("fr", fr3); + + + + +boolean en3 = false; + + +plurals2.put("en", en3); + + + + +boolean ru3 = true; + + +plurals2.put("ru", ru3); + }disableStandardEntries1.setPlurals(plurals2); + }dictionarySettingsParams0.setDisableStandardEntries(disableStandardEntries1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.setDictionarySettings(dictionarySettingsParams0); + }); + + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("get setDictionarySettings results with all parameters") + void setDictionarySettingsTest1() { + + + + + + + +DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); +{ + + + + + + +StandardEntries disableStandardEntries1 = new StandardEntries(); +{ + + + + + + +Map plurals2 = new HashMap<>(); +{ + + + +boolean fr3 = false; + + +plurals2.put("fr", fr3); + + + + +boolean en3 = false; + + +plurals2.put("en", en3); + + + + +boolean ru3 = true; + + +plurals2.put("ru", ru3); + }disableStandardEntries1.setPlurals(plurals2); + + + + + + + +Map stopwords2 = new HashMap<>(); +{ + + + +boolean fr3 = false; + + +stopwords2.put("fr", fr3); + }disableStandardEntries1.setStopwords(stopwords2); + + + + + + + +Map compounds2 = new HashMap<>(); +{ + + + +boolean ru3 = true; + + +compounds2.put("ru", ru3); + }disableStandardEntries1.setCompounds(compounds2); + }dictionarySettingsParams0.setDisableStandardEntries(disableStandardEntries1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.setDictionarySettings(dictionarySettingsParams0); + }); + + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } + @Test + @DisplayName("setSettings") + void setSettingsTest0() { + String indexName0 = "theIndexName"; + + + + + + + + + + + + + +IndexSettings indexSettings0 = new IndexSettings(); +{ +int paginationLimitedTo1 = 10; + + + + + +indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); + } + + + +boolean forwardToReplicas0 = true; + + + + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.setSettings(indexName0,indexSettings0,forwardToReplicas0); + }); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"paginationLimitedTo\":10}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType()); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("updateApiKey") + void updateApiKeyTest0() { + String key0 = "myApiKey"; + + + + + + + + + + + + + +ApiKey apiKey0 = new ApiKey(); +{ + + + + + +List + acl1 = new ArrayList<>(); { + + + + +Acl acl_02 = Acl.fromValue("search"); + +acl1.add(acl_02); + + + + +Acl acl_12 = Acl.fromValue("addObject"); + +acl1.add(acl_12); } +apiKey0.setAcl(acl1); + +int validity1 = 300; + + + + + +apiKey0.setValidity(validity1); + +int maxQueriesPerIPPerHour1 = 100; + + + + + +apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); + +int maxHitsPerQuery1 = 20; + + + + + +apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.updateApiKey(key0,apiKey0); + }); + + assertEquals(req.getPath(), "/1/keys/myApiKey"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals("{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", req.getBody(), JSONCompareMode.STRICT_ORDER); + }); + + } } diff --git a/tests/output/javascript/src/methods/requests/abtesting.test.ts b/tests/output/javascript/src/methods/requests/abtesting.test.ts index 6ae5e9153e..30ee990217 100644 --- a/tests/output/javascript/src/methods/requests/abtesting.test.ts +++ b/tests/output/javascript/src/methods/requests/abtesting.test.ts @@ -30,7 +30,7 @@ describe('addABTests', () => { { index: 'AB_TEST_2', trafficPercentage: 50 }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -68,7 +68,7 @@ describe('deleteABTest', () => { expect(req.path).toEqual('/2/abtests/42'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -104,7 +104,7 @@ describe('getABTest', () => { expect(req.path).toEqual('/2/abtests/42'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -118,7 +118,7 @@ describe('listABTests', () => { expect(req.path).toEqual('/2/abtests'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ offset: '42', limit: '21' }); + expect(req.searchParams).toStrictEqual({ offset: '42', limit: '21' }); }); }); @@ -183,6 +183,6 @@ describe('stopABTest', () => { expect(req.path).toEqual('/2/abtests/42/stop'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); diff --git a/tests/output/javascript/src/methods/requests/analytics.test.ts b/tests/output/javascript/src/methods/requests/analytics.test.ts index 93f2e3dacc..d1bca4cbe6 100644 --- a/tests/output/javascript/src/methods/requests/analytics.test.ts +++ b/tests/output/javascript/src/methods/requests/analytics.test.ts @@ -68,7 +68,7 @@ describe('getAverageClickPosition', () => { expect(req.path).toEqual('/2/clicks/averageClickPosition'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getAverageClickPosition with all parameters', async () => { @@ -82,7 +82,7 @@ describe('getAverageClickPosition', () => { expect(req.path).toEqual('/2/clicks/averageClickPosition'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -100,7 +100,7 @@ describe('getClickPositions', () => { expect(req.path).toEqual('/2/clicks/positions'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getClickPositions with all parameters', async () => { @@ -114,7 +114,7 @@ describe('getClickPositions', () => { expect(req.path).toEqual('/2/clicks/positions'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -132,7 +132,7 @@ describe('getClickThroughRate', () => { expect(req.path).toEqual('/2/clicks/clickThroughRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getClickThroughRate with all parameters', async () => { @@ -146,7 +146,7 @@ describe('getClickThroughRate', () => { expect(req.path).toEqual('/2/clicks/clickThroughRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -164,7 +164,7 @@ describe('getConversationRate', () => { expect(req.path).toEqual('/2/conversions/conversionRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getConversationRate with all parameters', async () => { @@ -178,7 +178,7 @@ describe('getConversationRate', () => { expect(req.path).toEqual('/2/conversions/conversionRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -196,7 +196,7 @@ describe('getNoClickRate', () => { expect(req.path).toEqual('/2/searches/noClickRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getNoClickRate with all parameters', async () => { @@ -210,7 +210,7 @@ describe('getNoClickRate', () => { expect(req.path).toEqual('/2/searches/noClickRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -228,7 +228,7 @@ describe('getNoResultsRate', () => { expect(req.path).toEqual('/2/searches/noResultRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getNoResultsRate with all parameters', async () => { @@ -242,7 +242,7 @@ describe('getNoResultsRate', () => { expect(req.path).toEqual('/2/searches/noResultRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -260,7 +260,7 @@ describe('getSearchesCount', () => { expect(req.path).toEqual('/2/searches/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getSearchesCount with all parameters', async () => { @@ -274,7 +274,7 @@ describe('getSearchesCount', () => { expect(req.path).toEqual('/2/searches/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -292,7 +292,7 @@ describe('getSearchesNoClicks', () => { expect(req.path).toEqual('/2/searches/noClicks'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getSearchesNoClicks with all parameters', async () => { @@ -308,7 +308,7 @@ describe('getSearchesNoClicks', () => { expect(req.path).toEqual('/2/searches/noClicks'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -328,7 +328,7 @@ describe('getSearchesNoResults', () => { expect(req.path).toEqual('/2/searches/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getSearchesNoResults with all parameters', async () => { @@ -344,7 +344,7 @@ describe('getSearchesNoResults', () => { expect(req.path).toEqual('/2/searches/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -364,7 +364,7 @@ describe('getStatus', () => { expect(req.path).toEqual('/2/status'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); }); @@ -377,7 +377,7 @@ describe('getTopCountries', () => { expect(req.path).toEqual('/2/countries'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getTopCountries with all parameters', async () => { @@ -393,7 +393,7 @@ describe('getTopCountries', () => { expect(req.path).toEqual('/2/countries'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -413,7 +413,7 @@ describe('getTopFilterAttributes', () => { expect(req.path).toEqual('/2/filters'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getTopFilterAttributes with all parameters', async () => { @@ -430,7 +430,7 @@ describe('getTopFilterAttributes', () => { expect(req.path).toEqual('/2/filters'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', search: 'mySearch', startDate: '1999-09-19', @@ -452,7 +452,7 @@ describe('getTopFilterForAttribute', () => { expect(req.path).toEqual('/2/filters/myAttribute'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getTopFilterForAttribute with minimal parameters and multiple attributes', async () => { @@ -464,7 +464,7 @@ describe('getTopFilterForAttribute', () => { expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getTopFilterForAttribute with all parameters', async () => { @@ -482,7 +482,7 @@ describe('getTopFilterForAttribute', () => { expect(req.path).toEqual('/2/filters/myAttribute'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', search: 'mySearch', startDate: '1999-09-19', @@ -508,7 +508,7 @@ describe('getTopFilterForAttribute', () => { expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', search: 'mySearch', startDate: '1999-09-19', @@ -529,7 +529,7 @@ describe('getTopFiltersNoResults', () => { expect(req.path).toEqual('/2/filters/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getTopFiltersNoResults with all parameters', async () => { @@ -546,7 +546,7 @@ describe('getTopFiltersNoResults', () => { expect(req.path).toEqual('/2/filters/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', search: 'mySearch', startDate: '1999-09-19', @@ -567,7 +567,7 @@ describe('getTopHits', () => { expect(req.path).toEqual('/2/hits'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getTopHits with all parameters', async () => { @@ -585,7 +585,7 @@ describe('getTopHits', () => { expect(req.path).toEqual('/2/hits'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', search: 'mySearch', clickAnalytics: 'true', @@ -607,7 +607,7 @@ describe('getTopSearches', () => { expect(req.path).toEqual('/2/searches'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getTopSearches with all parameters', async () => { @@ -626,7 +626,7 @@ describe('getTopSearches', () => { expect(req.path).toEqual('/2/searches'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', clickAnalytics: 'true', startDate: '1999-09-19', @@ -649,7 +649,7 @@ describe('getUsersCount', () => { expect(req.path).toEqual('/2/users/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toStrictEqual({ index: 'index' }); }); test('get getUsersCount with all parameters', async () => { @@ -663,7 +663,7 @@ describe('getUsersCount', () => { expect(req.path).toEqual('/2/users/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', diff --git a/tests/output/javascript/src/methods/requests/insights.test.ts b/tests/output/javascript/src/methods/requests/insights.test.ts index a2a8e57792..14ce5768d5 100644 --- a/tests/output/javascript/src/methods/requests/insights.test.ts +++ b/tests/output/javascript/src/methods/requests/insights.test.ts @@ -152,7 +152,7 @@ describe('pushEvents', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); diff --git a/tests/output/javascript/src/methods/requests/personalization.test.ts b/tests/output/javascript/src/methods/requests/personalization.test.ts index 3f97eefec3..86c84efd9e 100644 --- a/tests/output/javascript/src/methods/requests/personalization.test.ts +++ b/tests/output/javascript/src/methods/requests/personalization.test.ts @@ -43,7 +43,7 @@ describe('deleteUserProfile', () => { expect(req.path).toEqual('/1/profiles/UserToken'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -80,7 +80,7 @@ describe('getPersonalizationStrategy', () => { expect(req.path).toEqual('/1/strategies/personalization'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -93,7 +93,7 @@ describe('getUserTokenProfile', () => { expect(req.path).toEqual('/1/profiles/personalization/UserToken'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -164,6 +164,6 @@ describe('setPersonalizationStrategy', () => { facetScoring: [{ score: 42, facetName: 'Event' }], personalizationImpact: 42, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); diff --git a/tests/output/javascript/src/methods/requests/query-suggestions.test.ts b/tests/output/javascript/src/methods/requests/query-suggestions.test.ts index acfc470f2a..17716519a0 100644 --- a/tests/output/javascript/src/methods/requests/query-suggestions.test.ts +++ b/tests/output/javascript/src/methods/requests/query-suggestions.test.ts @@ -38,7 +38,7 @@ describe('createConfig', () => { languages: ['french'], exclude: ['test'], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -76,7 +76,7 @@ describe('deleteConfig', () => { expect(req.path).toEqual('/1/configs/theIndexName'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -112,7 +112,7 @@ describe('getAllConfigs', () => { expect(req.path).toEqual('/1/configs'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -125,7 +125,7 @@ describe('getConfig', () => { expect(req.path).toEqual('/1/configs/theIndexName'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -138,7 +138,7 @@ describe('getConfigStatus', () => { expect(req.path).toEqual('/1/configs/theIndexName/status'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -151,7 +151,7 @@ describe('getLogFile', () => { expect(req.path).toEqual('/1/logs/theIndexName'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -237,6 +237,6 @@ describe('updateConfig', () => { languages: ['french'], exclude: ['test'], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); diff --git a/tests/output/javascript/src/methods/requests/recommend.test.ts b/tests/output/javascript/src/methods/requests/recommend.test.ts index 5476120514..6d81d12ec6 100644 --- a/tests/output/javascript/src/methods/requests/recommend.test.ts +++ b/tests/output/javascript/src/methods/requests/recommend.test.ts @@ -82,7 +82,7 @@ describe('getRecommendations', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get recommendations for recommend model with all parameters', async () => { @@ -115,7 +115,7 @@ describe('getRecommendations', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get recommendations for trending model with minimal parameters', async () => { @@ -132,7 +132,7 @@ describe('getRecommendations', () => { { indexName: 'indexName', model: 'trending-items', threshold: 42 }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get recommendations for trending model with all parameters', async () => { @@ -167,7 +167,7 @@ describe('getRecommendations', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get multiple recommendations with minimal parameters', async () => { @@ -206,7 +206,7 @@ describe('getRecommendations', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get multiple recommendations with all parameters', async () => { @@ -257,7 +257,7 @@ describe('getRecommendations', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get frequently bought together recommendations', async () => { @@ -284,7 +284,7 @@ describe('getRecommendations', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index b06e82288a..16c7d84765 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -26,7 +26,7 @@ describe('addApiKey', () => { maxQueriesPerIPPerHour: 100, maxHitsPerQuery: 20, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -41,7 +41,7 @@ describe('addOrUpdateObject', () => { expect(req.path).toEqual('/1/indexes/indexName/uniqueID'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ key: 'value' }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -58,7 +58,7 @@ describe('appendSource', () => { source: 'theSource', description: 'theDescription', }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -72,7 +72,7 @@ describe('assignUserId', () => { expect(req.path).toEqual('/1/clusters/mapping'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ cluster: 'theCluster' }); - expect(req.searchParams).toEqual({ 'X-Algolia-User-ID': 'userID' }); + expect(req.searchParams).toStrictEqual({ 'X-Algolia-User-ID': 'userID' }); }); }); @@ -90,7 +90,7 @@ describe('batch', () => { expect(req.data).toEqual({ requests: [{ action: 'delete', body: { key: 'value' } }], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -110,7 +110,7 @@ describe('batchAssignUserIds', () => { cluster: 'theCluster', users: ['user1', 'user2'], }); - expect(req.searchParams).toEqual({ 'X-Algolia-User-ID': 'userID' }); + expect(req.searchParams).toStrictEqual({ 'X-Algolia-User-ID': 'userID' }); }); }); @@ -134,7 +134,7 @@ describe('batchDictionaryEntries', () => { { action: 'deleteEntry', body: { objectID: '2', language: 'fr' } }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get batchDictionaryEntries results with all parameters', async () => { @@ -198,7 +198,7 @@ describe('batchDictionaryEntries', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -236,7 +236,7 @@ describe('batchRules', () => { consequence: { params: { filters: 'brand:apple' } }, }, ]); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true', clearExistingRules: 'true', }); @@ -252,7 +252,7 @@ describe('browse', () => { expect(req.path).toEqual('/1/indexes/indexName/browse'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get browse results with all parameters', async () => { @@ -270,7 +270,7 @@ describe('browse', () => { params: "query=foo&facetFilters=['bar']", cursor: 'cts', }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -283,7 +283,7 @@ describe('clearAllSynonyms', () => { expect(req.path).toEqual('/1/indexes/indexName/synonyms/clear'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -296,7 +296,7 @@ describe('clearObjects', () => { expect(req.path).toEqual('/1/indexes/theIndexName/clear'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -309,7 +309,7 @@ describe('clearRules', () => { expect(req.path).toEqual('/1/indexes/indexName/rules/clear'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -347,7 +347,7 @@ describe('deleteApiKey', () => { expect(req.path).toEqual('/1/keys/myTestApiKey'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -361,7 +361,7 @@ describe('deleteBy', () => { expect(req.path).toEqual('/1/indexes/theIndexName/deleteByQuery'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ query: 'testQuery' }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -374,7 +374,7 @@ describe('deleteIndex', () => { expect(req.path).toEqual('/1/indexes/theIndexName'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -388,7 +388,7 @@ describe('deleteObject', () => { expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -402,7 +402,7 @@ describe('deleteRule', () => { expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -415,7 +415,7 @@ describe('deleteSource', () => { expect(req.path).toEqual('/1/security/sources/theSource'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -429,7 +429,7 @@ describe('deleteSynonym', () => { expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -467,7 +467,7 @@ describe('getApiKey', () => { expect(req.path).toEqual('/1/keys/myTestApiKey'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -479,7 +479,7 @@ describe('getDictionaryLanguages', () => { expect(req.path).toEqual('/1/dictionaries/*/languages'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -491,7 +491,7 @@ describe('getDictionarySettings', () => { expect(req.path).toEqual('/1/dictionaries/*/settings'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -507,7 +507,7 @@ describe('getLogs', () => { expect(req.path).toEqual('/1/logs'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ offset: '5', length: '10', indexName: 'theIndexName', @@ -527,7 +527,9 @@ describe('getObject', () => { expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ attributesToRetrieve: 'attr1,attr2' }); + expect(req.searchParams).toStrictEqual({ + attributesToRetrieve: 'attr1,attr2', + }); }); }); @@ -554,7 +556,7 @@ describe('getObjects', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -568,7 +570,7 @@ describe('getRule', () => { expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -581,7 +583,7 @@ describe('getSettings', () => { expect(req.path).toEqual('/1/indexes/theIndexName/settings'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -592,7 +594,7 @@ describe('getSources', () => { expect(req.path).toEqual('/1/security/sources'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -606,7 +608,7 @@ describe('getSynonym', () => { expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -620,7 +622,7 @@ describe('getTask', () => { expect(req.path).toEqual('/1/indexes/theIndexName/task/123'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -631,7 +633,7 @@ describe('getTopUserIds', () => { expect(req.path).toEqual('/1/clusters/mapping/top'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -644,7 +646,7 @@ describe('getUserId', () => { expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -657,7 +659,7 @@ describe('hasPendingMappings', () => { expect(req.path).toEqual('/1/clusters/mapping/pending'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ getClusters: 'true' }); + expect(req.searchParams).toStrictEqual({ getClusters: 'true' }); }); }); @@ -668,7 +670,7 @@ describe('listApiKeys', () => { expect(req.path).toEqual('/1/keys'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -679,7 +681,7 @@ describe('listClusters', () => { expect(req.path).toEqual('/1/clusters'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -692,7 +694,7 @@ describe('listIndices', () => { expect(req.path).toEqual('/1/indexes'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ page: '8' }); + expect(req.searchParams).toStrictEqual({ page: '8' }); }); }); @@ -706,7 +708,7 @@ describe('listUserIds', () => { expect(req.path).toEqual('/1/clusters/mapping'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ page: '8', hitsPerPage: '100' }); + expect(req.searchParams).toStrictEqual({ page: '8', hitsPerPage: '100' }); }); }); @@ -733,7 +735,7 @@ describe('multipleBatch', () => { }, ], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -766,7 +768,7 @@ describe('multipleQueries', () => { ], strategy: 'stopIfEnoughMatches', }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -788,7 +790,7 @@ describe('operationIndex', () => { destination: 'dest', scope: ['rules', 'settings'], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -808,7 +810,7 @@ describe('partialUpdateObject', () => { expect(req.data).toEqual([ { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, ]); - expect(req.searchParams).toEqual({ createIfNotExists: 'true' }); + expect(req.searchParams).toStrictEqual({ createIfNotExists: 'true' }); }); }); @@ -873,7 +875,7 @@ describe('removeUserId', () => { expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -888,7 +890,7 @@ describe('replaceSources', () => { expect(req.data).toEqual([ { source: 'theSource', description: 'theDescription' }, ]); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -901,7 +903,7 @@ describe('restoreApiKey', () => { expect(req.path).toEqual('/1/keys/myApiKey/restore'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -915,7 +917,7 @@ describe('saveObject', () => { expect(req.path).toEqual('/1/indexes/theIndexName'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ objectID: 'id', test: 'val' }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -939,7 +941,7 @@ describe('saveRule', () => { conditions: [{ pattern: 'apple', anchoring: 'contains' }], consequence: { params: { filters: 'brand:apple' } }, }); - expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); }); }); @@ -963,7 +965,7 @@ describe('saveSynonym', () => { type: 'synonym', synonyms: ['car', 'vehicule', 'auto'], }); - expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); }); }); @@ -1003,7 +1005,7 @@ describe('saveSynonyms', () => { synonyms: ['ephone', 'aphone', 'yphone'], }, ]); - expect(req.searchParams).toEqual({ + expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true', replaceExistingSynonyms: 'false', }); @@ -1020,7 +1022,7 @@ describe('search', () => { expect(req.path).toEqual('/1/indexes/indexName/query'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ query: 'myQuery' }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('search with facetFilters', async () => { @@ -1049,7 +1051,7 @@ describe('searchDictionaryEntries', () => { expect(req.path).toEqual('/1/dictionaries/compounds/search'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ query: 'foo' }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get searchDictionaryEntries results with all parameters', async () => { @@ -1071,7 +1073,7 @@ describe('searchDictionaryEntries', () => { hitsPerPage: 2, language: 'fr', }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -1085,7 +1087,7 @@ describe('searchForFacetValues', () => { expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get searchForFacetValues results with all parameters', async () => { @@ -1106,7 +1108,7 @@ describe('searchForFacetValues', () => { facetQuery: 'foo', maxFacetHits: 42, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -1120,7 +1122,7 @@ describe('searchRules', () => { expect(req.path).toEqual('/1/indexes/indexName/rules/search'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ query: 'something' }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -1133,7 +1135,7 @@ describe('searchSynonyms', () => { expect(req.path).toEqual('/1/indexes/indexName/synonyms/search'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -1154,7 +1156,7 @@ describe('searchUserIds', () => { page: 5, hitsPerPage: 10, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -1169,7 +1171,7 @@ describe('setDictionarySettings', () => { expect(req.data).toEqual({ disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('get setDictionarySettings results with all parameters', async () => { @@ -1190,7 +1192,7 @@ describe('setDictionarySettings', () => { compounds: { ru: true }, }, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); @@ -1205,7 +1207,7 @@ describe('setSettings', () => { expect(req.path).toEqual('/1/indexes/theIndexName/settings'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ paginationLimitedTo: 10 }); - expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + expect(req.searchParams).toStrictEqual({ forwardToReplicas: 'true' }); }); }); @@ -1229,6 +1231,6 @@ describe('updateApiKey', () => { maxQueriesPerIPPerHour: 100, maxHitsPerQuery: 20, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); diff --git a/tests/output/javascript/src/methods/requests/sources.test.ts b/tests/output/javascript/src/methods/requests/sources.test.ts index e5d2af95fc..860e05ebe4 100644 --- a/tests/output/javascript/src/methods/requests/sources.test.ts +++ b/tests/output/javascript/src/methods/requests/sources.test.ts @@ -100,7 +100,7 @@ describe('postIngestUrl', () => { input: { url: 'https://example.com/file.csv' }, target: { type: 'search', indexName: 'pageviews', operation: 'replace' }, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('post postIngestUrl with all parameters', async () => { @@ -127,7 +127,7 @@ describe('postIngestUrl', () => { }, target: { type: 'search', indexName: 'pageviews', operation: 'replace' }, }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); From 97da10bb3d025b3cee98925699cdad4e1db228a2 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 13 Apr 2022 11:57:33 +0200 Subject: [PATCH 03/14] doc --- .../automation/testing/common-test-suite.md | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/website/docs/automation/testing/common-test-suite.md b/website/docs/automation/testing/common-test-suite.md index e04a44ccf1..54c12baa5d 100644 --- a/website/docs/automation/testing/common-test-suite.md +++ b/website/docs/automation/testing/common-test-suite.md @@ -25,7 +25,6 @@ The test generation script requires a JSON file name from the `operationId` (e.g [ { "testName": "the name of the test (e.g. test('search endpoint')) (default: 'method')", - "method": "the method to call (e.g. search)", "parameters": { "indexName": "testIndex", "searchParam": { @@ -34,22 +33,24 @@ The test generation script requires a JSON file name from the `operationId` (e.g "limit": 21, // data parameters "query": "the string to search" - } + }, + "otherParam": 22 }, "request": { "path": "/1/indexes/testIndex/query", "method": "POST", - "data": { "query": "the string to search" }, - "searchParams": { - "offset": "42", - "limit": "21" + "body": { "query": "the string to search" }, + "queryParameters": { + "otherParam": "22" } } } ] ``` -And that's it! If the name of the file matches a real `operationId` in the spec, then a test will be generated. +And that's it! If the name of the file matches a real `operationId` in the spec, then a test will be generated and will be calling the method name `operationId`. + +The list of `queryParameters` must match exactly the actual value, the CTS has to check the number of query parameters and the value of each. ## How to add a new language @@ -79,22 +80,41 @@ When writing your template, here is a list of variables accessible from `mustach "key": "key", "value": "value", // booleans indicating the data type - "isDate": "false", - "isArray": "false", - "isObject": "true", - "isString": "false", + "isArray": false, + "isObject": true, + "isFreeFormObject": false, + "isString": false, + "isInteger": false, + "isLong": false, + "isDouble": false, + "isEnum": false, + "isBoolean": false, + "objectName": "SearchParams", + // oneOfModel empty if there is no oneOf + "oneOfModel": { + "parentClassName": "SearchParams", + "type": "SearchParamsObject" + }, + // properties used to have unique name and link to parent + "parent": "theParentObject", + "suffix": 7, + "parentSuffix": 6, // boolean indicating if it is the last parameter - "-last": "false", + "-last": false, } ], // boolean indicating if the method has parameters, useful for `GET` requests - "hasParameters": "true", + "hasParameters": true, "request": { "path": "the expected path of the request", "method": "the expected method: GET, POST, PUT, DELETE or PATCH", - "data": { + "body": { // The expected body of the request } + "queryParameters": { + // key: string map + "parameterName": "stringify version of the value" + } } }] }] From 6390813976e3f1f490ccaa271c773577dc276cc7 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 13 Apr 2022 12:11:54 +0200 Subject: [PATCH 04/14] format --- generators/src/main/java/com/algolia/codegen/cts/Request.java | 1 + 1 file changed, 1 insertion(+) diff --git a/generators/src/main/java/com/algolia/codegen/cts/Request.java b/generators/src/main/java/com/algolia/codegen/cts/Request.java index 6f04044e00..a513749f2c 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/Request.java +++ b/generators/src/main/java/com/algolia/codegen/cts/Request.java @@ -10,6 +10,7 @@ import java.util.Map; public class Request { + public String testName; public Map parameters; From 5d032dec5092ccd88adf93b7d663e2a85e9ee851 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 14 Apr 2022 17:45:44 +0200 Subject: [PATCH 05/14] fix cts for custom request --- tests/CTS/methods/requests/common/del.json | 2 +- tests/CTS/methods/requests/common/get.json | 2 +- tests/CTS/methods/requests/common/post.json | 4 ++-- tests/CTS/methods/requests/common/put.json | 4 ++-- .../templates/javascript/requests.mustache | 2 +- .../src/methods/requests/abtesting.test.ts | 16 ++++++++-------- .../src/methods/requests/analytics.test.ts | 16 ++++++++-------- .../src/methods/requests/insights.test.ts | 16 ++++++++-------- .../src/methods/requests/personalization.test.ts | 16 ++++++++-------- .../methods/requests/query-suggestions.test.ts | 16 ++++++++-------- .../src/methods/requests/recommend.test.ts | 16 ++++++++-------- .../src/methods/requests/search.test.ts | 16 ++++++++-------- .../src/methods/requests/sources.test.ts | 16 ++++++++-------- 13 files changed, 71 insertions(+), 71 deletions(-) diff --git a/tests/CTS/methods/requests/common/del.json b/tests/CTS/methods/requests/common/del.json index fcb8830de1..d0c32c399b 100644 --- a/tests/CTS/methods/requests/common/del.json +++ b/tests/CTS/methods/requests/common/del.json @@ -22,7 +22,7 @@ "request": { "path": "/1/test/all", "method": "DELETE", - "searchParams": { + "queryParameters": { "query": "parameters" } } diff --git a/tests/CTS/methods/requests/common/get.json b/tests/CTS/methods/requests/common/get.json index 50834e8318..35056e57d2 100644 --- a/tests/CTS/methods/requests/common/get.json +++ b/tests/CTS/methods/requests/common/get.json @@ -22,7 +22,7 @@ "request": { "path": "/1/test/all", "method": "GET", - "searchParams": { + "queryParameters": { "query": "parameters" } } diff --git a/tests/CTS/methods/requests/common/post.json b/tests/CTS/methods/requests/common/post.json index 931b06b532..8a981c4414 100644 --- a/tests/CTS/methods/requests/common/post.json +++ b/tests/CTS/methods/requests/common/post.json @@ -25,10 +25,10 @@ "request": { "path": "/1/test/all", "method": "POST", - "data": { + "body": { "body": "parameters" }, - "searchParams": { + "queryParameters": { "query": "parameters" } } diff --git a/tests/CTS/methods/requests/common/put.json b/tests/CTS/methods/requests/common/put.json index dfffd8577a..6e88f94747 100644 --- a/tests/CTS/methods/requests/common/put.json +++ b/tests/CTS/methods/requests/common/put.json @@ -25,10 +25,10 @@ "request": { "path": "/1/test/all", "method": "PUT", - "data": { + "body": { "body": "parameters" }, - "searchParams": { + "queryParameters": { "query": "parameters" } } diff --git a/tests/CTS/methods/requests/templates/javascript/requests.mustache b/tests/CTS/methods/requests/templates/javascript/requests.mustache index 0d0c0ad195..fdd67a2650 100644 --- a/tests/CTS/methods/requests/templates/javascript/requests.mustache +++ b/tests/CTS/methods/requests/templates/javascript/requests.mustache @@ -16,7 +16,7 @@ describe('{{operationId}}', () => { expect(req.path).toEqual('{{{request.path}}}'); expect(req.method).toEqual('{{{request.method}}}'); expect(req.data).toEqual({{#request.body}}{{{.}}}{{/request.body}}{{^request.body}}undefined{{/request.body}}); - expect(req.searchParams).toStrictEqual({{#request.queryParameters}}{{{request.queryParameters}}}{{/request.queryParameters}}{{^request.queryParameters}}undefined{{/request.queryParameters}}); + expect(req.searchParams).toStrictEqual({{#request.queryParameters}}{{{.}}}{{/request.queryParameters}}{{^request.queryParameters}}undefined{{/request.queryParameters}}); }); {{/tests}} diff --git a/tests/output/javascript/src/methods/requests/abtesting.test.ts b/tests/output/javascript/src/methods/requests/abtesting.test.ts index 30ee990217..f918a095f6 100644 --- a/tests/output/javascript/src/methods/requests/abtesting.test.ts +++ b/tests/output/javascript/src/methods/requests/abtesting.test.ts @@ -43,7 +43,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -55,7 +55,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -81,7 +81,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -93,7 +93,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -131,7 +131,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -144,7 +144,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -157,7 +157,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -170,7 +170,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/javascript/src/methods/requests/analytics.test.ts b/tests/output/javascript/src/methods/requests/analytics.test.ts index d1bca4cbe6..ff5587e172 100644 --- a/tests/output/javascript/src/methods/requests/analytics.test.ts +++ b/tests/output/javascript/src/methods/requests/analytics.test.ts @@ -18,7 +18,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -30,7 +30,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -43,7 +43,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -55,7 +55,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -681,7 +681,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -694,7 +694,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -707,7 +707,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -720,6 +720,6 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/javascript/src/methods/requests/insights.test.ts b/tests/output/javascript/src/methods/requests/insights.test.ts index 14ce5768d5..dcd7cf924f 100644 --- a/tests/output/javascript/src/methods/requests/insights.test.ts +++ b/tests/output/javascript/src/methods/requests/insights.test.ts @@ -18,7 +18,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -30,7 +30,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -43,7 +43,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -55,7 +55,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -68,7 +68,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -81,7 +81,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -165,7 +165,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -178,6 +178,6 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/javascript/src/methods/requests/personalization.test.ts b/tests/output/javascript/src/methods/requests/personalization.test.ts index 86c84efd9e..4819322b85 100644 --- a/tests/output/javascript/src/methods/requests/personalization.test.ts +++ b/tests/output/javascript/src/methods/requests/personalization.test.ts @@ -18,7 +18,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -30,7 +30,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -56,7 +56,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -68,7 +68,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -106,7 +106,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -119,7 +119,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -132,7 +132,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -145,7 +145,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/javascript/src/methods/requests/query-suggestions.test.ts b/tests/output/javascript/src/methods/requests/query-suggestions.test.ts index 17716519a0..4443b49bd6 100644 --- a/tests/output/javascript/src/methods/requests/query-suggestions.test.ts +++ b/tests/output/javascript/src/methods/requests/query-suggestions.test.ts @@ -51,7 +51,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -63,7 +63,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -89,7 +89,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -101,7 +101,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -164,7 +164,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -177,7 +177,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -190,7 +190,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -203,7 +203,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/javascript/src/methods/requests/recommend.test.ts b/tests/output/javascript/src/methods/requests/recommend.test.ts index 6d81d12ec6..fef51037eb 100644 --- a/tests/output/javascript/src/methods/requests/recommend.test.ts +++ b/tests/output/javascript/src/methods/requests/recommend.test.ts @@ -16,7 +16,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -28,7 +28,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -41,7 +41,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -53,7 +53,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -297,7 +297,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -310,7 +310,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -323,7 +323,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -336,6 +336,6 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index 16c7d84765..22bffc9e40 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -322,7 +322,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -334,7 +334,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -442,7 +442,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -454,7 +454,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -823,7 +823,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -836,7 +836,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -849,7 +849,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -862,7 +862,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/javascript/src/methods/requests/sources.test.ts b/tests/output/javascript/src/methods/requests/sources.test.ts index 860e05ebe4..15ffecf317 100644 --- a/tests/output/javascript/src/methods/requests/sources.test.ts +++ b/tests/output/javascript/src/methods/requests/sources.test.ts @@ -18,7 +18,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow del method for a custom path with all parameters', async () => { @@ -30,7 +30,7 @@ describe('del', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -43,7 +43,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow get method for a custom path with all parameters', async () => { @@ -55,7 +55,7 @@ describe('get', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -68,7 +68,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow post method for a custom path with all parameters', async () => { @@ -81,7 +81,7 @@ describe('post', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); @@ -140,7 +140,7 @@ describe('put', () => { expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); test('allow put method for a custom path with all parameters', async () => { @@ -153,6 +153,6 @@ describe('put', () => { expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toStrictEqual({ query: 'parameters' }); }); }); From 6148133f47d45c3baac3f32cabd90c0e75ce683a Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 14 Apr 2022 18:16:11 +0200 Subject: [PATCH 06/14] damnit --- .../algolia/methods/requests/search.test.java | 821 +++++++++++++++++- 1 file changed, 813 insertions(+), 8 deletions(-) diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index c311f4757e..cf44191516 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -234,15 +234,724 @@ void assignUserIdTest0() { assertEquals(req.getPath(), "/1/clusters/mapping"); assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"cluster\":\"theCluster\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + params3.setFilters(filters4); + } + consequence2.setParams(params3); + } + rule_11.setConsequence(consequence2); + } + rule0.add(rule_11); + } - HashMap expectedQuery = JSON.deserialize("{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); + boolean forwardToReplicas0 = true; + + boolean clearExistingRules0 = true; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchRules( + indexName0, + rule0, + forwardToReplicas0, + clearExistingRules0 + ); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/batch"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "[{\"objectID\":\"a-rule-id\",\"conditions\":[{\"pattern\":\"smartphone\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"category:smartphone\"}}},{\"objectID\":\"a-second-rule-id\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}]", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"forwardToReplicas\":\"true\",\"clearExistingRules\":\"true\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("get browse results with minimal parameters") + void browseTest0() { + String indexName0 = "indexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.browse(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/browse"); + assertEquals(req.getMethod(), "POST"); + } + + @Test + @DisplayName("get browse results with all parameters") + void browseTest1() { + String indexName0 = "indexName"; + + BrowseRequest browseRequest0 = new BrowseRequest(); + { + String params1 = "query=foo&facetFilters=['bar']"; + + browseRequest0.setParams(params1); + String cursor1 = "cts"; + + browseRequest0.setCursor(cursor1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.browse(indexName0, browseRequest0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/browse"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("clearAllSynonyms") + void clearAllSynonymsTest0() { + String indexName0 = "indexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.clearAllSynonyms(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/clear"); + assertEquals(req.getMethod(), "POST"); + } + + @Test + @DisplayName("clearObjects") + void clearObjectsTest0() { + String indexName0 = "theIndexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.clearObjects(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/clear"); + assertEquals(req.getMethod(), "POST"); + } + + @Test + @DisplayName("clearRules") + void clearRulesTest0() { + String indexName0 = "indexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.clearRules(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/clear"); + assertEquals(req.getMethod(), "POST"); + } + + @Test + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + } + ); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; + + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; + + parameters0.put("query", query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0, parameters0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("deleteApiKey") + void deleteApiKeyTest0() { + String key0 = "myTestApiKey"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteApiKey(key0); + } + ); + + assertEquals(req.getPath(), "/1/keys/myTestApiKey"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("deleteBy") + void deleteByTest0() { + String indexName0 = "theIndexName"; + + SearchParamsObject searchParams0 = new SearchParamsObject(); + { + String query1 = "testQuery"; + + searchParams0.setQuery(query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteBy( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"testQuery\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("deleteIndex") + void deleteIndexTest0() { + String indexName0 = "theIndexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteIndex(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("deleteObject") + void deleteObjectTest0() { + String indexName0 = "theIndexName"; + + String objectID0 = "uniqueID"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteObject(indexName0, objectID0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("deleteRule") + void deleteRuleTest0() { + String indexName0 = "indexName"; + + String objectID0 = "id1"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteRule(indexName0, objectID0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("deleteSource") + void deleteSourceTest0() { + String source0 = "theSource"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteSource(source0); + } + ); + + assertEquals(req.getPath(), "/1/security/sources/theSource"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("deleteSynonym") + void deleteSynonymTest0() { + String indexName0 = "indexName"; + + String objectID0 = "id1"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteSynonym(indexName0, objectID0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; + + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; + + parameters0.put("query", query1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0, parameters0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("getApiKey") + void getApiKeyTest0() { + String key0 = "myTestApiKey"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getApiKey(key0); + } + ); + + assertEquals(req.getPath(), "/1/keys/myTestApiKey"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("get getDictionaryLanguages") + void getDictionaryLanguagesTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getDictionaryLanguages(); + } + ); + + assertEquals(req.getPath(), "/1/dictionaries/*/languages"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("get getDictionarySettings results") + void getDictionarySettingsTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getDictionarySettings(); + } + ); + + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getLogs") + void getLogsTest0() { + int offset0 = 5; + + int length0 = 10; + + String indexName0 = "theIndexName"; + + LogType type0 = LogType.fromValue("all"); + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getLogs(offset0, length0, indexName0, type0); + } + ); + + assertEquals(req.getPath(), "/1/logs"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("getObject") + void getObjectTest0() { + String indexName0 = "theIndexName"; + + String objectID0 = "uniqueID"; + + List attributesToRetrieve0 = new ArrayList<>(); + { + String attributesToRetrieve_01 = "attr1"; + + attributesToRetrieve0.add(attributesToRetrieve_01); + String attributesToRetrieve_11 = "attr2"; + + attributesToRetrieve0.add(attributesToRetrieve_11); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getObject(indexName0, objectID0, attributesToRetrieve0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"attributesToRetrieve\":\"attr1,attr2\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("getObjects") + void getObjectsTest0() { + GetObjectsParams getObjectsParams0 = new GetObjectsParams(); + { + List requests1 = new ArrayList<>(); + { + MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); + { + List attributesToRetrieve3 = new ArrayList<>(); + { + String attributesToRetrieve_04 = "attr1"; + + attributesToRetrieve3.add(attributesToRetrieve_04); + String attributesToRetrieve_14 = "attr2"; + + attributesToRetrieve3.add(attributesToRetrieve_14); + } + requests_02.setAttributesToRetrieve(attributesToRetrieve3); + String objectID3 = "uniqueID"; + + requests_02.setObjectID(objectID3); + String indexName3 = "theIndexName"; + + requests_02.setIndexName(indexName3); + } + requests1.add(requests_02); + } + getObjectsParams0.setRequests(requests1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getObjects(getObjectsParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/*/objects"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"attributesToRetrieve\":[\"attr1\",\"attr2\"],\"objectID\":\"uniqueID\",\"indexName\":\"theIndexName\"}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("getRule") + void getRuleTest0() { + String indexName0 = "indexName"; + + String objectID0 = "id1"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRule(indexName0, objectID0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getSettings") + void getSettingsTest0() { + String indexName0 = "theIndexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSettings(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getSources") + void getSourcesTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSources(); + } + ); + + assertEquals(req.getPath(), "/1/security/sources"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getSynonym") + void getSynonymTest0() { + String indexName0 = "indexName"; + + String objectID0 = "id1"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSynonym(indexName0, objectID0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getTask") + void getTaskTest0() { + String indexName0 = "theIndexName"; + + int taskID0 = 123; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTask(indexName0, taskID0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/task/123"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getTopUserIds") + void getTopUserIdsTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopUserIds(); + } + ); + + assertEquals(req.getPath(), "/1/clusters/mapping/top"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getUserId") + void getUserIdTest0() { + String userID0 = "uniqueID"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getUserId(userID0); + } + ); + + assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("hasPendingMappings") + void hasPendingMappingsTest0() { + boolean getClusters0 = true; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.hasPendingMappings(getClusters0); + } + ); + + assertEquals(req.getPath(), "/1/clusters/mapping/pending"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"getClusters\":\"true\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("listApiKeys") + void listApiKeysTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listApiKeys(); + } + ); + + assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("listClusters") + void listClustersTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listClusters(); + } + ); + + assertEquals(req.getPath(), "/1/clusters"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("listIndices") + void listIndicesTest0() { + int page0 = 8; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listIndices(page0); + } + ); + + assertEquals(req.getPath(), "/1/indexes"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"page\":\"8\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("listUserIds") + void listUserIdsTest0() { + int page0 = 8; + + int hitsPerPage0 = 100; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listUserIds(page0, hitsPerPage0); + } + ); + + assertEquals(req.getPath(), "/1/clusters/mapping"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"page\":\"8\",\"hitsPerPage\":\"100\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("multipleBatch") + void multipleBatchTest0() { + BatchParams batchParams0 = new BatchParams(); + { + List requests1 = new ArrayList<>(); + { + MultipleBatchOperation requests_02 = new MultipleBatchOperation(); + { + Action action3 = Action.fromValue("addObject"); + + requests_02.setAction(action3); + + Map body3 = new HashMap<>(); + { + String key4 = "value"; + + body3.put("key", key4); + } + requests_02.setBody(body3); + String indexName3 = "theIndexName"; + + requests_02.setIndexName(indexName3); } } @Test @@ -300,8 +1009,104 @@ void batchTest0() { + parameters0.put("query", query1); + } + + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0, parameters0, body0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + + @Test + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + } + @Test + @DisplayName("allow put method for a custom path with all parameters") + void putTest1() { + String path0 = "/test/all"; + + + parameters0.put("query", query1); + } + + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0, parameters0, body0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("removeUserId") + void removeUserIdTest0() { + String userID0 = "uniqueID"; body3.put("key", key4); }requests_02.setBody(body3); From 314a1f596012869d70363986cc304ce62ff17ad1 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 15 Apr 2022 13:15:56 +0200 Subject: [PATCH 07/14] fix merge --- .../java/com/algolia/codegen/cts/ParametersWithDataType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java b/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java index 73a08b18f3..149dae769d 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java +++ b/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java @@ -253,7 +253,7 @@ private void handleModel( HashMap oneOfModel = new HashMap<>(); String typeName = getTypeName(match).replace("<", "").replace(">", ""); - oneOfModel.put("classname", Utils.capitalize(baseType)); + oneOfModel.put("parentClassName", Utils.capitalize(baseType)); if (typeName.equals("List")) { CodegenProperty items = match.getItems(); @@ -265,7 +265,7 @@ private void handleModel( typeName += getTypeName(items); } - oneOfModel.put("name", typeName); + oneOfModel.put("type", typeName); testOutput.put("oneOfModel", oneOfModel); return; From 96ac826d6addae6444495d08006c270a9b8c043d Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 15 Apr 2022 14:03:35 +0200 Subject: [PATCH 08/14] regen for custom request --- .../methods/requests/abtesting.test.java | 733 ++- .../methods/requests/analytics.test.java | 862 ++-- .../methods/requests/insights.test.java | 173 +- .../requests/personalization.test.java | 205 +- .../requests/query-suggestions.test.java | 243 +- .../methods/requests/recommend.test.java | 1842 +++---- .../algolia/methods/requests/search.test.java | 4509 +++++------------ 7 files changed, 3058 insertions(+), 5509 deletions(-) diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java index 96fdf1b9d7..b739f72cbc 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java @@ -1,494 +1,365 @@ package com.algolia.methods.requests; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import java.util.*; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.BeforeAll; -import com.google.gson.reflect.TypeToken; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.algolia.JSON; import com.algolia.Pair; -import com.algolia.model.abtesting.*; import com.algolia.api.AbtestingClient; +import com.algolia.model.abtesting.*; import com.algolia.utils.echo.*; +import com.google.gson.reflect.TypeToken; +import java.util.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class AbtestingClientTests { - private AbtestingClient client; - - @BeforeAll - void init() { - client = new AbtestingClient("appId", "apiKey", new EchoRequester()); - } - - @Test - @DisplayName("addABTests with minimal parameters") - void addABTestsTest0() { - - - - - - - -AddABTestsRequest addABTestsRequest0 = new AddABTestsRequest(); -{ String endAt1 = "2022-12-31T00:00:00.000Z"; - - - - - - -addABTestsRequest0.setEndAt(endAt1); -String name1 = "myABTest"; - - - - - - -addABTestsRequest0.setName(name1); - - - - - - -List< -> - variant1 = new ArrayList<>(); { - - - - - - -AbTestsVariant variant_02 = new AbTestsVariant(); -{ String index3 = "AB_TEST_1"; - - - - - - -variant_02.setIndex(index3); - -int trafficPercentage3 = 30; - - - - - -variant_02.setTrafficPercentage(trafficPercentage3); - }variant1.add(.of(variant_02)); - - + private AbtestingClient client; + @BeforeAll + void init() { + client = new AbtestingClient("appId", "apiKey", new EchoRequester()); + } + @Test + @DisplayName("addABTests with minimal parameters") + void addABTestsTest0() { + AddABTestsRequest addABTestsRequest0 = new AddABTestsRequest(); + { + String endAt1 = "2022-12-31T00:00:00.000Z"; -AbTestsVariant variant_12 = new AbTestsVariant(); -{ String index3 = "AB_TEST_2"; + addABTestsRequest0.setEndAt(endAt1); + String name1 = "myABTest"; + addABTestsRequest0.setName(name1); + List variant1 = new ArrayList<>(); + { + AbTestsVariant variant_02 = new AbTestsVariant(); + { + String index3 = "AB_TEST_1"; + variant_02.setIndex(index3); + int trafficPercentage3 = 30; + variant_02.setTrafficPercentage(trafficPercentage3); + } + variant1.add(AddABTestsVariant.ofAbTestsVariant(variant_02)); -variant_12.setIndex(index3); - -int trafficPercentage3 = 50; - - - - - -variant_12.setTrafficPercentage(trafficPercentage3); - }variant1.add(.of(variant_12)); } -addABTestsRequest0.setVariant(variant1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addABTests(addABTestsRequest0); - }); + AbTestsVariant variant_12 = new AbTestsVariant(); + { + String index3 = "AB_TEST_2"; - assertEquals(req.getPath(), "/2/abtests"); - assertEquals(req.getMethod(), "POST"); + variant_12.setIndex(index3); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + int trafficPercentage3 = 50; + variant_12.setTrafficPercentage(trafficPercentage3); + } + variant1.add(AddABTestsVariant.ofAbTestsVariant(variant_12)); + } + addABTestsRequest0.setVariant(variant1); } - @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.addABTests(addABTestsRequest0); + } + ); + + assertEquals(req.getPath(), "/2/abtests"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + } + ); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; + + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; + + parameters0.put("query", query1); } - @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0,parameters0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0, parameters0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - @Test - @DisplayName("deleteABTest") - void deleteABTestTest0() { - -int id0 = 42; - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteABTest(id0); - }); - - assertEquals(req.getPath(), "/2/abtests/42"); - assertEquals(req.getMethod(), "DELETE"); - - + } + + @Test + @DisplayName("deleteABTest") + void deleteABTestTest0() { + int id0 = 42; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteABTest(id0); + } + ); + + assertEquals(req.getPath(), "/2/abtests/42"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; + + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; + + parameters0.put("query", query1); } - @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0, parameters0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0,parameters0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); - - + } + + @Test + @DisplayName("getABTest") + void getABTestTest0() { + int id0 = 42; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getABTest(id0); + } + ); + + assertEquals(req.getPath(), "/2/abtests/42"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("listABTests with minimal parameters") + void listABTestsTest0() { + int offset0 = 42; + + int limit0 = 21; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.listABTests(offset0, limit0); + } + ); + + assertEquals(req.getPath(), "/2/abtests"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"offset\":\"42\",\"limit\":\"21\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - @Test - @DisplayName("getABTest") - void getABTestTest0() { - -int id0 = 42; - + } + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + } + ); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "POST"); + } + @Test + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { + String path0 = "/test/all"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getABTest(id0); - }); - - assertEquals(req.getPath(), "/2/abtests/42"); - assertEquals(req.getMethod(), "GET"); - - + parameters0.put("query", query1); } - @Test - @DisplayName("listABTests with minimal parameters") - void listABTestsTest0() { - -int offset0 = 42; - - - - - - -int limit0 = 21; - - - + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listABTests(offset0,limit0); - }); - - assertEquals(req.getPath(), "/2/abtests"); - assertEquals(req.getMethod(), "GET"); - - - HashMap expectedQuery = JSON.deserialize("{\"offset\":\"42\",\"limit\":\"21\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } + body0.put("body", body1); } - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0, parameters0, body0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - + } + @Test + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); -parameters0.put("query", query1); - } + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + } + @Test + @DisplayName("allow put method for a custom path with all parameters") + void putTest1() { + String path0 = "/test/all"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; - - - -Map body0 = new HashMap<>(); -{ String body1 = "parameters"; - - - - - - -body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0,parameters0,body0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - + parameters0.put("query", query1); } - @Test - @DisplayName("allow put method for a custom path with minimal parameters") - void putTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "PUT"); + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + body0.put("body", body1); } - @Test - @DisplayName("allow put method for a custom path with all parameters") - void putTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - - - - - -Map body0 = new HashMap<>(); -{ String body1 = "parameters"; - - - - - - -body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0,parameters0,body0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0, parameters0, body0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - @Test - @DisplayName("stopABTest") - void stopABTestTest0() { - -int id0 = 42; + } + @Test + @DisplayName("stopABTest") + void stopABTestTest0() { + int id0 = 42; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.stopABTest(id0); + } + ); - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.stopABTest(id0); - }); - - assertEquals(req.getPath(), "/2/abtests/42/stop"); - assertEquals(req.getMethod(), "POST"); - - - } + assertEquals(req.getPath(), "/2/abtests/42/stop"); + assertEquals(req.getMethod(), "POST"); + } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java index 0b27bae702..1e2f95e300 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java @@ -14,9 +14,12 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class AnalyticsClientTests { + private AnalyticsClient client; @BeforeAll @@ -29,12 +32,10 @@ void init() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -52,15 +53,23 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -68,12 +77,10 @@ void delTest1() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -91,15 +98,23 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -107,19 +122,18 @@ void getTest1() { void getAverageClickPositionTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getAverageClickPosition(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getAverageClickPosition(index0); + } + ); assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -138,20 +152,23 @@ void getAverageClickPositionTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getAverageClickPosition(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getAverageClickPosition( + index0, + startDate0, + endDate0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -164,19 +181,18 @@ void getAverageClickPositionTest1() { void getClickPositionsTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getClickPositions(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getClickPositions(index0); + } + ); assertEquals(req.getPath(), "/2/clicks/positions"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -195,20 +211,18 @@ void getClickPositionsTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getClickPositions(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getClickPositions(index0, startDate0, endDate0, tags0); + } + ); assertEquals(req.getPath(), "/2/clicks/positions"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -221,19 +235,18 @@ void getClickPositionsTest1() { void getClickThroughRateTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getClickThroughRate(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getClickThroughRate(index0); + } + ); assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -252,20 +265,18 @@ void getClickThroughRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getClickThroughRate(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getClickThroughRate(index0, startDate0, endDate0, tags0); + } + ); assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -278,19 +289,18 @@ void getClickThroughRateTest1() { void getConversationRateTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getConversationRate(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getConversationRate(index0); + } + ); assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -309,20 +319,18 @@ void getConversationRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getConversationRate(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getConversationRate(index0, startDate0, endDate0, tags0); + } + ); assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -335,19 +343,18 @@ void getConversationRateTest1() { void getNoClickRateTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getNoClickRate(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getNoClickRate(index0); + } + ); assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -366,20 +373,18 @@ void getNoClickRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getNoClickRate(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getNoClickRate(index0, startDate0, endDate0, tags0); + } + ); assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -392,19 +397,18 @@ void getNoClickRateTest1() { void getNoResultsRateTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getNoResultsRate(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getNoResultsRate(index0); + } + ); assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -423,20 +427,18 @@ void getNoResultsRateTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getNoResultsRate(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getNoResultsRate(index0, startDate0, endDate0, tags0); + } + ); assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -449,19 +451,18 @@ void getNoResultsRateTest1() { void getSearchesCountTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getSearchesCount(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSearchesCount(index0); + } + ); assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -480,20 +481,18 @@ void getSearchesCountTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getSearchesCount(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSearchesCount(index0, startDate0, endDate0, tags0); + } + ); assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -506,19 +505,18 @@ void getSearchesCountTest1() { void getSearchesNoClicksTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getSearchesNoClicks(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSearchesNoClicks(index0); + } + ); assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -541,21 +539,25 @@ void getSearchesNoClicksTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getSearchesNoClicks( - index0, startDate0, endDate0, limit0, offset0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSearchesNoClicks( + index0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -568,19 +570,18 @@ void getSearchesNoClicksTest1() { void getSearchesNoResultsTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getSearchesNoResults(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSearchesNoResults(index0); + } + ); assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -603,21 +604,25 @@ void getSearchesNoResultsTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getSearchesNoResults( - index0, startDate0, endDate0, limit0, offset0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSearchesNoResults( + index0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -630,19 +635,18 @@ void getSearchesNoResultsTest1() { void getStatusTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getStatus(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getStatus(index0); + } + ); assertEquals(req.getPath(), "/2/status"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -655,19 +659,18 @@ void getStatusTest0() { void getTopCountriesTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopCountries(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopCountries(index0); + } + ); assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -690,21 +693,25 @@ void getTopCountriesTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopCountries( - index0, startDate0, endDate0, limit0, offset0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopCountries( + index0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -717,19 +724,18 @@ void getTopCountriesTest1() { void getTopFilterAttributesTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFilterAttributes(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFilterAttributes(index0); + } + ); assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -754,21 +760,26 @@ void getTopFilterAttributesTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFilterAttributes( - index0, search0, startDate0, endDate0, limit0, offset0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFilterAttributes( + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -783,19 +794,18 @@ void getTopFilterForAttributeTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFilterForAttribute(attribute0, index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFilterForAttribute(attribute0, index0); + } + ); assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -804,25 +814,26 @@ void getTopFilterForAttributeTest0() { } @Test - @DisplayName("get getTopFilterForAttribute with minimal parameters and multiple attributes") + @DisplayName( + "get getTopFilterForAttribute with minimal parameters and multiple attributes" + ) void getTopFilterForAttributeTest1() { String attribute0 = "myAttribute1,myAttribute2"; String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFilterForAttribute(attribute0, index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFilterForAttribute(attribute0, index0); + } + ); assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -849,21 +860,27 @@ void getTopFilterForAttributeTest2() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFilterForAttribute( - attribute0, index0, search0, startDate0, endDate0, limit0, offset0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFilterForAttribute( + attribute0, + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -872,7 +889,9 @@ void getTopFilterForAttributeTest2() { } @Test - @DisplayName("get getTopFilterForAttribute with all parameters and multiple attributes") + @DisplayName( + "get getTopFilterForAttribute with all parameters and multiple attributes" + ) void getTopFilterForAttributeTest3() { String attribute0 = "myAttribute1,myAttribute2"; @@ -890,21 +909,27 @@ void getTopFilterForAttributeTest3() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFilterForAttribute( - attribute0, index0, search0, startDate0, endDate0, limit0, offset0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFilterForAttribute( + attribute0, + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -917,19 +942,18 @@ void getTopFilterForAttributeTest3() { void getTopFiltersNoResultsTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFiltersNoResults(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFiltersNoResults(index0); + } + ); assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -954,21 +978,26 @@ void getTopFiltersNoResultsTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopFiltersNoResults( - index0, search0, startDate0, endDate0, limit0, offset0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopFiltersNoResults( + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -981,19 +1010,18 @@ void getTopFiltersNoResultsTest1() { void getTopHitsTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopHits(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopHits(index0); + } + ); assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -1020,28 +1048,27 @@ void getTopHitsTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopHits( - index0, - search0, - clickAnalytics0, - startDate0, - endDate0, - limit0, - offset0, - tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopHits( + index0, + search0, + clickAnalytics0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -1054,19 +1081,18 @@ void getTopHitsTest1() { void getTopSearchesTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopSearches(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopSearches(index0); + } + ); assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -1095,29 +1121,28 @@ void getTopSearchesTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getTopSearches( - index0, - clickAnalytics0, - startDate0, - endDate0, - orderBy0, - direction0, - limit0, - offset0, - tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopSearches( + index0, + clickAnalytics0, + startDate0, + endDate0, + orderBy0, + direction0, + limit0, + offset0, + tags0 + ); + } + ); assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -1130,19 +1155,18 @@ void getTopSearchesTest1() { void getUsersCountTest0() { String index0 = "index"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getUsersCount(index0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getUsersCount(index0); + } + ); assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\"}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -1161,20 +1185,18 @@ void getUsersCountTest1() { String tags0 = "tag"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getUsersCount(index0, startDate0, endDate0, tags0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getUsersCount(index0, startDate0, endDate0, tags0); + } + ); assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = - JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", - new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + new TypeToken>() {}.getType() + ); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { @@ -1187,12 +1209,10 @@ void getUsersCountTest1() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -1217,15 +1237,31 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -1233,12 +1269,10 @@ void postTest1() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -1263,14 +1297,30 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java index 427b8407e0..5f8fa2bba0 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java @@ -3,9 +3,12 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; +import com.algolia.JSON; +import com.algolia.Pair; import com.algolia.api.InsightsClient; import com.algolia.model.insights.*; import com.algolia.utils.echo.*; +import com.google.gson.reflect.TypeToken; import java.util.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -16,6 +19,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class InsightsClientTests { + private InsightsClient client; @BeforeAll @@ -28,12 +32,10 @@ void init() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -51,15 +53,23 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -67,12 +77,10 @@ void delTest1() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -90,15 +98,23 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -106,12 +122,10 @@ void getTest1() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -136,21 +150,36 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @DisplayName("pushEvents") void pushEventsTest0() { - InsightEvents insightEvents0 = new InsightEvents(); { List events1 = new ArrayList<>(); @@ -271,27 +300,25 @@ void pushEventsTest0() { insightEvents0.setEvents(events1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.pushEvents(insightEvents0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.pushEvents(insightEvents0); + } + ); assertEquals(req.getPath(), "/1/events"); assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow( - () -> { - JSONAssert.assertEquals( - "{\"events\":[{\"eventType\":\"click\",\"eventName\":\"Product" - + " Clicked\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\",\"positions\":[7,6]},{\"eventType\":\"view\",\"eventName\":\"Product" - + " Detail Page" - + " Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]},{\"eventType\":\"conversion\",\"eventName\":\"Product" - + " Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"}]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER); - }); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"events\":[{\"eventType\":\"click\",\"eventName\":\"Product" + + " Clicked\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\",\"positions\":[7,6]},{\"eventType\":\"view\",\"eventName\":\"Product" + + " Detail Page" + + " Viewed\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"]},{\"eventType\":\"conversion\",\"eventName\":\"Product" + + " Purchased\",\"index\":\"products\",\"userToken\":\"user-123456\",\"timestamp\":1641290601962,\"objectIDs\":[\"9780545139700\",\"9780439784542\"],\"queryID\":\"43b15df305339e827f0ac0bdc5ebcaa7\"}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test @@ -299,12 +326,10 @@ void pushEventsTest0() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -329,14 +354,30 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java index bc235fe93f..98902b41a3 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java @@ -3,9 +3,12 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; +import com.algolia.JSON; +import com.algolia.Pair; import com.algolia.api.PersonalizationClient; import com.algolia.model.personalization.*; import com.algolia.utils.echo.*; +import com.google.gson.reflect.TypeToken; import java.util.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -16,6 +19,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class PersonalizationClientTests { + private PersonalizationClient client; @BeforeAll @@ -28,12 +32,10 @@ void init() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -51,15 +53,23 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -67,12 +77,10 @@ void delTest1() { void deleteUserProfileTest0() { String userToken0 = "UserToken"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.deleteUserProfile(userToken0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteUserProfile(userToken0); + } + ); assertEquals(req.getPath(), "/1/profiles/UserToken"); assertEquals(req.getMethod(), "DELETE"); @@ -83,12 +91,10 @@ void deleteUserProfileTest0() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -106,27 +112,32 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @DisplayName("get getPersonalizationStrategy") void getPersonalizationStrategyTest0() { - - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getPersonalizationStrategy(); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getPersonalizationStrategy(); + } + ); assertEquals(req.getPath(), "/1/strategies/personalization"); assertEquals(req.getMethod(), "GET"); @@ -137,12 +148,10 @@ void getPersonalizationStrategyTest0() { void getUserTokenProfileTest0() { String userToken0 = "UserToken"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getUserTokenProfile(userToken0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getUserTokenProfile(userToken0); + } + ); assertEquals(req.getPath(), "/1/profiles/personalization/UserToken"); assertEquals(req.getMethod(), "GET"); @@ -153,12 +162,10 @@ void getUserTokenProfileTest0() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -183,15 +190,31 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -199,12 +222,10 @@ void postTest1() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -229,23 +250,37 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @DisplayName("set setPersonalizationStrategy") void setPersonalizationStrategyTest0() { - - PersonalizationStrategyParams personalizationStrategyParams0 = - new PersonalizationStrategyParams(); + PersonalizationStrategyParams personalizationStrategyParams0 = new PersonalizationStrategyParams(); { List eventScoring1 = new ArrayList<>(); { @@ -282,25 +317,27 @@ void setPersonalizationStrategyTest0() { int personalizationImpact1 = 42; - personalizationStrategyParams0.setPersonalizationImpact(personalizationImpact1); + personalizationStrategyParams0.setPersonalizationImpact( + personalizationImpact1 + ); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.setPersonalizationStrategy(personalizationStrategyParams0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.setPersonalizationStrategy( + personalizationStrategyParams0 + ); + } + ); assertEquals(req.getPath(), "/1/strategies/personalization"); assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow( - () -> { - JSONAssert.assertEquals( - "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}", - req.getBody(), - JSONCompareMode.STRICT_ORDER); - }); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java index 540ad6ceda..127fb56aa5 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java @@ -3,9 +3,12 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; +import com.algolia.JSON; +import com.algolia.Pair; import com.algolia.api.QuerySuggestionsClient; import com.algolia.model.querySuggestions.*; import com.algolia.utils.echo.*; +import com.google.gson.reflect.TypeToken; import java.util.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -16,6 +19,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class QuerySuggestionsClientTests { + private QuerySuggestionsClient client; @BeforeAll @@ -26,9 +30,7 @@ void init() { @Test @DisplayName("createConfig") void createConfigTest0() { - - QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = - new QuerySuggestionsIndexWithIndexParam(); + QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = new QuerySuggestionsIndexWithIndexParam(); { String indexName1 = "theIndexName"; @@ -98,23 +100,21 @@ void createConfigTest0() { querySuggestionsIndexWithIndexParam0.setExclude(exclude1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.createConfig(querySuggestionsIndexWithIndexParam0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.createConfig(querySuggestionsIndexWithIndexParam0); + } + ); assertEquals(req.getPath(), "/1/configs"); assertEquals(req.getMethod(), "POST"); - assertDoesNotThrow( - () -> { - JSONAssert.assertEquals( - "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER); - }); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test @@ -122,12 +122,10 @@ void createConfigTest0() { void delTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "DELETE"); @@ -145,15 +143,23 @@ void delTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.del(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -161,12 +167,10 @@ void delTest1() { void deleteConfigTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.deleteConfig(indexName0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteConfig(indexName0); + } + ); assertEquals(req.getPath(), "/1/configs/theIndexName"); assertEquals(req.getMethod(), "DELETE"); @@ -177,12 +181,10 @@ void deleteConfigTest0() { void getTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "GET"); @@ -200,27 +202,32 @@ void getTest1() { parameters0.put("query", query1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.get(path0, parameters0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0, parameters0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @DisplayName("getAllConfigs") void getAllConfigsTest0() { - - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getAllConfigs(); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getAllConfigs(); + } + ); assertEquals(req.getPath(), "/1/configs"); assertEquals(req.getMethod(), "GET"); @@ -231,12 +238,10 @@ void getAllConfigsTest0() { void getConfigTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getConfig(indexName0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getConfig(indexName0); + } + ); assertEquals(req.getPath(), "/1/configs/theIndexName"); assertEquals(req.getMethod(), "GET"); @@ -247,12 +252,10 @@ void getConfigTest0() { void getConfigStatusTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getConfigStatus(indexName0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getConfigStatus(indexName0); + } + ); assertEquals(req.getPath(), "/1/configs/theIndexName/status"); assertEquals(req.getMethod(), "GET"); @@ -263,12 +266,10 @@ void getConfigStatusTest0() { void getLogFileTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.getLogFile(indexName0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getLogFile(indexName0); + } + ); assertEquals(req.getPath(), "/1/logs/theIndexName"); assertEquals(req.getMethod(), "GET"); @@ -279,12 +280,10 @@ void getLogFileTest0() { void postTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "POST"); @@ -309,15 +308,31 @@ void postTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.post(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -325,12 +340,10 @@ void postTest1() { void putTest0() { String path0 = "/test/minimal"; - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); assertEquals(req.getPath(), "/1/test/minimal"); assertEquals(req.getMethod(), "PUT"); @@ -355,15 +368,31 @@ void putTest1() { body0.put("body", body1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.put(path0, parameters0, body0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0, parameters0, body0); + } + ); assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } } @Test @@ -437,22 +466,20 @@ void updateConfigTest0() { querySuggestionsIndexParam0.setExclude(exclude1); } - EchoResponseInterface req = - (EchoResponseInterface) - assertDoesNotThrow( - () -> { - return client.updateConfig(indexName0, querySuggestionsIndexParam0); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.updateConfig(indexName0, querySuggestionsIndexParam0); + } + ); assertEquals(req.getPath(), "/1/configs/theIndexName"); assertEquals(req.getMethod(), "PUT"); - assertDoesNotThrow( - () -> { - JSONAssert.assertEquals( - "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", - req.getBody(), - JSONCompareMode.STRICT_ORDER); - }); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java index d3f05a9814..d0b02fbb71 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java @@ -1,1207 +1,789 @@ package com.algolia.methods.requests; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import java.util.*; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.BeforeAll; -import com.google.gson.reflect.TypeToken; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.algolia.JSON; import com.algolia.Pair; -import com.algolia.model.recommend.*; import com.algolia.api.RecommendClient; +import com.algolia.model.recommend.*; import com.algolia.utils.echo.*; +import com.google.gson.reflect.TypeToken; +import java.util.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class RecommendClientTests { - private RecommendClient client; - - @BeforeAll - void init() { - client = new RecommendClient("appId", "apiKey", new EchoRequester()); - } - - @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; - - - + private RecommendClient client; + @BeforeAll + void init() { + client = new RecommendClient("appId", "apiKey", new EchoRequester()); + } + @Test + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0); + } + ); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - }); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); + } - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + @Test + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; + parameters0.put("query", query1); } - @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0,parameters0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.del(path0, parameters0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; - - + } + @Test + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + } + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - - + parameters0.put("query", query1); } - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0,parameters0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0, parameters0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "GET"); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } - @Test - @DisplayName("get recommendations for recommend model with minimal parameters") - void getRecommendationsTest0() { - - - - - - - -GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); -{ - - - - - -List< -> - requests1 = new ArrayList<>(); { - - - - - - -RecommendationRequest requests_02 = new RecommendationRequest(); -{ String indexName3 = "indexName"; - - - - - - -requests_02.setIndexName(indexName3); -String objectID3 = "objectID"; - - - - - - -requests_02.setObjectID(objectID3); - - - - - -RecommendationModels model3 = RecommendationModels.fromValue("related-products"); - -requests_02.setModel(model3); - -int threshold3 = 42; - - - - - -requests_02.setThreshold(threshold3); - }requests1.add(.of(requests_02)); } -getRecommendationsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - + } + + @Test + @DisplayName( + "get recommendations for recommend model with minimal parameters" + ) + void getRecommendationsTest0() { + GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); + { + List requests1 = new ArrayList<>(); + { + RecommendationRequest requests_02 = new RecommendationRequest(); + { + String indexName3 = "indexName"; + + requests_02.setIndexName(indexName3); + String objectID3 = "objectID"; + + requests_02.setObjectID(objectID3); + + RecommendationModels model3 = RecommendationModels.fromValue( + "related-products" + ); + + requests_02.setModel(model3); + + int threshold3 = 42; + + requests_02.setThreshold(threshold3); + } + requests1.add( + RecommendationsRequest.ofRecommendationRequest(requests_02) + ); + } + getRecommendationsParams0.setRequests(requests1); } - @Test - @DisplayName("get recommendations for recommend model with all parameters") - void getRecommendationsTest1() { - - - - - - - -GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); -{ - - - - - -List< -> - requests1 = new ArrayList<>(); { - - - - - - -RecommendationRequest requests_02 = new RecommendationRequest(); -{ String indexName3 = "indexName"; - - - - - - -requests_02.setIndexName(indexName3); -String objectID3 = "objectID"; - - - - - - -requests_02.setObjectID(objectID3); - - - - - -RecommendationModels model3 = RecommendationModels.fromValue("related-products"); - -requests_02.setModel(model3); - -int threshold3 = 42; - - - - - -requests_02.setThreshold(threshold3); - -int maxRecommendations3 = 10; - - - - - -requests_02.setMaxRecommendations(maxRecommendations3); - - - - - - - -SearchParamsObject queryParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -queryParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query"; - - - - - - -facetFilters4.add(facetFilters_05); } -queryParameters3.setFacetFilters(.of(facetFilters4)); - }requests_02.setQueryParameters(queryParameters3); - - - - - - - -SearchParamsObject fallbackParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -fallbackParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback"; - - - - - - -facetFilters4.add(facetFilters_05); } -fallbackParameters3.setFacetFilters(.of(facetFilters4)); - }requests_02.setFallbackParameters(fallbackParameters3); - }requests1.add(.of(requests_02)); } -getRecommendationsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("get recommendations for recommend model with all parameters") + void getRecommendationsTest1() { + GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); + { + List requests1 = new ArrayList<>(); + { + RecommendationRequest requests_02 = new RecommendationRequest(); + { + String indexName3 = "indexName"; + + requests_02.setIndexName(indexName3); + String objectID3 = "objectID"; + + requests_02.setObjectID(objectID3); + + RecommendationModels model3 = RecommendationModels.fromValue( + "related-products" + ); + + requests_02.setModel(model3); + + int threshold3 = 42; + + requests_02.setThreshold(threshold3); + + int maxRecommendations3 = 10; + + requests_02.setMaxRecommendations(maxRecommendations3); + + SearchParamsObject queryParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; + + queryParameters3.setQuery(query4); + + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "query"; + + facetFilters4.add(facetFilters_05); + } + queryParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_02.setQueryParameters(queryParameters3); + + SearchParamsObject fallbackParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; + + fallbackParameters3.setQuery(query4); + + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "fallback"; + + facetFilters4.add(facetFilters_05); + } + fallbackParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_02.setFallbackParameters(fallbackParameters3); + } + requests1.add( + RecommendationsRequest.ofRecommendationRequest(requests_02) + ); + } + getRecommendationsParams0.setRequests(requests1); } - @Test - @DisplayName("get recommendations for trending model with minimal parameters") - void getRecommendationsTest2() { - - - - - - - -GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); -{ + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"indexName\",\"objectID\":\"objectID\",\"model\":\"related-products\",\"threshold\":42,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("get recommendations for trending model with minimal parameters") + void getRecommendationsTest2() { + GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); + { + List requests1 = new ArrayList<>(); + { + TrendingRequest requests_02 = new TrendingRequest(); + { + String indexName3 = "indexName"; + + requests_02.setIndexName(indexName3); + + TrendingModels model3 = TrendingModels.fromValue("trending-items"); + + requests_02.setModel(model3); + + int threshold3 = 42; + + requests_02.setThreshold(threshold3); + } + requests1.add(RecommendationsRequest.ofTrendingRequest(requests_02)); + } + getRecommendationsParams0.setRequests(requests1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("get recommendations for trending model with all parameters") + void getRecommendationsTest3() { + GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); + { + List requests1 = new ArrayList<>(); + { + TrendingRequest requests_02 = new TrendingRequest(); + { + String indexName3 = "indexName"; + + requests_02.setIndexName(indexName3); + + TrendingModels model3 = TrendingModels.fromValue("trending-items"); + + requests_02.setModel(model3); + + int threshold3 = 42; + + requests_02.setThreshold(threshold3); + + int maxRecommendations3 = 10; + + requests_02.setMaxRecommendations(maxRecommendations3); + String facetName3 = "myFacetName"; + + requests_02.setFacetName(facetName3); + String facetValue3 = "myFacetValue"; + + requests_02.setFacetValue(facetValue3); + + SearchParamsObject queryParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; + + queryParameters3.setQuery(query4); + + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "query"; + + facetFilters4.add(facetFilters_05); + } + queryParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_02.setQueryParameters(queryParameters3); + + SearchParamsObject fallbackParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; + + fallbackParameters3.setQuery(query4); + + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "fallback"; + + facetFilters4.add(facetFilters_05); + } + fallbackParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_02.setFallbackParameters(fallbackParameters3); + } + requests1.add(RecommendationsRequest.ofTrendingRequest(requests_02)); + } + getRecommendationsParams0.setRequests(requests1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42,\"maxRecommendations\":10,\"facetName\":\"myFacetName\",\"facetValue\":\"myFacetValue\",\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("get multiple recommendations with minimal parameters") + void getRecommendationsTest4() { + GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); + { + List requests1 = new ArrayList<>(); + { + RecommendationRequest requests_02 = new RecommendationRequest(); + { + String indexName3 = "indexName1"; + + requests_02.setIndexName(indexName3); + String objectID3 = "objectID1"; + + requests_02.setObjectID(objectID3); + + RecommendationModels model3 = RecommendationModels.fromValue( + "related-products" + ); + + requests_02.setModel(model3); + + int threshold3 = 21; + + requests_02.setThreshold(threshold3); + } + requests1.add( + RecommendationsRequest.ofRecommendationRequest(requests_02) + ); + + RecommendationRequest requests_12 = new RecommendationRequest(); + { + String indexName3 = "indexName2"; + + requests_12.setIndexName(indexName3); + String objectID3 = "objectID2"; + + requests_12.setObjectID(objectID3); + + RecommendationModels model3 = RecommendationModels.fromValue( + "related-products" + ); + + requests_12.setModel(model3); + + int threshold3 = 21; + + requests_12.setThreshold(threshold3); + } + requests1.add( + RecommendationsRequest.ofRecommendationRequest(requests_12) + ); + } + getRecommendationsParams0.setRequests(requests1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + } + ); -List< -> - requests1 = new ArrayList<>(); { - - - - - - -TrendingRequest requests_02 = new TrendingRequest(); -{ String indexName3 = "indexName"; - - - - + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } -requests_02.setIndexName(indexName3); + @Test + @DisplayName("get multiple recommendations with all parameters") + void getRecommendationsTest5() { + GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); + { + List requests1 = new ArrayList<>(); + { + RecommendationRequest requests_02 = new RecommendationRequest(); + { + String indexName3 = "indexName1"; + requests_02.setIndexName(indexName3); + String objectID3 = "objectID1"; + requests_02.setObjectID(objectID3); + RecommendationModels model3 = RecommendationModels.fromValue( + "related-products" + ); + requests_02.setModel(model3); -TrendingModels model3 = TrendingModels.fromValue("trending-items"); + int threshold3 = 21; -requests_02.setModel(model3); + requests_02.setThreshold(threshold3); -int threshold3 = 42; + int maxRecommendations3 = 10; + requests_02.setMaxRecommendations(maxRecommendations3); + SearchParamsObject queryParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; + + queryParameters3.setQuery(query4); + + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "query1"; + + facetFilters4.add(facetFilters_05); + } + queryParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_02.setQueryParameters(queryParameters3); + + SearchParamsObject fallbackParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; + + fallbackParameters3.setQuery(query4); + + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "fallback1"; + + facetFilters4.add(facetFilters_05); + } + fallbackParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_02.setFallbackParameters(fallbackParameters3); + } + requests1.add( + RecommendationsRequest.ofRecommendationRequest(requests_02) + ); + + RecommendationRequest requests_12 = new RecommendationRequest(); + { + String indexName3 = "indexName2"; + + requests_12.setIndexName(indexName3); + String objectID3 = "objectID2"; + + requests_12.setObjectID(objectID3); + + RecommendationModels model3 = RecommendationModels.fromValue( + "related-products" + ); + + requests_12.setModel(model3); + + int threshold3 = 21; + + requests_12.setThreshold(threshold3); + + int maxRecommendations3 = 10; + + requests_12.setMaxRecommendations(maxRecommendations3); + + SearchParamsObject queryParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; + queryParameters3.setQuery(query4); + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "query2"; -requests_02.setThreshold(threshold3); - }requests1.add(.of(requests_02)); } -getRecommendationsParams0.setRequests(requests1); - } + facetFilters4.add(facetFilters_05); + } + queryParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_12.setQueryParameters(queryParameters3); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - }); + SearchParamsObject fallbackParameters3 = new SearchParamsObject(); + { + String query4 = "myQuery"; - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); + fallbackParameters3.setQuery(query4); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + List facetFilters4 = new ArrayList<>(); + { + String facetFilters_05 = "fallback2"; + facetFilters4.add(facetFilters_05); + } + fallbackParameters3.setFacetFilters( + FacetFilters.ofListString(facetFilters4) + ); + } + requests_12.setFallbackParameters(fallbackParameters3); + } + requests1.add( + RecommendationsRequest.ofRecommendationRequest(requests_12) + ); + } + getRecommendationsParams0.setRequests(requests1); } - @Test - @DisplayName("get recommendations for trending model with all parameters") - void getRecommendationsTest3() { - - - - - - - -GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); -{ - - - - - -List< -> - requests1 = new ArrayList<>(); { - - - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query1\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback1\"]}},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query2\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback2\"]}}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("get frequently bought together recommendations") + void getRecommendationsTest6() { + GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); + { + List requests1 = new ArrayList<>(); + { + RecommendationRequest requests_02 = new RecommendationRequest(); + { + String indexName3 = "indexName1"; + + requests_02.setIndexName(indexName3); + String objectID3 = "objectID1"; + + requests_02.setObjectID(objectID3); + + RecommendationModels model3 = RecommendationModels.fromValue( + "bought-together" + ); + + requests_02.setModel(model3); + + int threshold3 = 42; + + requests_02.setThreshold(threshold3); + } + requests1.add( + RecommendationsRequest.ofRecommendationRequest(requests_02) + ); + } + getRecommendationsParams0.setRequests(requests1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getRecommendations(getRecommendationsParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/*/recommendations"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"bought-together\",\"threshold\":42}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + } + ); + + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "POST"); + } + + @Test + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { + String path0 = "/test/all"; + + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; + + parameters0.put("query", query1); + } -TrendingRequest requests_02 = new TrendingRequest(); -{ String indexName3 = "indexName"; + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0, parameters0, body0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + } -requests_02.setIndexName(indexName3); + @Test + @DisplayName("allow put method for a custom path with all parameters") + void putTest1() { + String path0 = "/test/all"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; + parameters0.put("query", query1); + } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; - -TrendingModels model3 = TrendingModels.fromValue("trending-items"); - -requests_02.setModel(model3); - -int threshold3 = 42; - - - - - -requests_02.setThreshold(threshold3); - -int maxRecommendations3 = 10; - - - - - -requests_02.setMaxRecommendations(maxRecommendations3); -String facetName3 = "myFacetName"; - - - - - - -requests_02.setFacetName(facetName3); -String facetValue3 = "myFacetValue"; - - - - - - -requests_02.setFacetValue(facetValue3); - - - - - - - -SearchParamsObject queryParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -queryParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query"; - - - - - - -facetFilters4.add(facetFilters_05); } -queryParameters3.setFacetFilters(.of(facetFilters4)); - }requests_02.setQueryParameters(queryParameters3); - - - - - - - -SearchParamsObject fallbackParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -fallbackParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback"; - - - - - - -facetFilters4.add(facetFilters_05); } -fallbackParameters3.setFacetFilters(.of(facetFilters4)); - }requests_02.setFallbackParameters(fallbackParameters3); - }requests1.add(.of(requests_02)); } -getRecommendationsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName\",\"model\":\"trending-items\",\"threshold\":42,\"maxRecommendations\":10,\"facetName\":\"myFacetName\",\"facetValue\":\"myFacetValue\",\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback\"]}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("get multiple recommendations with minimal parameters") - void getRecommendationsTest4() { - - - - - - - -GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); -{ - - - - - -List< -> - requests1 = new ArrayList<>(); { - - - - - - -RecommendationRequest requests_02 = new RecommendationRequest(); -{ String indexName3 = "indexName1"; - - - - - - -requests_02.setIndexName(indexName3); -String objectID3 = "objectID1"; - - - - - - -requests_02.setObjectID(objectID3); - - - - - -RecommendationModels model3 = RecommendationModels.fromValue("related-products"); - -requests_02.setModel(model3); - -int threshold3 = 21; - - - - - -requests_02.setThreshold(threshold3); - }requests1.add(.of(requests_02)); - - - - - - -RecommendationRequest requests_12 = new RecommendationRequest(); -{ String indexName3 = "indexName2"; - - - - - - -requests_12.setIndexName(indexName3); -String objectID3 = "objectID2"; - - - - - - -requests_12.setObjectID(objectID3); - - - - - -RecommendationModels model3 = RecommendationModels.fromValue("related-products"); - -requests_12.setModel(model3); - -int threshold3 = 21; - - - - - -requests_12.setThreshold(threshold3); - }requests1.add(.of(requests_12)); } -getRecommendationsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("get multiple recommendations with all parameters") - void getRecommendationsTest5() { - - - - - - - -GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); -{ - - - - - -List< -> - requests1 = new ArrayList<>(); { - - - - - - -RecommendationRequest requests_02 = new RecommendationRequest(); -{ String indexName3 = "indexName1"; - - - - - - -requests_02.setIndexName(indexName3); -String objectID3 = "objectID1"; - - - - - - -requests_02.setObjectID(objectID3); - - - - - -RecommendationModels model3 = RecommendationModels.fromValue("related-products"); - -requests_02.setModel(model3); - -int threshold3 = 21; - - - - - -requests_02.setThreshold(threshold3); - -int maxRecommendations3 = 10; - - - - - -requests_02.setMaxRecommendations(maxRecommendations3); - - - - - - - -SearchParamsObject queryParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -queryParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query1"; - - - - - - -facetFilters4.add(facetFilters_05); } -queryParameters3.setFacetFilters(.of(facetFilters4)); - }requests_02.setQueryParameters(queryParameters3); - - - - - - - -SearchParamsObject fallbackParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -fallbackParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback1"; - - - - - - -facetFilters4.add(facetFilters_05); } -fallbackParameters3.setFacetFilters(.of(facetFilters4)); - }requests_02.setFallbackParameters(fallbackParameters3); - }requests1.add(.of(requests_02)); - - - - - - -RecommendationRequest requests_12 = new RecommendationRequest(); -{ String indexName3 = "indexName2"; - - - - - - -requests_12.setIndexName(indexName3); -String objectID3 = "objectID2"; - - - - - - -requests_12.setObjectID(objectID3); - - - - - -RecommendationModels model3 = RecommendationModels.fromValue("related-products"); - -requests_12.setModel(model3); - -int threshold3 = 21; - - - - - -requests_12.setThreshold(threshold3); - -int maxRecommendations3 = 10; - - - - - -requests_12.setMaxRecommendations(maxRecommendations3); - - - - - - - -SearchParamsObject queryParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -queryParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "query2"; - - - - - - -facetFilters4.add(facetFilters_05); } -queryParameters3.setFacetFilters(.of(facetFilters4)); - }requests_12.setQueryParameters(queryParameters3); - - - - - - - -SearchParamsObject fallbackParameters3 = new SearchParamsObject(); -{ String query4 = "myQuery"; - - - - - - -fallbackParameters3.setQuery(query4); - - - - - - -List - facetFilters4 = new ArrayList<>(); { String facetFilters_05 = "fallback2"; - - - - - - -facetFilters4.add(facetFilters_05); } -fallbackParameters3.setFacetFilters(.of(facetFilters4)); - }requests_12.setFallbackParameters(fallbackParameters3); - }requests1.add(.of(requests_12)); } -getRecommendationsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query1\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback1\"]}},{\"indexName\":\"indexName2\",\"objectID\":\"objectID2\",\"model\":\"related-products\",\"threshold\":21,\"maxRecommendations\":10,\"queryParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"query2\"]},\"fallbackParameters\":{\"query\":\"myQuery\",\"facetFilters\":[\"fallback2\"]}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("get frequently bought together recommendations") - void getRecommendationsTest6() { - - - - - - - -GetRecommendationsParams getRecommendationsParams0 = new GetRecommendationsParams(); -{ - - - - - -List< -> - requests1 = new ArrayList<>(); { - - - - - - -RecommendationRequest requests_02 = new RecommendationRequest(); -{ String indexName3 = "indexName1"; - - - - - - -requests_02.setIndexName(indexName3); -String objectID3 = "objectID1"; - - - - - - -requests_02.setObjectID(objectID3); - - - - - -RecommendationModels model3 = RecommendationModels.fromValue("bought-together"); - -requests_02.setModel(model3); - -int threshold3 = 42; - - - - - -requests_02.setThreshold(threshold3); - }requests1.add(.of(requests_02)); } -getRecommendationsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRecommendations(getRecommendationsParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/recommendations"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"indexName1\",\"objectID\":\"objectID1\",\"model\":\"bought-together\",\"threshold\":42}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - + body0.put("body", body1); } - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - - - - - -Map body0 = new HashMap<>(); -{ String body1 = "parameters"; - - - - - - -body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0,parameters0,body0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("allow put method for a custom path with minimal parameters") - void putTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "PUT"); - - - } - @Test - @DisplayName("allow put method for a custom path with all parameters") - void putTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - - - - - -Map body0 = new HashMap<>(); -{ String body1 = "parameters"; - - - - - - -body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0,parameters0,body0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0, parameters0, body0); + } + ); + + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + + HashMap expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); } + } } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index cf44191516..05c4693600 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -1,238 +1,559 @@ package com.algolia.methods.requests; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import java.util.*; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.BeforeAll; -import com.google.gson.reflect.TypeToken; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.algolia.JSON; import com.algolia.Pair; -import com.algolia.model.search.*; import com.algolia.api.SearchClient; +import com.algolia.model.search.*; import com.algolia.utils.echo.*; +import com.google.gson.reflect.TypeToken; +import java.util.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class SearchClientTests { - private SearchClient client; - - @BeforeAll - void init() { - client = new SearchClient("appId", "apiKey", new EchoRequester()); - } - @Test - @DisplayName("addApiKey") - void addApiKeyTest0() { - + private SearchClient client; + @BeforeAll + void init() { + client = new SearchClient("appId", "apiKey", new EchoRequester()); + } + @Test + @DisplayName("addApiKey") + void addApiKeyTest0() { + ApiKey apiKey0 = new ApiKey(); + { + List acl1 = new ArrayList<>(); + { + Acl acl_02 = Acl.fromValue("search"); + acl1.add(acl_02); + Acl acl_12 = Acl.fromValue("addObject"); + acl1.add(acl_12); + } + apiKey0.setAcl(acl1); + String description1 = "my new api key"; -ApiKey apiKey0 = new ApiKey(); -{ + apiKey0.setDescription(description1); + int validity1 = 300; + apiKey0.setValidity(validity1); + int maxQueriesPerIPPerHour1 = 100; + apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); -List - acl1 = new ArrayList<>(); { + int maxHitsPerQuery1 = 20; + apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.addApiKey(apiKey0); + } + ); + assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getMethod(), "POST"); -Acl acl_02 = Acl.fromValue("search"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api" + + " key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } -acl1.add(acl_02); + @Test + @DisplayName("addOrUpdateObject") + void addOrUpdateObjectTest0() { + String indexName0 = "indexName"; + String objectID0 = "uniqueID"; + Map body0 = new HashMap<>(); + { + String key1 = "value"; + body0.put("key", key1); + } -Acl acl_12 = Acl.fromValue("addObject"); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.addOrUpdateObject(indexName0, objectID0, body0); + } + ); -acl1.add(acl_12); } -apiKey0.setAcl(acl1); -String description1 = "my new api key"; + assertEquals(req.getPath(), "/1/indexes/indexName/uniqueID"); + assertEquals(req.getMethod(), "PUT"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"key\":\"value\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("appendSource") + void appendSourceTest0() { + Source source0 = new Source(); + { + String source1 = "theSource"; + source0.setSource(source1); + String description1 = "theDescription"; + source0.setDescription(description1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.appendSource(source0); + } + ); -apiKey0.setDescription(description1); + assertEquals(req.getPath(), "/1/security/sources/append"); + assertEquals(req.getMethod(), "POST"); -int validity1 = 300; + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"source\":\"theSource\",\"description\":\"theDescription\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("assignUserId") + void assignUserIdTest0() { + String xAlgoliaUserID0 = "userID"; + AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); + { + String cluster1 = "theCluster"; + assignUserIdParams0.setCluster(cluster1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.assignUserId(xAlgoliaUserID0, assignUserIdParams0); + } + ); -apiKey0.setValidity(validity1); + assertEquals(req.getPath(), "/1/clusters/mapping"); + assertEquals(req.getMethod(), "POST"); -int maxQueriesPerIPPerHour1 = 100; + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"cluster\":\"theCluster\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + HashMap expectedQuery = JSON.deserialize( + "{\"X-Algolia-User-ID\":\"userID\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("batch") + void batchTest0() { + String indexName0 = "theIndexName"; + BatchWriteParams batchWriteParams0 = new BatchWriteParams(); + { + List requests1 = new ArrayList<>(); + { + BatchOperation requests_02 = new BatchOperation(); + { + Action action3 = Action.fromValue("delete"); + requests_02.setAction(action3); -apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); + Map body3 = new HashMap<>(); + { + String key4 = "value"; -int maxHitsPerQuery1 = 20; + body3.put("key", key4); + } + requests_02.setBody(body3); + } + requests1.add(requests_02); + } + batchWriteParams0.setRequests(requests1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batch(indexName0, batchWriteParams0); + } + ); + assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("batchAssignUserIds") + void batchAssignUserIdsTest0() { + String xAlgoliaUserID0 = "userID"; -apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); - } + BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); + { + String cluster1 = "theCluster"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addApiKey(apiKey0); - }); + batchAssignUserIdsParams0.setCluster(cluster1); - assertEquals(req.getPath(), "/1/keys"); - assertEquals(req.getMethod(), "POST"); + List users1 = new ArrayList<>(); + { + String users_02 = "user1"; - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + users1.add(users_02); + String users_12 = "user2"; + users1.add(users_12); + } + batchAssignUserIdsParams0.setUsers(users1); } - @Test - @DisplayName("addOrUpdateObject") - void addOrUpdateObjectTest0() { - String indexName0 = "indexName"; - - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchAssignUserIds( + xAlgoliaUserID0, + batchAssignUserIdsParams0 + ); + } + ); + assertEquals(req.getPath(), "/1/clusters/mapping/batch"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); -String objectID0 = "uniqueID"; + HashMap expectedQuery = JSON.deserialize( + "{\"X-Algolia-User-ID\":\"userID\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("get batchDictionaryEntries results with minimal parameters") + void batchDictionaryEntriesTest0() { + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); + { + List requests1 = new ArrayList<>(); + { + BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); + { + DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); + requests_02.setAction(action3); + DictionaryEntry body3 = new DictionaryEntry(); + { + String objectID4 = "1"; + body3.setObjectID(objectID4); + String language4 = "en"; + body3.setLanguage(language4); + } + requests_02.setBody(body3); + } + requests1.add(requests_02); + BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); + { + DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); + requests_12.setAction(action3); + DictionaryEntry body3 = new DictionaryEntry(); + { + String objectID4 = "2"; + body3.setObjectID(objectID4); + String language4 = "fr"; + body3.setLanguage(language4); + } + requests_12.setBody(body3); + } + requests1.add(requests_12); + } + batchDictionaryEntriesParams0.setRequests(requests1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchDictionaryEntries( + dictionaryName0, + batchDictionaryEntriesParams0 + ); + } + ); -Map body0 = new HashMap<>(); -{ String key1 = "value"; + assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\"}}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("get batchDictionaryEntries results with all parameters") + void batchDictionaryEntriesTest1() { + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); + { + boolean clearExistingDictionaryEntries1 = false; + batchDictionaryEntriesParams0.setClearExistingDictionaryEntries( + clearExistingDictionaryEntries1 + ); + List requests1 = new ArrayList<>(); + { + BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); + { + DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); -body0.put("key", key1); - } + requests_02.setAction(action3); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addOrUpdateObject(indexName0,objectID0,body0); - }); + DictionaryEntry body3 = new DictionaryEntry(); + { + String objectID4 = "1"; - assertEquals(req.getPath(), "/1/indexes/indexName/uniqueID"); - assertEquals(req.getMethod(), "PUT"); + body3.setObjectID(objectID4); + String language4 = "en"; - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"key\":\"value\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + body3.setLanguage(language4); + String word4 = "fancy"; - } - @Test - @DisplayName("appendSource") - void appendSourceTest0() { - + body3.setWord(word4); + List words4 = new ArrayList<>(); + { + String words_05 = "believe"; + words4.add(words_05); + String words_15 = "algolia"; + words4.add(words_15); + } + body3.setWords(words4); + List decomposition4 = new ArrayList<>(); + { + String decomposition_05 = "trust"; + decomposition4.add(decomposition_05); + String decomposition_15 = "algolia"; -Source source0 = new Source(); -{ String source1 = "theSource"; + decomposition4.add(decomposition_15); + } + body3.setDecomposition(decomposition4); + DictionaryEntryState state4 = DictionaryEntryState.fromValue( + "enabled" + ); + body3.setState(state4); + } + requests_02.setBody(body3); + } + requests1.add(requests_02); + BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); + { + DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); + requests_12.setAction(action3); + DictionaryEntry body3 = new DictionaryEntry(); + { + String objectID4 = "2"; -source0.setSource(source1); -String description1 = "theDescription"; + body3.setObjectID(objectID4); + String language4 = "fr"; + body3.setLanguage(language4); + String word4 = "humility"; + body3.setWord(word4); + List words4 = new ArrayList<>(); + { + String words_05 = "candor"; + words4.add(words_05); + String words_15 = "algolia"; + words4.add(words_15); + } + body3.setWords(words4); -source0.setDescription(description1); - } + List decomposition4 = new ArrayList<>(); + { + String decomposition_05 = "grit"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.appendSource(source0); - }); + decomposition4.add(decomposition_05); + String decomposition_15 = "algolia"; - assertEquals(req.getPath(), "/1/security/sources/append"); - assertEquals(req.getMethod(), "POST"); + decomposition4.add(decomposition_15); + } + body3.setDecomposition(decomposition4); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"source\":\"theSource\",\"description\":\"theDescription\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + DictionaryEntryState state4 = DictionaryEntryState.fromValue( + "enabled" + ); + body3.setState(state4); + } + requests_12.setBody(body3); + } + requests1.add(requests_12); + } + batchDictionaryEntriesParams0.setRequests(requests1); } - @Test - @DisplayName("assignUserId") - void assignUserIdTest0() { - String xAlgoliaUserID0 = "userID"; - - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.batchDictionaryEntries( + dictionaryName0, + batchDictionaryEntriesParams0 + ); + } + ); + assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"clearExistingDictionaryEntries\":false,\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\",\"word\":\"fancy\",\"words\":[\"believe\",\"algolia\"],\"decomposition\":[\"trust\",\"algolia\"],\"state\":\"enabled\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\",\"word\":\"humility\",\"words\":[\"candor\",\"algolia\"],\"decomposition\":[\"grit\",\"algolia\"],\"state\":\"enabled\"}}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("batchRules") + void batchRulesTest0() { + String indexName0 = "indexName"; + List rule0 = new ArrayList<>(); + { + Rule rule_01 = new Rule(); + { + String objectID2 = "a-rule-id"; + rule_01.setObjectID(objectID2); + List conditions2 = new ArrayList<>(); + { + Condition conditions_03 = new Condition(); + { + String pattern4 = "smartphone"; + conditions_03.setPattern(pattern4); + Anchoring anchoring4 = Anchoring.fromValue("contains"); + conditions_03.setAnchoring(anchoring4); + } + conditions2.add(conditions_03); + } + rule_01.setConditions(conditions2); -AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); -{ String cluster1 = "theCluster"; + Consequence consequence2 = new Consequence(); + { + ConsequenceParams params3 = new ConsequenceParams(); + { + String filters4 = "category:smartphone"; + params3.setFilters(filters4); + } + consequence2.setParams(params3); + } + rule_01.setConsequence(consequence2); + } + rule0.add(rule_01); + Rule rule_11 = new Rule(); + { + String objectID2 = "a-second-rule-id"; + rule_11.setObjectID(objectID2); + List conditions2 = new ArrayList<>(); + { + Condition conditions_03 = new Condition(); + { + String pattern4 = "apple"; + conditions_03.setPattern(pattern4); -assignUserIdParams0.setCluster(cluster1); - } + Anchoring anchoring4 = Anchoring.fromValue("contains"); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.assignUserId(xAlgoliaUserID0,assignUserIdParams0); - }); + conditions_03.setAnchoring(anchoring4); + } + conditions2.add(conditions_03); + } + rule_11.setConditions(conditions2); - assertEquals(req.getPath(), "/1/clusters/mapping"); - assertEquals(req.getMethod(), "POST"); + Consequence consequence2 = new Consequence(); + { + ConsequenceParams params3 = new ConsequenceParams(); + { + String filters4 = "brand:apple"; params3.setFilters(filters4); } @@ -953,61 +1274,219 @@ void multipleBatchTest0() { requests_02.setIndexName(indexName3); } + requests1.add(requests_02); + } + batchParams0.setRequests(requests1); } - @Test - @DisplayName("batch") - void batchTest0() { - String indexName0 = "theIndexName"; - - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.multipleBatch(batchParams0); + } + ); + assertEquals(req.getPath(), "/1/indexes/*/batch"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("multipleQueries") + void multipleQueriesTest0() { + MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); + { + List requests1 = new ArrayList<>(); + { + MultipleQueries requests_02 = new MultipleQueries(); + { + String indexName3 = "theIndexName"; + requests_02.setIndexName(indexName3); + String query3 = "test"; + requests_02.setQuery(query3); + MultipleQueriesType type3 = MultipleQueriesType.fromValue("facet"); + requests_02.setType(type3); + String facet3 = "theFacet"; + requests_02.setFacet(facet3); + String params3 = "testParam"; + requests_02.setParams(params3); + } + requests1.add(requests_02); + } + multipleQueriesParams0.setRequests(requests1); -BatchWriteParams batchWriteParams0 = new BatchWriteParams(); -{ + MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue( + "stopIfEnoughMatches" + ); + multipleQueriesParams0.setStrategy(strategy1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.multipleQueries(multipleQueriesParams0); + } + ); + assertEquals(req.getPath(), "/1/indexes/*/queries"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("operationIndex") + void operationIndexTest0() { + String indexName0 = "theIndexName"; + + OperationIndexParams operationIndexParams0 = new OperationIndexParams(); + { + OperationType operation1 = OperationType.fromValue("copy"); + + operationIndexParams0.setOperation(operation1); + String destination1 = "dest"; + + operationIndexParams0.setDestination(destination1); + + List scope1 = new ArrayList<>(); + { + ScopeType scope_02 = ScopeType.fromValue("rules"); -List - requests1 = new ArrayList<>(); { + scope1.add(scope_02); + ScopeType scope_12 = ScopeType.fromValue("settings"); + scope1.add(scope_12); + } + operationIndexParams0.setScope(scope1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.operationIndex(indexName0, operationIndexParams0); + } + ); + + assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("partialUpdateObject") + void partialUpdateObjectTest0() { + String indexName0 = "theIndexName"; + String objectID0 = "uniqueID"; -BatchOperation requests_02 = new BatchOperation(); -{ + List> attributeOrBuiltInOperation0 = new ArrayList<>(); + { + Map attributeOrBuiltInOperation_01 = new HashMap<>(); + { + String id12 = "test"; + attributeOrBuiltInOperation_01.put( + "id1", + AttributeOrBuiltInOperation.ofString(id12) + ); + BuiltInOperation id22 = new BuiltInOperation(); + { + BuiltInOperationType operation3 = BuiltInOperationType.fromValue( + "AddUnique" + ); + id22.setOperation(operation3); + String value3 = "test2"; -Action action3 = Action.fromValue("delete"); + id22.setValue(value3); + } + attributeOrBuiltInOperation_01.put( + "id2", + AttributeOrBuiltInOperation.ofBuiltInOperation(id22) + ); + } + attributeOrBuiltInOperation0.add(attributeOrBuiltInOperation_01); + } -requests_02.setAction(action3); + boolean createIfNotExists0 = true; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.partialUpdateObject( + indexName0, + objectID0, + attributeOrBuiltInOperation0, + createIfNotExists0 + ); + } + ); + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID/partial"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + HashMap expectedQuery = JSON.deserialize( + "{\"createIfNotExists\":\"true\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.post(path0); + } + ); -Map body3 = new HashMap<>(); -{ String key4 = "value"; + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "POST"); + } + @Test + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { + String path0 = "/test/all"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; parameters0.put("query", query1); } @@ -1065,6 +1544,9 @@ void putTest0() { void putTest1() { String path0 = "/test/all"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; parameters0.put("query", query1); } @@ -1108,3352 +1590,811 @@ void putTest1() { void removeUserIdTest0() { String userID0 = "uniqueID"; -body3.put("key", key4); - }requests_02.setBody(body3); - }requests1.add(requests_02); } -batchWriteParams0.setRequests(requests1); - } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.removeUserId(userID0); + } + ); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batch(indexName0,batchWriteParams0); - }); + assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); + assertEquals(req.getMethod(), "DELETE"); + } - assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); - assertEquals(req.getMethod(), "POST"); + @Test + @DisplayName("replaceSources") + void replaceSourcesTest0() { + List source0 = new ArrayList<>(); + { + Source source_01 = new Source(); + { + String source2 = "theSource"; - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + source_01.setSource(source2); + String description2 = "theDescription"; + source_01.setDescription(description2); + } + source0.add(source_01); } - @Test - @DisplayName("batchAssignUserIds") - void batchAssignUserIdsTest0() { - String xAlgoliaUserID0 = "userID"; - - - + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.replaceSources(source0); + } + ); + assertEquals(req.getPath(), "/1/security/sources"); + assertEquals(req.getMethod(), "PUT"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("restoreApiKey") + void restoreApiKeyTest0() { + String key0 = "myApiKey"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.restoreApiKey(key0); + } + ); + assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); + assertEquals(req.getMethod(), "POST"); + } + @Test + @DisplayName("saveObject") + void saveObjectTest0() { + String indexName0 = "theIndexName"; + Map body0 = new HashMap<>(); + { + String objectID1 = "id"; + body0.put("objectID", objectID1); + String test1 = "val"; -BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); -{ String cluster1 = "theCluster"; + body0.put("test", test1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveObject(indexName0, body0); + } + ); + assertEquals(req.getPath(), "/1/indexes/theIndexName"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"objectID\":\"id\",\"test\":\"val\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("saveRule") + void saveRuleTest0() { + String indexName0 = "indexName"; + String objectID0 = "id1"; -batchAssignUserIdsParams0.setCluster(cluster1); + Rule rule0 = new Rule(); + { + String objectID1 = "id1"; + rule0.setObjectID(objectID1); + List conditions1 = new ArrayList<>(); + { + Condition conditions_02 = new Condition(); + { + String pattern3 = "apple"; + conditions_02.setPattern(pattern3); + Anchoring anchoring3 = Anchoring.fromValue("contains"); + conditions_02.setAnchoring(anchoring3); + } + conditions1.add(conditions_02); + } + rule0.setConditions(conditions1); -List - users1 = new ArrayList<>(); { String users_02 = "user1"; + Consequence consequence1 = new Consequence(); + { + ConsequenceParams params2 = new ConsequenceParams(); + { + String filters3 = "brand:apple"; + params2.setFilters(filters3); + } + consequence1.setParams(params2); + } + rule0.setConsequence(consequence1); + } + boolean forwardToReplicas0 = true; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveRule( + indexName0, + objectID0, + rule0, + forwardToReplicas0 + ); + } + ); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "PUT"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"objectID\":\"id1\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); -users1.add(users_02);String users_12 = "user2"; + HashMap expectedQuery = JSON.deserialize( + "{\"forwardToReplicas\":\"true\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("saveSynonym") + void saveSynonymTest0() { + String indexName0 = "indexName"; + String objectID0 = "id1"; + SynonymHit synonymHit0 = new SynonymHit(); + { + String objectID1 = "id1"; + synonymHit0.setObjectID(objectID1); + SynonymType type1 = SynonymType.fromValue("synonym"); -users1.add(users_12); } -batchAssignUserIdsParams0.setUsers(users1); - } + synonymHit0.setType(type1); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchAssignUserIds(xAlgoliaUserID0,batchAssignUserIdsParams0); - }); + List synonyms1 = new ArrayList<>(); + { + String synonyms_02 = "car"; - assertEquals(req.getPath(), "/1/clusters/mapping/batch"); - assertEquals(req.getMethod(), "POST"); + synonyms1.add(synonyms_02); + String synonyms_12 = "vehicule"; - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + synonyms1.add(synonyms_12); + String synonyms_22 = "auto"; - HashMap expectedQuery = JSON.deserialize("{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } + synonyms1.add(synonyms_22); + } + synonymHit0.setSynonyms(synonyms1); } - @Test - @DisplayName("get batchDictionaryEntries results with minimal parameters") - void batchDictionaryEntriesTest0() { - - + boolean forwardToReplicas0 = true; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveSynonym( + indexName0, + objectID0, + synonymHit0, + forwardToReplicas0 + ); + } + ); -DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "PUT"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + HashMap expectedQuery = JSON.deserialize( + "{\"forwardToReplicas\":\"true\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("saveSynonyms") + void saveSynonymsTest0() { + String indexName0 = "indexName"; + List synonymHit0 = new ArrayList<>(); + { + SynonymHit synonymHit_01 = new SynonymHit(); + { + String objectID2 = "id1"; + synonymHit_01.setObjectID(objectID2); + SynonymType type2 = SynonymType.fromValue("synonym"); + synonymHit_01.setType(type2); -BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); -{ + List synonyms2 = new ArrayList<>(); + { + String synonyms_03 = "car"; + synonyms2.add(synonyms_03); + String synonyms_13 = "vehicule"; + synonyms2.add(synonyms_13); + String synonyms_23 = "auto"; + synonyms2.add(synonyms_23); + } + synonymHit_01.setSynonyms(synonyms2); + } + synonymHit0.add(synonymHit_01); + SynonymHit synonymHit_11 = new SynonymHit(); + { + String objectID2 = "id2"; -List - requests1 = new ArrayList<>(); { + synonymHit_11.setObjectID(objectID2); + SynonymType type2 = SynonymType.fromValue("onewaysynonym"); + synonymHit_11.setType(type2); + String input2 = "iphone"; + synonymHit_11.setInput(input2); + List synonyms2 = new ArrayList<>(); + { + String synonyms_03 = "ephone"; + synonyms2.add(synonyms_03); + String synonyms_13 = "aphone"; -BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); -{ + synonyms2.add(synonyms_13); + String synonyms_23 = "yphone"; + synonyms2.add(synonyms_23); + } + synonymHit_11.setSynonyms(synonyms2); + } + synonymHit0.add(synonymHit_11); + } + boolean forwardToReplicas0 = true; + boolean replaceExistingSynonyms0 = false; -DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.saveSynonyms( + indexName0, + synonymHit0, + forwardToReplicas0, + replaceExistingSynonyms0 + ); + } + ); -requests_02.setAction(action3); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + HashMap expectedQuery = JSON.deserialize( + "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("search with minimal parameters") + void searchTest0() { + String indexName0 = "indexName"; + SearchParamsObject searchParams0 = new SearchParamsObject(); + { + String query1 = "myQuery"; + searchParams0.setQuery(query1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.search( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); + } + ); -DictionaryEntry body3 = new DictionaryEntry(); -{ String objectID4 = "1"; + assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"myQuery\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("search with facetFilters") + void searchTest1() { + String indexName0 = "indexName"; + SearchParamsObject searchParams0 = new SearchParamsObject(); + { + String query1 = "myQuery"; + searchParams0.setQuery(query1); + List facetFilters1 = new ArrayList<>(); + { + String facetFilters_02 = "tags:algolia"; -body3.setObjectID(objectID4); -String language4 = "en"; - - - - - - -body3.setLanguage(language4); - }requests_02.setBody(body3); - }requests1.add(requests_02); - - - - - - -BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); -{ - - - - -DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); - -requests_12.setAction(action3); - - - - - - - -DictionaryEntry body3 = new DictionaryEntry(); -{ String objectID4 = "2"; - - - - - - -body3.setObjectID(objectID4); -String language4 = "fr"; - - - - - - -body3.setLanguage(language4); - }requests_12.setBody(body3); - }requests1.add(requests_12); } -batchDictionaryEntriesParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchDictionaryEntries(dictionaryName0,batchDictionaryEntriesParams0); - }); - - assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("get batchDictionaryEntries results with all parameters") - void batchDictionaryEntriesTest1() { - - - - - -DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - - - - - - - -BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); -{ - - - -boolean clearExistingDictionaryEntries1 = false; - - -batchDictionaryEntriesParams0.setClearExistingDictionaryEntries(clearExistingDictionaryEntries1); - - - - - - -List - requests1 = new ArrayList<>(); { - - - - - - -BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); -{ - - - - -DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); - -requests_02.setAction(action3); - - - - - - - -DictionaryEntry body3 = new DictionaryEntry(); -{ String objectID4 = "1"; - - - - - - -body3.setObjectID(objectID4); -String language4 = "en"; - - - - - - -body3.setLanguage(language4); -String word4 = "fancy"; - - - - - - -body3.setWord(word4); - - - - - - -List - words4 = new ArrayList<>(); { String words_05 = "believe"; - - - - - - -words4.add(words_05);String words_15 = "algolia"; - - - - - - -words4.add(words_15); } -body3.setWords(words4); - - - - - - -List - decomposition4 = new ArrayList<>(); { String decomposition_05 = "trust"; - - - - - - -decomposition4.add(decomposition_05);String decomposition_15 = "algolia"; - - - - - - -decomposition4.add(decomposition_15); } -body3.setDecomposition(decomposition4); - - - - - -DictionaryEntryState state4 = DictionaryEntryState.fromValue("enabled"); - -body3.setState(state4); - }requests_02.setBody(body3); - }requests1.add(requests_02); - - - - - - -BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); -{ - - - - -DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); - -requests_12.setAction(action3); - - - - - - - -DictionaryEntry body3 = new DictionaryEntry(); -{ String objectID4 = "2"; - - - - - - -body3.setObjectID(objectID4); -String language4 = "fr"; - - - - - - -body3.setLanguage(language4); -String word4 = "humility"; - - - - - - -body3.setWord(word4); - - - - - - -List - words4 = new ArrayList<>(); { String words_05 = "candor"; - - - - - - -words4.add(words_05);String words_15 = "algolia"; - - - - - - -words4.add(words_15); } -body3.setWords(words4); - - - - - - -List - decomposition4 = new ArrayList<>(); { String decomposition_05 = "grit"; - - - - - - -decomposition4.add(decomposition_05);String decomposition_15 = "algolia"; - - - - - - -decomposition4.add(decomposition_15); } -body3.setDecomposition(decomposition4); - - - - - -DictionaryEntryState state4 = DictionaryEntryState.fromValue("enabled"); - -body3.setState(state4); - }requests_12.setBody(body3); - }requests1.add(requests_12); } -batchDictionaryEntriesParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchDictionaryEntries(dictionaryName0,batchDictionaryEntriesParams0); - }); - - assertEquals(req.getPath(), "/1/dictionaries/compounds/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"clearExistingDictionaryEntries\":false,\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\",\"word\":\"fancy\",\"words\":[\"believe\",\"algolia\"],\"decomposition\":[\"trust\",\"algolia\"],\"state\":\"enabled\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\",\"word\":\"humility\",\"words\":[\"candor\",\"algolia\"],\"decomposition\":[\"grit\",\"algolia\"],\"state\":\"enabled\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("batchRules") - void batchRulesTest0() { - String indexName0 = "indexName"; - - - - - - - - - - - - -List - rule0 = new ArrayList<>(); { - - - - - - -Rule rule_01 = new Rule(); -{ String objectID2 = "a-rule-id"; - - - - - - -rule_01.setObjectID(objectID2); - - - - - - -List - conditions2 = new ArrayList<>(); { - - - - - - -Condition conditions_03 = new Condition(); -{ String pattern4 = "smartphone"; - - - - - - -conditions_03.setPattern(pattern4); - - - - - -Anchoring anchoring4 = Anchoring.fromValue("contains"); - -conditions_03.setAnchoring(anchoring4); - }conditions2.add(conditions_03); } -rule_01.setConditions(conditions2); - - - - - - - -Consequence consequence2 = new Consequence(); -{ - - - - - - -ConsequenceParams params3 = new ConsequenceParams(); -{ String filters4 = "category:smartphone"; - - - - - - -params3.setFilters(filters4); - }consequence2.setParams(params3); - }rule_01.setConsequence(consequence2); - }rule0.add(rule_01); - - - - - - -Rule rule_11 = new Rule(); -{ String objectID2 = "a-second-rule-id"; - - - - - - -rule_11.setObjectID(objectID2); - - - - - - -List - conditions2 = new ArrayList<>(); { - - - - - - -Condition conditions_03 = new Condition(); -{ String pattern4 = "apple"; - - - - - - -conditions_03.setPattern(pattern4); - - - - - -Anchoring anchoring4 = Anchoring.fromValue("contains"); - -conditions_03.setAnchoring(anchoring4); - }conditions2.add(conditions_03); } -rule_11.setConditions(conditions2); - - - - - - - -Consequence consequence2 = new Consequence(); -{ - - - - - - -ConsequenceParams params3 = new ConsequenceParams(); -{ String filters4 = "brand:apple"; - - - - - - -params3.setFilters(filters4); - }consequence2.setParams(params3); - }rule_11.setConsequence(consequence2); - }rule0.add(rule_11); } - - - - -boolean forwardToReplicas0 = true; - - - - - - -boolean clearExistingRules0 = true; - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchRules(indexName0,rule0,forwardToReplicas0,clearExistingRules0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("[{\"objectID\":\"a-rule-id\",\"conditions\":[{\"pattern\":\"smartphone\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"category:smartphone\"}}},{\"objectID\":\"a-second-rule-id\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}]", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\",\"clearExistingRules\":\"true\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("get browse results with minimal parameters") - void browseTest0() { - String indexName0 = "indexName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.browse(indexName0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/browse"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("get browse results with all parameters") - void browseTest1() { - String indexName0 = "indexName"; - - - - - - - - - - - - - -BrowseRequest browseRequest0 = new BrowseRequest(); -{ String params1 = "query=foo&facetFilters=['bar']"; - - - - - - -browseRequest0.setParams(params1); -String cursor1 = "cts"; - - - - - - -browseRequest0.setCursor(cursor1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.browse(indexName0,browseRequest0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/browse"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("clearAllSynonyms") - void clearAllSynonymsTest0() { - String indexName0 = "indexName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearAllSynonyms(indexName0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/clear"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("clearObjects") - void clearObjectsTest0() { - String indexName0 = "theIndexName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearObjects(indexName0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/clear"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("clearRules") - void clearRulesTest0() { - String indexName0 = "indexName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearRules(indexName0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/clear"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0,parameters0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("deleteApiKey") - void deleteApiKeyTest0() { - String key0 = "myTestApiKey"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteApiKey(key0); - }); - - assertEquals(req.getPath(), "/1/keys/myTestApiKey"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("deleteBy") - void deleteByTest0() { - String indexName0 = "theIndexName"; - - - - - - - - - - - - - -SearchParamsObject searchParams0 = new SearchParamsObject(); -{ String query1 = "testQuery"; - - - - - - -searchParams0.setQuery(query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteBy(indexName0,.of(searchParams0)); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"query\":\"testQuery\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("deleteIndex") - void deleteIndexTest0() { - String indexName0 = "theIndexName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteIndex(indexName0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("deleteObject") - void deleteObjectTest0() { - String indexName0 = "theIndexName"; - - - - - - -String objectID0 = "uniqueID"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteObject(indexName0,objectID0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("deleteRule") - void deleteRuleTest0() { - String indexName0 = "indexName"; - - - - - - -String objectID0 = "id1"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteRule(indexName0,objectID0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("deleteSource") - void deleteSourceTest0() { - String source0 = "theSource"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSource(source0); - }); - - assertEquals(req.getPath(), "/1/security/sources/theSource"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("deleteSynonym") - void deleteSynonymTest0() { - String indexName0 = "indexName"; - - - - - - -String objectID0 = "id1"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSynonym(indexName0,objectID0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0,parameters0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getApiKey") - void getApiKeyTest0() { - String key0 = "myTestApiKey"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getApiKey(key0); - }); - - assertEquals(req.getPath(), "/1/keys/myTestApiKey"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("get getDictionaryLanguages") - void getDictionaryLanguagesTest0() { - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getDictionaryLanguages(); - }); - - assertEquals(req.getPath(), "/1/dictionaries/*/languages"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("get getDictionarySettings results") - void getDictionarySettingsTest0() { - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getDictionarySettings(); - }); - - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getLogs") - void getLogsTest0() { - -int offset0 = 5; - - - - - - -int length0 = 10; - - - - - -String indexName0 = "theIndexName"; - - - - - - - - - - - -LogType type0 = LogType.fromValue("all"); - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogs(offset0,length0,indexName0,type0); - }); - - assertEquals(req.getPath(), "/1/logs"); - assertEquals(req.getMethod(), "GET"); - - - HashMap expectedQuery = JSON.deserialize("{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("getObject") - void getObjectTest0() { - String indexName0 = "theIndexName"; - - - - - - -String objectID0 = "uniqueID"; - - - - - - - - - - - - -List - attributesToRetrieve0 = new ArrayList<>(); { String attributesToRetrieve_01 = "attr1"; - - - - - - -attributesToRetrieve0.add(attributesToRetrieve_01);String attributesToRetrieve_11 = "attr2"; - - - - - - -attributesToRetrieve0.add(attributesToRetrieve_11); } - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObject(indexName0,objectID0,attributesToRetrieve0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); - assertEquals(req.getMethod(), "GET"); - - - HashMap expectedQuery = JSON.deserialize("{\"attributesToRetrieve\":\"attr1,attr2\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("getObjects") - void getObjectsTest0() { - - - - - - - -GetObjectsParams getObjectsParams0 = new GetObjectsParams(); -{ - - - - - -List - requests1 = new ArrayList<>(); { - - - - - - -MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); -{ - - - - - -List - attributesToRetrieve3 = new ArrayList<>(); { String attributesToRetrieve_04 = "attr1"; - - - - - - -attributesToRetrieve3.add(attributesToRetrieve_04);String attributesToRetrieve_14 = "attr2"; - - - - - - -attributesToRetrieve3.add(attributesToRetrieve_14); } -requests_02.setAttributesToRetrieve(attributesToRetrieve3); -String objectID3 = "uniqueID"; - - - - - - -requests_02.setObjectID(objectID3); -String indexName3 = "theIndexName"; - - - - - - -requests_02.setIndexName(indexName3); - }requests1.add(requests_02); } -getObjectsParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObjects(getObjectsParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/objects"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"attributesToRetrieve\":[\"attr1\",\"attr2\"],\"objectID\":\"uniqueID\",\"indexName\":\"theIndexName\"}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("getRule") - void getRuleTest0() { - String indexName0 = "indexName"; - - - - - - -String objectID0 = "id1"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRule(indexName0,objectID0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getSettings") - void getSettingsTest0() { - String indexName0 = "theIndexName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSettings(indexName0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getSources") - void getSourcesTest0() { - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSources(); - }); - - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getSynonym") - void getSynonymTest0() { - String indexName0 = "indexName"; - - - - - - -String objectID0 = "id1"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSynonym(indexName0,objectID0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getTask") - void getTaskTest0() { - String indexName0 = "theIndexName"; - - - - - - - -int taskID0 = 123; - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTask(indexName0,taskID0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/task/123"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getTopUserIds") - void getTopUserIdsTest0() { - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopUserIds(); - }); - - assertEquals(req.getPath(), "/1/clusters/mapping/top"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("getUserId") - void getUserIdTest0() { - String userID0 = "uniqueID"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUserId(userID0); - }); - - assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("hasPendingMappings") - void hasPendingMappingsTest0() { - - - - -boolean getClusters0 = true; - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.hasPendingMappings(getClusters0); - }); - - assertEquals(req.getPath(), "/1/clusters/mapping/pending"); - assertEquals(req.getMethod(), "GET"); - - - HashMap expectedQuery = JSON.deserialize("{\"getClusters\":\"true\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("listApiKeys") - void listApiKeysTest0() { - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listApiKeys(); - }); - - assertEquals(req.getPath(), "/1/keys"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("listClusters") - void listClustersTest0() { - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listClusters(); - }); - - assertEquals(req.getPath(), "/1/clusters"); - assertEquals(req.getMethod(), "GET"); - - - } - @Test - @DisplayName("listIndices") - void listIndicesTest0() { - -int page0 = 8; - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listIndices(page0); - }); - - assertEquals(req.getPath(), "/1/indexes"); - assertEquals(req.getMethod(), "GET"); - - - HashMap expectedQuery = JSON.deserialize("{\"page\":\"8\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("listUserIds") - void listUserIdsTest0() { - -int page0 = 8; - - - - - - -int hitsPerPage0 = 100; - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listUserIds(page0,hitsPerPage0); - }); - - assertEquals(req.getPath(), "/1/clusters/mapping"); - assertEquals(req.getMethod(), "GET"); - - - HashMap expectedQuery = JSON.deserialize("{\"page\":\"8\",\"hitsPerPage\":\"100\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("multipleBatch") - void multipleBatchTest0() { - - - - - - - -BatchParams batchParams0 = new BatchParams(); -{ - - - - - -List - requests1 = new ArrayList<>(); { - - - - - - -MultipleBatchOperation requests_02 = new MultipleBatchOperation(); -{ - - - - -Action action3 = Action.fromValue("addObject"); - -requests_02.setAction(action3); - - - - - - - -Map body3 = new HashMap<>(); -{ String key4 = "value"; - - - - - - -body3.put("key", key4); - }requests_02.setBody(body3); -String indexName3 = "theIndexName"; - - - - - - -requests_02.setIndexName(indexName3); - }requests1.add(requests_02); } -batchParams0.setRequests(requests1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.multipleBatch(batchParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("multipleQueries") - void multipleQueriesTest0() { - - - - - - - -MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); -{ - - - - - -List - requests1 = new ArrayList<>(); { - - - - - - -MultipleQueries requests_02 = new MultipleQueries(); -{ String indexName3 = "theIndexName"; - - - - - - -requests_02.setIndexName(indexName3); -String query3 = "test"; - - - - - - -requests_02.setQuery(query3); - - - - - -MultipleQueriesType type3 = MultipleQueriesType.fromValue("facet"); - -requests_02.setType(type3); -String facet3 = "theFacet"; - - - - - - -requests_02.setFacet(facet3); -String params3 = "testParam"; - - - - - - -requests_02.setParams(params3); - }requests1.add(requests_02); } -multipleQueriesParams0.setRequests(requests1); - - - - - -MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue("stopIfEnoughMatches"); - -multipleQueriesParams0.setStrategy(strategy1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.multipleQueries(multipleQueriesParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/*/queries"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("operationIndex") - void operationIndexTest0() { - String indexName0 = "theIndexName"; - - - - - - - - - - - - - -OperationIndexParams operationIndexParams0 = new OperationIndexParams(); -{ - - - - -OperationType operation1 = OperationType.fromValue("copy"); - -operationIndexParams0.setOperation(operation1); -String destination1 = "dest"; - - - - - - -operationIndexParams0.setDestination(destination1); - - - - - - -List - scope1 = new ArrayList<>(); { - - - - -ScopeType scope_02 = ScopeType.fromValue("rules"); - -scope1.add(scope_02); - - - - -ScopeType scope_12 = ScopeType.fromValue("settings"); - -scope1.add(scope_12); } -operationIndexParams0.setScope(scope1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.operationIndex(indexName0,operationIndexParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("partialUpdateObject") - void partialUpdateObjectTest0() { - String indexName0 = "theIndexName"; - - - - - - -String objectID0 = "uniqueID"; - - - - - - - - - - - - -List> - attributeOrBuiltInOperation0 = new ArrayList<>(); { - - - - - - -Map attributeOrBuiltInOperation_01 = new HashMap<>(); -{ String id12 = "test"; - - - - - - -attributeOrBuiltInOperation_01.put("id1", .of(id12)); - - - - - - - -BuiltInOperation id22 = new BuiltInOperation(); -{ - - - - -BuiltInOperationType operation3 = BuiltInOperationType.fromValue("AddUnique"); - -id22.setOperation(operation3); -String value3 = "test2"; - - - - - - -id22.setValue(value3); - }attributeOrBuiltInOperation_01.put("id2", .of(id22)); - }attributeOrBuiltInOperation0.add(attributeOrBuiltInOperation_01); } - - - - -boolean createIfNotExists0 = true; - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.partialUpdateObject(indexName0,objectID0,attributeOrBuiltInOperation0,createIfNotExists0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID/partial"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - HashMap expectedQuery = JSON.deserialize("{\"createIfNotExists\":\"true\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - - - - - -Map body0 = new HashMap<>(); -{ String body1 = "parameters"; - - - - - - -body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0,parameters0,body0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("allow put method for a custom path with minimal parameters") - void putTest0() { - String path0 = "/test/minimal"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); - }); - - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "PUT"); - - - } - @Test - @DisplayName("allow put method for a custom path with all parameters") - void putTest1() { - String path0 = "/test/all"; - - - - - - - - - - - - - -Map parameters0 = new HashMap<>(); -{ String query1 = "parameters"; - - - - - - -parameters0.put("query", query1); - } - - - - - - -Map body0 = new HashMap<>(); -{ String body1 = "parameters"; - - - - - - -body0.put("body", body1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0,parameters0,body0); - }); - - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - - - } - @Test - @DisplayName("removeUserId") - void removeUserIdTest0() { - String userID0 = "uniqueID"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.removeUserId(userID0); - }); - - assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); - assertEquals(req.getMethod(), "DELETE"); - - - } - @Test - @DisplayName("replaceSources") - void replaceSourcesTest0() { - - - - - - -List - source0 = new ArrayList<>(); { - - - - - - -Source source_01 = new Source(); -{ String source2 = "theSource"; - - - - - - -source_01.setSource(source2); -String description2 = "theDescription"; - - - - - - -source_01.setDescription(description2); - }source0.add(source_01); } - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.replaceSources(source0); - }); - - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("restoreApiKey") - void restoreApiKeyTest0() { - String key0 = "myApiKey"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.restoreApiKey(key0); - }); - - assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("saveObject") - void saveObjectTest0() { - String indexName0 = "theIndexName"; - - - - - - - - - - - - - -Map body0 = new HashMap<>(); -{ String objectID1 = "id"; - - - - - - -body0.put("objectID", objectID1); -String test1 = "val"; - - - - - - -body0.put("test", test1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveObject(indexName0,body0); - }); - - assertEquals(req.getPath(), "/1/indexes/theIndexName"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"objectID\":\"id\",\"test\":\"val\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("saveRule") - void saveRuleTest0() { - String indexName0 = "indexName"; - - - - - - -String objectID0 = "id1"; - - - - - - - - - - - - - -Rule rule0 = new Rule(); -{ String objectID1 = "id1"; - - - - - - -rule0.setObjectID(objectID1); - - - - - - -List - conditions1 = new ArrayList<>(); { - - - - - - -Condition conditions_02 = new Condition(); -{ String pattern3 = "apple"; - - - - - - -conditions_02.setPattern(pattern3); - - - - - -Anchoring anchoring3 = Anchoring.fromValue("contains"); - -conditions_02.setAnchoring(anchoring3); - }conditions1.add(conditions_02); } -rule0.setConditions(conditions1); - - - - - - - -Consequence consequence1 = new Consequence(); -{ - - - - - - -ConsequenceParams params2 = new ConsequenceParams(); -{ String filters3 = "brand:apple"; - - - - - - -params2.setFilters(filters3); - }consequence1.setParams(params2); - }rule0.setConsequence(consequence1); - } - - - -boolean forwardToReplicas0 = true; - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveRule(indexName0,objectID0,rule0,forwardToReplicas0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"objectID\":\"id1\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("saveSynonym") - void saveSynonymTest0() { - String indexName0 = "indexName"; - - - - - - -String objectID0 = "id1"; - - - - - - - - - - - - - -SynonymHit synonymHit0 = new SynonymHit(); -{ String objectID1 = "id1"; - - - - - - -synonymHit0.setObjectID(objectID1); - - - - - -SynonymType type1 = SynonymType.fromValue("synonym"); - -synonymHit0.setType(type1); - - - - - - -List - synonyms1 = new ArrayList<>(); { String synonyms_02 = "car"; - - - - - - -synonyms1.add(synonyms_02);String synonyms_12 = "vehicule"; - - - - - - -synonyms1.add(synonyms_12);String synonyms_22 = "auto"; - - - - - - -synonyms1.add(synonyms_22); } -synonymHit0.setSynonyms(synonyms1); - } - - - -boolean forwardToReplicas0 = true; - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonym(indexName0,objectID0,synonymHit0,forwardToReplicas0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("saveSynonyms") - void saveSynonymsTest0() { - String indexName0 = "indexName"; - - - - - - - - - - - - -List - synonymHit0 = new ArrayList<>(); { - - - - - - -SynonymHit synonymHit_01 = new SynonymHit(); -{ String objectID2 = "id1"; - - - - - - -synonymHit_01.setObjectID(objectID2); - - - - - -SynonymType type2 = SynonymType.fromValue("synonym"); - -synonymHit_01.setType(type2); - - - - - - -List - synonyms2 = new ArrayList<>(); { String synonyms_03 = "car"; - - - - - - -synonyms2.add(synonyms_03);String synonyms_13 = "vehicule"; - - - - - - -synonyms2.add(synonyms_13);String synonyms_23 = "auto"; - - - - - - -synonyms2.add(synonyms_23); } -synonymHit_01.setSynonyms(synonyms2); - }synonymHit0.add(synonymHit_01); - - - - - - -SynonymHit synonymHit_11 = new SynonymHit(); -{ String objectID2 = "id2"; - - - - - - -synonymHit_11.setObjectID(objectID2); - - - - - -SynonymType type2 = SynonymType.fromValue("onewaysynonym"); - -synonymHit_11.setType(type2); -String input2 = "iphone"; - - - - - - -synonymHit_11.setInput(input2); - - - - - - -List - synonyms2 = new ArrayList<>(); { String synonyms_03 = "ephone"; - - - - - - -synonyms2.add(synonyms_03);String synonyms_13 = "aphone"; - - - - - - -synonyms2.add(synonyms_13);String synonyms_23 = "yphone"; - - - - - - -synonyms2.add(synonyms_23); } -synonymHit_11.setSynonyms(synonyms2); - }synonymHit0.add(synonymHit_11); } - - - - -boolean forwardToReplicas0 = true; - - - - - - -boolean replaceExistingSynonyms0 = false; - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonyms(indexName0,synonymHit0,forwardToReplicas0,replaceExistingSynonyms0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); - } - } - @Test - @DisplayName("search with minimal parameters") - void searchTest0() { - String indexName0 = "indexName"; - - - - - - - - - - - - - -SearchParamsObject searchParams0 = new SearchParamsObject(); -{ String query1 = "myQuery"; - - - - - - -searchParams0.setQuery(query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search(indexName0,.of(searchParams0)); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/query"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"query\":\"myQuery\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("search with facetFilters") - void searchTest1() { - String indexName0 = "indexName"; - - - - - - - - - - - - - -SearchParamsObject searchParams0 = new SearchParamsObject(); -{ String query1 = "myQuery"; - - - - - - -searchParams0.setQuery(query1); - - - - - - -List - facetFilters1 = new ArrayList<>(); { String facetFilters_02 = "tags:algolia"; - - - - - - -facetFilters1.add(facetFilters_02); } -searchParams0.setFacetFilters(.of(facetFilters1)); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search(indexName0,.of(searchParams0)); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/query"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("get searchDictionaryEntries results with minimal parameters") - void searchDictionaryEntriesTest0() { - - - - - -DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - - - - - - - -SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); -{ String query1 = "foo"; - - - - - - -searchDictionaryEntriesParams0.setQuery(query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchDictionaryEntries(dictionaryName0,searchDictionaryEntriesParams0); - }); - - assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"query\":\"foo\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("get searchDictionaryEntries results with all parameters") - void searchDictionaryEntriesTest1() { - - - - - -DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - - - - - - - -SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); -{ String query1 = "foo"; - - - - - - -searchDictionaryEntriesParams0.setQuery(query1); - -int page1 = 4; - - - - - -searchDictionaryEntriesParams0.setPage(page1); - -int hitsPerPage1 = 2; - - - - - -searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); -String language1 = "fr"; - - - - - - -searchDictionaryEntriesParams0.setLanguage(language1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchDictionaryEntries(dictionaryName0,searchDictionaryEntriesParams0); - }); - - assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"query\":\"foo\",\"page\":4,\"hitsPerPage\":2,\"language\":\"fr\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("get searchForFacetValues results with minimal parameters") - void searchForFacetValuesTest0() { - String indexName0 = "indexName"; - - - - - - -String facetName0 = "facetName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchForFacetValues(indexName0,facetName0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("get searchForFacetValues results with all parameters") - void searchForFacetValuesTest1() { - String indexName0 = "indexName"; - - - - - - -String facetName0 = "facetName"; - - - - - - - - - - - - - -SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); -{ String params1 = "query=foo&facetFilters=['bar']"; - - - - - - -searchForFacetValuesRequest0.setParams(params1); -String facetQuery1 = "foo"; - - - - - - -searchForFacetValuesRequest0.setFacetQuery(facetQuery1); - -int maxFacetHits1 = 42; - - - - - -searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchForFacetValues(indexName0,facetName0,searchForFacetValuesRequest0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("searchRules") - void searchRulesTest0() { - String indexName0 = "indexName"; - - - - - - - - - - - - - -SearchRulesParams searchRulesParams0 = new SearchRulesParams(); -{ String query1 = "something"; - - - - - - -searchRulesParams0.setQuery(query1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchRules(indexName0,searchRulesParams0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"query\":\"something\"}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("searchSynonyms") - void searchSynonymsTest0() { - String indexName0 = "indexName"; - - - - - - - - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchSynonyms(indexName0); - }); - - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/search"); - assertEquals(req.getMethod(), "POST"); - - - } - @Test - @DisplayName("searchUserIds") - void searchUserIdsTest0() { - - - - - - - -SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); -{ String query1 = "test"; - - - - - - -searchUserIdsParams0.setQuery(query1); -String clusterName1 = "theClusterName"; - - - - - - -searchUserIdsParams0.setClusterName(clusterName1); - -int page1 = 5; - - - - - -searchUserIdsParams0.setPage(page1); - -int hitsPerPage1 = 10; - - - - - -searchUserIdsParams0.setHitsPerPage(hitsPerPage1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchUserIds(searchUserIdsParams0); - }); - - assertEquals(req.getPath(), "/1/clusters/mapping/search"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - - } - @Test - @DisplayName("get setDictionarySettings results with minimal parameters") - void setDictionarySettingsTest0() { - - - - - - - -DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); -{ - - - - - - -StandardEntries disableStandardEntries1 = new StandardEntries(); -{ - - - - - - -Map plurals2 = new HashMap<>(); -{ - - - -boolean fr3 = false; - - -plurals2.put("fr", fr3); - - - - -boolean en3 = false; - - -plurals2.put("en", en3); - - - - -boolean ru3 = true; - - -plurals2.put("ru", ru3); - }disableStandardEntries1.setPlurals(plurals2); - }dictionarySettingsParams0.setDisableStandardEntries(disableStandardEntries1); - } - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(dictionarySettingsParams0); - }); - - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); - + facetFilters1.add(facetFilters_02); + } + searchParams0.setFacetFilters(FacetFilters.ofListString(facetFilters1)); } - @Test - @DisplayName("get setDictionarySettings results with all parameters") - void setDictionarySettingsTest1() { - - - - - - - -DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); -{ - - - - - - -StandardEntries disableStandardEntries1 = new StandardEntries(); -{ - - - - - - -Map plurals2 = new HashMap<>(); -{ - - - -boolean fr3 = false; - - -plurals2.put("fr", fr3); - - - - -boolean en3 = false; - - -plurals2.put("en", en3); - - - - -boolean ru3 = true; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.search( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); + } + ); -plurals2.put("ru", ru3); - }disableStandardEntries1.setPlurals(plurals2); + assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getMethod(), "POST"); + } + @Test + @DisplayName("get searchDictionaryEntries results with minimal parameters") + void searchDictionaryEntriesTest0() { + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); + { + String query1 = "foo"; + searchDictionaryEntriesParams0.setQuery(query1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchDictionaryEntries( + dictionaryName0, + searchDictionaryEntriesParams0 + ); + } + ); + assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"foo\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } -Map stopwords2 = new HashMap<>(); -{ + @Test + @DisplayName("get searchDictionaryEntries results with all parameters") + void searchDictionaryEntriesTest1() { + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); + { + String query1 = "foo"; + searchDictionaryEntriesParams0.setQuery(query1); -boolean fr3 = false; + int page1 = 4; + searchDictionaryEntriesParams0.setPage(page1); -stopwords2.put("fr", fr3); - }disableStandardEntries1.setStopwords(stopwords2); + int hitsPerPage1 = 2; + searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); + String language1 = "fr"; + searchDictionaryEntriesParams0.setLanguage(language1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchDictionaryEntries( + dictionaryName0, + searchDictionaryEntriesParams0 + ); + } + ); + assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"foo\",\"page\":4,\"hitsPerPage\":2,\"language\":\"fr\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("get searchForFacetValues results with minimal parameters") + void searchForFacetValuesTest0() { + String indexName0 = "indexName"; -Map compounds2 = new HashMap<>(); -{ + String facetName0 = "facetName"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchForFacetValues(indexName0, facetName0); + } + ); + assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); + assertEquals(req.getMethod(), "POST"); + } -boolean ru3 = true; + @Test + @DisplayName("get searchForFacetValues results with all parameters") + void searchForFacetValuesTest1() { + String indexName0 = "indexName"; + String facetName0 = "facetName"; -compounds2.put("ru", ru3); - }disableStandardEntries1.setCompounds(compounds2); - }dictionarySettingsParams0.setDisableStandardEntries(disableStandardEntries1); - } + SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); + { + String params1 = "query=foo&facetFilters=['bar']"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(dictionarySettingsParams0); - }); + searchForFacetValuesRequest0.setParams(params1); + String facetQuery1 = "foo"; - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "PUT"); + searchForFacetValuesRequest0.setFacetQuery(facetQuery1); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + int maxFacetHits1 = 42; + searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); } - @Test - @DisplayName("setSettings") - void setSettingsTest0() { - String indexName0 = "theIndexName"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchForFacetValues( + indexName0, + facetName0, + searchForFacetValuesRequest0 + ); + } + ); + assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("searchRules") + void searchRulesTest0() { + String indexName0 = "indexName"; + SearchRulesParams searchRulesParams0 = new SearchRulesParams(); + { + String query1 = "something"; + searchRulesParams0.setQuery(query1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchRules(indexName0, searchRulesParams0); + } + ); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"something\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("searchSynonyms") + void searchSynonymsTest0() { + String indexName0 = "indexName"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchSynonyms(indexName0); + } + ); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/search"); + assertEquals(req.getMethod(), "POST"); + } -IndexSettings indexSettings0 = new IndexSettings(); -{ -int paginationLimitedTo1 = 10; + @Test + @DisplayName("searchUserIds") + void searchUserIdsTest0() { + SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); + { + String query1 = "test"; + searchUserIdsParams0.setQuery(query1); + String clusterName1 = "theClusterName"; + searchUserIdsParams0.setClusterName(clusterName1); + int page1 = 5; + searchUserIdsParams0.setPage(page1); -indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); - } + int hitsPerPage1 = 10; + searchUserIdsParams0.setHitsPerPage(hitsPerPage1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.searchUserIds(searchUserIdsParams0); + } + ); -boolean forwardToReplicas0 = true; + assertEquals(req.getPath(), "/1/clusters/mapping/search"); + assertEquals(req.getMethod(), "POST"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("get setDictionarySettings results with minimal parameters") + void setDictionarySettingsTest0() { + DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); + { + StandardEntries disableStandardEntries1 = new StandardEntries(); + { + Map plurals2 = new HashMap<>(); + { + boolean fr3 = false; + plurals2.put("fr", fr3); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setSettings(indexName0,indexSettings0,forwardToReplicas0); - }); + boolean en3 = false; - assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); - assertEquals(req.getMethod(), "PUT"); + plurals2.put("en", en3); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"paginationLimitedTo\":10}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + boolean ru3 = true; - HashMap expectedQuery = JSON.deserialize("{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType()); - List actualQuery = req.getQueryParams(); - assertEquals(expectedQuery.size(), actualQuery.size()); - for (Pair p : actualQuery) { - assertEquals(expectedQuery.get(p.getName()), p.getValue()); + plurals2.put("ru", ru3); } + disableStandardEntries1.setPlurals(plurals2); + } + dictionarySettingsParams0.setDisableStandardEntries( + disableStandardEntries1 + ); } - @Test - @DisplayName("updateApiKey") - void updateApiKeyTest0() { - String key0 = "myApiKey"; - - - - - - - - - - - - -ApiKey apiKey0 = new ApiKey(); -{ + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.setDictionarySettings(dictionarySettingsParams0); + } + ); + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "PUT"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + @Test + @DisplayName("get setDictionarySettings results with all parameters") + void setDictionarySettingsTest1() { + DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); + { + StandardEntries disableStandardEntries1 = new StandardEntries(); + { + Map plurals2 = new HashMap<>(); + { + boolean fr3 = false; + plurals2.put("fr", fr3); -List - acl1 = new ArrayList<>(); { + boolean en3 = false; + plurals2.put("en", en3); + boolean ru3 = true; + plurals2.put("ru", ru3); + } + disableStandardEntries1.setPlurals(plurals2); -Acl acl_02 = Acl.fromValue("search"); + Map stopwords2 = new HashMap<>(); + { + boolean fr3 = false; -acl1.add(acl_02); + stopwords2.put("fr", fr3); + } + disableStandardEntries1.setStopwords(stopwords2); + Map compounds2 = new HashMap<>(); + { + boolean ru3 = true; + compounds2.put("ru", ru3); + } + disableStandardEntries1.setCompounds(compounds2); + } + dictionarySettingsParams0.setDisableStandardEntries( + disableStandardEntries1 + ); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.setDictionarySettings(dictionarySettingsParams0); + } + ); -Acl acl_12 = Acl.fromValue("addObject"); + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "PUT"); -acl1.add(acl_12); } -apiKey0.setAcl(acl1); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } -int validity1 = 300; + @Test + @DisplayName("setSettings") + void setSettingsTest0() { + String indexName0 = "theIndexName"; + IndexSettings indexSettings0 = new IndexSettings(); + { + int paginationLimitedTo1 = 10; + indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); + } + boolean forwardToReplicas0 = true; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.setSettings( + indexName0, + indexSettings0, + forwardToReplicas0 + ); + } + ); -apiKey0.setValidity(validity1); + assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); + assertEquals(req.getMethod(), "PUT"); -int maxQueriesPerIPPerHour1 = 100; + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"paginationLimitedTo\":10}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + HashMap expectedQuery = JSON.deserialize( + "{\"forwardToReplicas\":\"true\"}", + new TypeToken>() {}.getType() + ); + List actualQuery = req.getQueryParams(); + assertEquals(expectedQuery.size(), actualQuery.size()); + for (Pair p : actualQuery) { + assertEquals(expectedQuery.get(p.getName()), p.getValue()); + } + } + @Test + @DisplayName("updateApiKey") + void updateApiKeyTest0() { + String key0 = "myApiKey"; + ApiKey apiKey0 = new ApiKey(); + { + List acl1 = new ArrayList<>(); + { + Acl acl_02 = Acl.fromValue("search"); + acl1.add(acl_02); -apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); + Acl acl_12 = Acl.fromValue("addObject"); -int maxHitsPerQuery1 = 20; + acl1.add(acl_12); + } + apiKey0.setAcl(acl1); + int validity1 = 300; + apiKey0.setValidity(validity1); + int maxQueriesPerIPPerHour1 = 100; + apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); -apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); - } + int maxHitsPerQuery1 = 20; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.updateApiKey(key0,apiKey0); - }); + apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); + } - assertEquals(req.getPath(), "/1/keys/myApiKey"); - assertEquals(req.getMethod(), "PUT"); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.updateApiKey(key0, apiKey0); + } + ); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", req.getBody(), JSONCompareMode.STRICT_ORDER); - }); + assertEquals(req.getPath(), "/1/keys/myApiKey"); + assertEquals(req.getMethod(), "PUT"); - } + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } } From 53733bf388a03abb023a6540174797d2a8696a59 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Fri, 15 Apr 2022 17:11:59 +0200 Subject: [PATCH 09/14] fix cache maybe --- scripts/ci/createMatrix.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/createMatrix.ts b/scripts/ci/createMatrix.ts index 74143bd598..ca401d8b51 100644 --- a/scripts/ci/createMatrix.ts +++ b/scripts/ci/createMatrix.ts @@ -40,7 +40,7 @@ async function getClientMatrix({ for (const { language, client, output } of Object.values(GENERATORS)) { // `algoliasearch` is an aggregation of clients - if (language !== forLanguage || client === 'algoliasearch') { + if (forLanguage !== language || client === 'algoliasearch') { continue; } From b4534c4ac637017b467c1ee4e5954084276bdb64 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 27 Apr 2022 15:22:39 +0200 Subject: [PATCH 10/14] remove method on custom request --- scripts/ci/createMatrix.ts | 2 +- tests/CTS/methods/requests/common/del.json | 2 -- tests/CTS/methods/requests/common/get.json | 2 -- tests/CTS/methods/requests/common/post.json | 2 -- tests/CTS/methods/requests/common/put.json | 2 -- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/ci/createMatrix.ts b/scripts/ci/createMatrix.ts index ca401d8b51..74143bd598 100644 --- a/scripts/ci/createMatrix.ts +++ b/scripts/ci/createMatrix.ts @@ -40,7 +40,7 @@ async function getClientMatrix({ for (const { language, client, output } of Object.values(GENERATORS)) { // `algoliasearch` is an aggregation of clients - if (forLanguage !== language || client === 'algoliasearch') { + if (language !== forLanguage || client === 'algoliasearch') { continue; } diff --git a/tests/CTS/methods/requests/common/del.json b/tests/CTS/methods/requests/common/del.json index d0c32c399b..53e2bdf5e3 100644 --- a/tests/CTS/methods/requests/common/del.json +++ b/tests/CTS/methods/requests/common/del.json @@ -1,6 +1,5 @@ [ { - "method": "del", "testName": "allow del method for a custom path with minimal parameters", "parameters": { "path": "/test/minimal" @@ -11,7 +10,6 @@ } }, { - "method": "del", "testName": "allow del method for a custom path with all parameters", "parameters": { "path": "/test/all", diff --git a/tests/CTS/methods/requests/common/get.json b/tests/CTS/methods/requests/common/get.json index 35056e57d2..060a4e483f 100644 --- a/tests/CTS/methods/requests/common/get.json +++ b/tests/CTS/methods/requests/common/get.json @@ -1,6 +1,5 @@ [ { - "method": "get", "testName": "allow get method for a custom path with minimal parameters", "parameters": { "path": "/test/minimal" @@ -11,7 +10,6 @@ } }, { - "method": "get", "testName": "allow get method for a custom path with all parameters", "parameters": { "path": "/test/all", diff --git a/tests/CTS/methods/requests/common/post.json b/tests/CTS/methods/requests/common/post.json index 8a981c4414..7aa7fb7614 100644 --- a/tests/CTS/methods/requests/common/post.json +++ b/tests/CTS/methods/requests/common/post.json @@ -1,6 +1,5 @@ [ { - "method": "post", "testName": "allow post method for a custom path with minimal parameters", "parameters": { "path": "/test/minimal" @@ -11,7 +10,6 @@ } }, { - "method": "post", "testName": "allow post method for a custom path with all parameters", "parameters": { "path": "/test/all", diff --git a/tests/CTS/methods/requests/common/put.json b/tests/CTS/methods/requests/common/put.json index 6e88f94747..d84b4c00dc 100644 --- a/tests/CTS/methods/requests/common/put.json +++ b/tests/CTS/methods/requests/common/put.json @@ -1,6 +1,5 @@ [ { - "method": "put", "testName": "allow put method for a custom path with minimal parameters", "parameters": { "path": "/test/minimal" @@ -11,7 +10,6 @@ } }, { - "method": "put", "testName": "allow put method for a custom path with all parameters", "parameters": { "path": "/test/all", From 7bb3e773406c1b9d9b10ea0ca9370c2396289e8c Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 27 Apr 2022 16:42:27 +0200 Subject: [PATCH 11/14] generate --- tests/CTS/methods/requests/search/search.json | 2 +- .../requests/templates/php/requests.mustache | 12 +-- .../algolia/methods/requests/search.test.java | 8 ++ .../src/methods/requests/search.test.ts | 2 +- .../src/methods/requests/AbtestingTest.php | 10 +-- .../src/methods/requests/AnalyticsTest.php | 78 +++++++++---------- .../php/src/methods/requests/InsightsTest.php | 8 +- .../methods/requests/PersonalizationTest.php | 8 +- .../methods/requests/QuerySuggestionsTest.php | 8 +- .../src/methods/requests/RecommendTest.php | 8 +- .../php/src/methods/requests/SearchTest.php | 34 ++++---- 11 files changed, 93 insertions(+), 85 deletions(-) diff --git a/tests/CTS/methods/requests/search/search.json b/tests/CTS/methods/requests/search/search.json index d279a668ce..cb550a42d8 100644 --- a/tests/CTS/methods/requests/search/search.json +++ b/tests/CTS/methods/requests/search/search.json @@ -30,7 +30,7 @@ "request": { "path": "/1/indexes/indexName/query", "method": "POST", - "data": { + "body": { "query": "myQuery", "facetFilters": [ "tags:algolia" diff --git a/tests/CTS/methods/requests/templates/php/requests.mustache b/tests/CTS/methods/requests/templates/php/requests.mustache index bb4dd19608..e34c52b637 100644 --- a/tests/CTS/methods/requests/templates/php/requests.mustache +++ b/tests/CTS/methods/requests/templates/php/requests.mustache @@ -85,12 +85,12 @@ class {{clientPrefix}}Test extends TestCase implements HttpClientInterface [ "path" => "{{{request.path}}}", "method" => "{{{request.method}}}", - {{#request.data}} - "body" => json_decode("{{#lambda.escapequotes}}{{{request.data}}}{{/lambda.escapequotes}}"), - {{/request.data}} - {{#request.searchParams}} - "searchParams" => json_decode("{{#lambda.escapequotes}}{{{request.searchParams}}}{{/lambda.escapequotes}}"), - {{/request.searchParams}} + {{#request.body}} + "body" => json_decode("{{#lambda.escapequotes}}{{{request.body}}}{{/lambda.escapequotes}}"), + {{/request.body}} + {{#request.queryParameters}} + "queryParameters" => json_decode("{{#lambda.escapequotes}}{{{request.queryParameters}}}{{/lambda.escapequotes}}"), + {{/request.queryParameters}} ], ]); } diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index 05c4693600..ad1d272f89 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -1982,6 +1982,14 @@ void searchTest1() { assertEquals(req.getPath(), "/1/indexes/indexName/query"); assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index 22bffc9e40..1312cf488a 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -1037,7 +1037,7 @@ describe('search', () => { query: 'myQuery', facetFilters: ['tags:algolia'], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toStrictEqual(undefined); }); }); diff --git a/tests/output/php/src/methods/requests/AbtestingTest.php b/tests/output/php/src/methods/requests/AbtestingTest.php index 255937ad9b..4336e8f52a 100644 --- a/tests/output/php/src/methods/requests/AbtestingTest.php +++ b/tests/output/php/src/methods/requests/AbtestingTest.php @@ -142,7 +142,7 @@ public function testDel1() [ 'path' => '/1/test/all', 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -200,7 +200,7 @@ public function testGet1() [ 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -240,7 +240,7 @@ public function testListABTests0() [ 'path' => '/2/abtests', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"offset\":\"42\",\"limit\":\"21\"}" ), ], @@ -284,7 +284,7 @@ public function testPost1() 'path' => '/1/test/all', 'method' => 'POST', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -326,7 +326,7 @@ public function testPut1() 'path' => '/1/test/all', 'method' => 'PUT', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } diff --git a/tests/output/php/src/methods/requests/AnalyticsTest.php b/tests/output/php/src/methods/requests/AnalyticsTest.php index a64a4ff459..03fe2145b8 100644 --- a/tests/output/php/src/methods/requests/AnalyticsTest.php +++ b/tests/output/php/src/methods/requests/AnalyticsTest.php @@ -111,7 +111,7 @@ public function testDel1() [ 'path' => '/1/test/all', 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -151,7 +151,7 @@ public function testGet1() [ 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -170,7 +170,7 @@ public function testGetAverageClickPosition0() [ 'path' => '/2/clicks/averageClickPosition', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -194,7 +194,7 @@ public function testGetAverageClickPosition1() [ 'path' => '/2/clicks/averageClickPosition', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -215,7 +215,7 @@ public function testGetClickPositions0() [ 'path' => '/2/clicks/positions', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -239,7 +239,7 @@ public function testGetClickPositions1() [ 'path' => '/2/clicks/positions', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -260,7 +260,7 @@ public function testGetClickThroughRate0() [ 'path' => '/2/clicks/clickThroughRate', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -284,7 +284,7 @@ public function testGetClickThroughRate1() [ 'path' => '/2/clicks/clickThroughRate', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -305,7 +305,7 @@ public function testGetConversationRate0() [ 'path' => '/2/conversions/conversionRate', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -329,7 +329,7 @@ public function testGetConversationRate1() [ 'path' => '/2/conversions/conversionRate', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -350,7 +350,7 @@ public function testGetNoClickRate0() [ 'path' => '/2/searches/noClickRate', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -374,7 +374,7 @@ public function testGetNoClickRate1() [ 'path' => '/2/searches/noClickRate', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -395,7 +395,7 @@ public function testGetNoResultsRate0() [ 'path' => '/2/searches/noResultRate', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -419,7 +419,7 @@ public function testGetNoResultsRate1() [ 'path' => '/2/searches/noResultRate', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -440,7 +440,7 @@ public function testGetSearchesCount0() [ 'path' => '/2/searches/count', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -464,7 +464,7 @@ public function testGetSearchesCount1() [ 'path' => '/2/searches/count', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -485,7 +485,7 @@ public function testGetSearchesNoClicks0() [ 'path' => '/2/searches/noClicks', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -511,7 +511,7 @@ public function testGetSearchesNoClicks1() [ 'path' => '/2/searches/noClicks', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -532,7 +532,7 @@ public function testGetSearchesNoResults0() [ 'path' => '/2/searches/noResults', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -558,7 +558,7 @@ public function testGetSearchesNoResults1() [ 'path' => '/2/searches/noResults', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -579,7 +579,7 @@ public function testGetStatus0() [ 'path' => '/2/status', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -598,7 +598,7 @@ public function testGetTopCountries0() [ 'path' => '/2/countries', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -624,7 +624,7 @@ public function testGetTopCountries1() [ 'path' => '/2/countries', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -645,7 +645,7 @@ public function testGetTopFilterAttributes0() [ 'path' => '/2/filters', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -672,7 +672,7 @@ public function testGetTopFilterAttributes1() [ 'path' => '/2/filters', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -696,7 +696,7 @@ public function testGetTopFilterForAttribute0() [ 'path' => '/2/filters/myAttribute', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -718,7 +718,7 @@ public function testGetTopFilterForAttribute1() [ 'path' => '/2/filters/myAttribute1%2CmyAttribute2', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -746,7 +746,7 @@ public function testGetTopFilterForAttribute2() [ 'path' => '/2/filters/myAttribute', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -776,7 +776,7 @@ public function testGetTopFilterForAttribute3() [ 'path' => '/2/filters/myAttribute1%2CmyAttribute2', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -797,7 +797,7 @@ public function testGetTopFiltersNoResults0() [ 'path' => '/2/filters/noResults', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -824,7 +824,7 @@ public function testGetTopFiltersNoResults1() [ 'path' => '/2/filters/noResults', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -845,7 +845,7 @@ public function testGetTopHits0() [ 'path' => '/2/hits', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -873,7 +873,7 @@ public function testGetTopHits1() [ 'path' => '/2/hits', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -894,7 +894,7 @@ public function testGetTopSearches0() [ 'path' => '/2/searches', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -923,7 +923,7 @@ public function testGetTopSearches1() [ 'path' => '/2/searches', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], @@ -944,7 +944,7 @@ public function testGetUsersCount0() [ 'path' => '/2/users/count', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'queryParameters' => json_decode("{\"index\":\"index\"}"), ], ]); } @@ -968,7 +968,7 @@ public function testGetUsersCount1() [ 'path' => '/2/users/count', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], @@ -1012,7 +1012,7 @@ public function testPost1() 'path' => '/1/test/all', 'method' => 'POST', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -1054,7 +1054,7 @@ public function testPut1() 'path' => '/1/test/all', 'method' => 'PUT', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } diff --git a/tests/output/php/src/methods/requests/InsightsTest.php b/tests/output/php/src/methods/requests/InsightsTest.php index 3c091e364d..1eb277e3c5 100644 --- a/tests/output/php/src/methods/requests/InsightsTest.php +++ b/tests/output/php/src/methods/requests/InsightsTest.php @@ -111,7 +111,7 @@ public function testDel1() [ 'path' => '/1/test/all', 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -151,7 +151,7 @@ public function testGet1() [ 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -193,7 +193,7 @@ public function testPost1() 'path' => '/1/test/all', 'method' => 'POST', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -306,7 +306,7 @@ public function testPut1() 'path' => '/1/test/all', 'method' => 'PUT', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } diff --git a/tests/output/php/src/methods/requests/PersonalizationTest.php b/tests/output/php/src/methods/requests/PersonalizationTest.php index 01795adbdc..65977b3b80 100644 --- a/tests/output/php/src/methods/requests/PersonalizationTest.php +++ b/tests/output/php/src/methods/requests/PersonalizationTest.php @@ -111,7 +111,7 @@ public function testDel1() [ 'path' => '/1/test/all', 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -169,7 +169,7 @@ public function testGet1() [ 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -247,7 +247,7 @@ public function testPost1() 'path' => '/1/test/all', 'method' => 'POST', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -289,7 +289,7 @@ public function testPut1() 'path' => '/1/test/all', 'method' => 'PUT', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } diff --git a/tests/output/php/src/methods/requests/QuerySuggestionsTest.php b/tests/output/php/src/methods/requests/QuerySuggestionsTest.php index 16d7d2ed13..2e46154a3e 100644 --- a/tests/output/php/src/methods/requests/QuerySuggestionsTest.php +++ b/tests/output/php/src/methods/requests/QuerySuggestionsTest.php @@ -148,7 +148,7 @@ public function testDel1() [ 'path' => '/1/test/all', 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -206,7 +206,7 @@ public function testGet1() [ 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -320,7 +320,7 @@ public function testPost1() 'path' => '/1/test/all', 'method' => 'POST', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -362,7 +362,7 @@ public function testPut1() 'path' => '/1/test/all', 'method' => 'PUT', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } diff --git a/tests/output/php/src/methods/requests/RecommendTest.php b/tests/output/php/src/methods/requests/RecommendTest.php index 70b6fe932d..e0bdb28494 100644 --- a/tests/output/php/src/methods/requests/RecommendTest.php +++ b/tests/output/php/src/methods/requests/RecommendTest.php @@ -111,7 +111,7 @@ public function testDel1() [ 'path' => '/1/test/all', 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -151,7 +151,7 @@ public function testGet1() [ 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -500,7 +500,7 @@ public function testPost1() 'path' => '/1/test/all', 'method' => 'POST', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -542,7 +542,7 @@ public function testPut1() 'path' => '/1/test/all', 'method' => 'PUT', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } diff --git a/tests/output/php/src/methods/requests/SearchTest.php b/tests/output/php/src/methods/requests/SearchTest.php index 9a3fe78aea..b8fe9169fb 100644 --- a/tests/output/php/src/methods/requests/SearchTest.php +++ b/tests/output/php/src/methods/requests/SearchTest.php @@ -173,7 +173,7 @@ public function testAssignUserId0() 'path' => '/1/clusters/mapping', 'method' => 'POST', 'body' => json_decode("{\"cluster\":\"theCluster\"}"), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"X-Algolia-User-ID\":\"userID\"}" ), ], @@ -228,7 +228,7 @@ public function testBatchAssignUserIds0() 'body' => json_decode( "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}" ), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"X-Algolia-User-ID\":\"userID\"}" ), ], @@ -381,7 +381,7 @@ public function testBatchRules0() 'body' => json_decode( "[{\"objectID\":\"a-rule-id\",\"conditions\":[{\"pattern\":\"smartphone\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"category:smartphone\"}}},{\"objectID\":\"a-second-rule-id\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}]" ), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"forwardToReplicas\":\"true\",\"clearExistingRules\":\"true\"}" ), ], @@ -519,7 +519,7 @@ public function testDel1() [ 'path' => '/1/test/all', 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -698,7 +698,7 @@ public function testGet1() [ 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -776,7 +776,7 @@ public function testGetLogs0() [ 'path' => '/1/logs', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}" ), ], @@ -801,7 +801,7 @@ public function testGetObject0() [ 'path' => '/1/indexes/theIndexName/uniqueID', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"attributesToRetrieve\":\"attr1,attr2\"}" ), ], @@ -988,7 +988,7 @@ public function testHasPendingMappings0() [ 'path' => '/1/clusters/mapping/pending', 'method' => 'GET', - 'searchParams' => json_decode("{\"getClusters\":\"true\"}"), + 'queryParameters' => json_decode("{\"getClusters\":\"true\"}"), ], ]); } @@ -1043,7 +1043,7 @@ public function testListIndices0() [ 'path' => '/1/indexes', 'method' => 'GET', - 'searchParams' => json_decode("{\"page\":\"8\"}"), + 'queryParameters' => json_decode("{\"page\":\"8\"}"), ], ]); } @@ -1065,7 +1065,7 @@ public function testListUserIds0() [ 'path' => '/1/clusters/mapping', 'method' => 'GET', - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"page\":\"8\",\"hitsPerPage\":\"100\"}" ), ], @@ -1197,7 +1197,7 @@ public function testPartialUpdateObject0() 'body' => json_decode( "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]" ), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"createIfNotExists\":\"true\"}" ), ], @@ -1241,7 +1241,7 @@ public function testPost1() 'path' => '/1/test/all', 'method' => 'POST', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -1283,7 +1283,7 @@ public function testPut1() 'path' => '/1/test/all', 'method' => 'PUT', 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'queryParameters' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -1399,7 +1399,7 @@ public function testSaveRule0() 'body' => json_decode( "{\"objectID\":\"id1\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}" ), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"forwardToReplicas\":\"true\"}" ), ], @@ -1434,7 +1434,7 @@ public function testSaveSynonym0() 'body' => json_decode( "{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}" ), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"forwardToReplicas\":\"true\"}" ), ], @@ -1481,7 +1481,7 @@ public function testSaveSynonyms0() 'body' => json_decode( "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]" ), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}" ), ], @@ -1780,7 +1780,7 @@ public function testSetSettings0() 'path' => '/1/indexes/theIndexName/settings', 'method' => 'PUT', 'body' => json_decode("{\"paginationLimitedTo\":10}"), - 'searchParams' => json_decode( + 'queryParameters' => json_decode( "{\"forwardToReplicas\":\"true\"}" ), ], From e73312e133ac6badb2bc7d61045b67f02176cc39 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 27 Apr 2022 17:22:16 +0200 Subject: [PATCH 12/14] map --- tests/CTS/methods/requests/templates/java/requests.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CTS/methods/requests/templates/java/requests.mustache b/tests/CTS/methods/requests/templates/java/requests.mustache index e05cc9c18a..524f7c9101 100644 --- a/tests/CTS/methods/requests/templates/java/requests.mustache +++ b/tests/CTS/methods/requests/templates/java/requests.mustache @@ -50,7 +50,7 @@ class {{client}}Tests { {{/request.body}} {{#request.queryParameters}} - HashMap expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.queryParameters}}}{{/lambda.escapequotes}}", new TypeToken>() {}.getType()); + Map expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.queryParameters}}}{{/lambda.escapequotes}}", new TypeToken>() {}.getType()); List actualQuery = req.getQueryParams(); assertEquals(expectedQuery.size(), actualQuery.size()); for (Pair p : actualQuery) { From e67489ed10db8e1b564dfca84ccb730b60f8ef93 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 27 Apr 2022 17:24:04 +0200 Subject: [PATCH 13/14] gen --- .../methods/requests/abtesting.test.java | 10 +-- .../methods/requests/analytics.test.java | 78 +++++++++---------- .../methods/requests/insights.test.java | 8 +- .../requests/personalization.test.java | 8 +- .../requests/query-suggestions.test.java | 8 +- .../methods/requests/recommend.test.java | 8 +- .../algolia/methods/requests/search.test.java | 34 ++++---- 7 files changed, 77 insertions(+), 77 deletions(-) diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java index b739f72cbc..b4562db194 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/abtesting.test.java @@ -119,7 +119,7 @@ void delTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -178,7 +178,7 @@ void getTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -218,7 +218,7 @@ void listABTestsTest0() { assertEquals(req.getPath(), "/2/abtests"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"offset\":\"42\",\"limit\":\"21\"}", new TypeToken>() {}.getType() ); @@ -278,7 +278,7 @@ void postTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -338,7 +338,7 @@ void putTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java index 1e2f95e300..bd347f836e 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/analytics.test.java @@ -61,7 +61,7 @@ void delTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -106,7 +106,7 @@ void getTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -130,7 +130,7 @@ void getAverageClickPositionTest0() { assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -165,7 +165,7 @@ void getAverageClickPositionTest1() { assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -189,7 +189,7 @@ void getClickPositionsTest0() { assertEquals(req.getPath(), "/2/clicks/positions"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -219,7 +219,7 @@ void getClickPositionsTest1() { assertEquals(req.getPath(), "/2/clicks/positions"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -243,7 +243,7 @@ void getClickThroughRateTest0() { assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -273,7 +273,7 @@ void getClickThroughRateTest1() { assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -297,7 +297,7 @@ void getConversationRateTest0() { assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -327,7 +327,7 @@ void getConversationRateTest1() { assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -351,7 +351,7 @@ void getNoClickRateTest0() { assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -381,7 +381,7 @@ void getNoClickRateTest1() { assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -405,7 +405,7 @@ void getNoResultsRateTest0() { assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -435,7 +435,7 @@ void getNoResultsRateTest1() { assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -459,7 +459,7 @@ void getSearchesCountTest0() { assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -489,7 +489,7 @@ void getSearchesCountTest1() { assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -513,7 +513,7 @@ void getSearchesNoClicksTest0() { assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -554,7 +554,7 @@ void getSearchesNoClicksTest1() { assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -578,7 +578,7 @@ void getSearchesNoResultsTest0() { assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -619,7 +619,7 @@ void getSearchesNoResultsTest1() { assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -643,7 +643,7 @@ void getStatusTest0() { assertEquals(req.getPath(), "/2/status"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -667,7 +667,7 @@ void getTopCountriesTest0() { assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -708,7 +708,7 @@ void getTopCountriesTest1() { assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -732,7 +732,7 @@ void getTopFilterAttributesTest0() { assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -776,7 +776,7 @@ void getTopFilterAttributesTest1() { assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -802,7 +802,7 @@ void getTopFilterForAttributeTest0() { assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -830,7 +830,7 @@ void getTopFilterForAttributeTest1() { assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -877,7 +877,7 @@ void getTopFilterForAttributeTest2() { assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -926,7 +926,7 @@ void getTopFilterForAttributeTest3() { assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -950,7 +950,7 @@ void getTopFiltersNoResultsTest0() { assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -994,7 +994,7 @@ void getTopFiltersNoResultsTest1() { assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -1018,7 +1018,7 @@ void getTopHitsTest0() { assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -1065,7 +1065,7 @@ void getTopHitsTest1() { assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -1089,7 +1089,7 @@ void getTopSearchesTest0() { assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -1139,7 +1139,7 @@ void getTopSearchesTest1() { assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -1163,7 +1163,7 @@ void getUsersCountTest0() { assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); @@ -1193,7 +1193,7 @@ void getUsersCountTest1() { assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); @@ -1253,7 +1253,7 @@ void postTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -1313,7 +1313,7 @@ void putTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java index 5f8fa2bba0..e705bb0665 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/insights.test.java @@ -61,7 +61,7 @@ void delTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -106,7 +106,7 @@ void getTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -166,7 +166,7 @@ void postTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -370,7 +370,7 @@ void putTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java index 98902b41a3..47885c9bec 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/personalization.test.java @@ -61,7 +61,7 @@ void delTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -120,7 +120,7 @@ void getTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -206,7 +206,7 @@ void postTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -266,7 +266,7 @@ void putTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java index 127fb56aa5..fecd145908 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/query-suggestions.test.java @@ -151,7 +151,7 @@ void delTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -210,7 +210,7 @@ void getTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -324,7 +324,7 @@ void postTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -384,7 +384,7 @@ void putTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java index d0b02fbb71..5bfb958b41 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/recommend.test.java @@ -61,7 +61,7 @@ void delTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -106,7 +106,7 @@ void getTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -716,7 +716,7 @@ void postTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -776,7 +776,7 @@ void putTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index b411c893e7..d2eb69ddc8 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -167,7 +167,7 @@ void assignUserIdTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType() ); @@ -265,7 +265,7 @@ void batchAssignUserIdsTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType() ); @@ -589,7 +589,7 @@ void batchRulesTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\",\"clearExistingRules\":\"true\"}", new TypeToken>() {}.getType() ); @@ -722,7 +722,7 @@ void delTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "DELETE"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -889,7 +889,7 @@ void getTest1() { assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -957,7 +957,7 @@ void getLogsTest0() { assertEquals(req.getPath(), "/1/logs"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", new TypeToken>() {}.getType() ); @@ -993,7 +993,7 @@ void getObjectTest0() { assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"attributesToRetrieve\":\"attr1,attr2\"}", new TypeToken>() {}.getType() ); @@ -1165,7 +1165,7 @@ void hasPendingMappingsTest0() { assertEquals(req.getPath(), "/1/clusters/mapping/pending"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"getClusters\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1213,7 +1213,7 @@ void listIndicesTest0() { assertEquals(req.getPath(), "/1/indexes"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"page\":\"8\"}", new TypeToken>() {}.getType() ); @@ -1239,7 +1239,7 @@ void listUserIdsTest0() { assertEquals(req.getPath(), "/1/clusters/mapping"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"page\":\"8\",\"hitsPerPage\":\"100\"}", new TypeToken>() {}.getType() ); @@ -1513,7 +1513,7 @@ void partialUpdateObjectTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"createIfNotExists\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1573,7 +1573,7 @@ void postTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -1633,7 +1633,7 @@ void putTest1() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); @@ -1803,7 +1803,7 @@ void saveRuleTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1869,7 +1869,7 @@ void saveSynonymTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1968,7 +1968,7 @@ void saveSynonymsTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", new TypeToken>() {}.getType() ); @@ -2405,7 +2405,7 @@ void setSettingsTest0() { ); }); - HashMap expectedQuery = JSON.deserialize( + Map expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); From 259e7933968141ae9011fd89aa948b054e846141 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 28 Apr 2022 09:36:43 +0200 Subject: [PATCH 14/14] Update website/docs/automation/testing/common-test-suite.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte --- website/docs/automation/testing/common-test-suite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/automation/testing/common-test-suite.md b/website/docs/automation/testing/common-test-suite.md index 54c12baa5d..e5591434b0 100644 --- a/website/docs/automation/testing/common-test-suite.md +++ b/website/docs/automation/testing/common-test-suite.md @@ -48,7 +48,7 @@ The test generation script requires a JSON file name from the `operationId` (e.g ] ``` -And that's it! If the name of the file matches a real `operationId` in the spec, then a test will be generated and will be calling the method name `operationId`. +And that's it! If the name of the file matches an `operationId` in the spec, a test will be generated and will be calling the method name `operationId`. The list of `queryParameters` must match exactly the actual value, the CTS has to check the number of query parameters and the value of each.