From bb66f51bd118f7abe04edd741776889334c3da31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 27 Apr 2022 09:38:52 +0200 Subject: [PATCH 1/6] feat(cts): add algoliasearch-lite --- .../codegen/cts/AlgoliaCtsGenerator.java | 15 +- .../requests/search/multipleQueries.json | 37 ++++ .../algolia/methods/requests/search.test.java | 63 ++++++- tests/output/javascript/package.json | 1 + .../requests/algoliasearch-lite.test.ts | 160 ++++++++++++++++++ .../src/methods/requests/search.test.ts | 29 +++- yarn.lock | 3 +- 7 files changed, 302 insertions(+), 6 deletions(-) create mode 100644 tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts 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 302de41084..62826cfe81 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -142,9 +142,12 @@ public Map postProcessSupportingFileData( for (Entry entry : cts.entrySet()) { String operationId = entry.getKey(); if (!operations.containsKey(operationId)) { - throw new CTSException( + // We only inform that it does not exist but skip the test generation + System.out.println( "operationId " + operationId + " does not exist in the spec" ); + + continue; } CodegenOperation op = operations.get(operationId); @@ -183,7 +186,15 @@ public Map postProcessSupportingFileData( private Map loadCTS() throws JsonParseException, JsonMappingException, IOException, CTSException { TreeMap cts = new TreeMap<>(); - File dir = new File("tests/CTS/methods/requests/" + client); + String clientName = client; + + // This special case allow us to read the `search` CTS to generated the + // tests for the `algoliasearch-lite` client. + if (clientName.equals("algoliasearch-lite")) { + clientName = "search"; + } + + File dir = new File("tests/CTS/methods/requests/" + clientName); File commonTestDir = new File("tests/CTS/methods/requests/common"); if (!dir.exists()) { throw new CTSException("CTS not found at " + dir.getAbsolutePath(), true); diff --git a/tests/CTS/methods/requests/search/multipleQueries.json b/tests/CTS/methods/requests/search/multipleQueries.json index d994520843..cace38b771 100644 --- a/tests/CTS/methods/requests/search/multipleQueries.json +++ b/tests/CTS/methods/requests/search/multipleQueries.json @@ -1,6 +1,31 @@ [ { "method": "multipleQueries", + "testName": "multipleQueries for a single request with minimal parameters", + "parameters": { + "requests": [ + { + "indexName": "theIndexName" + } + ], + "strategy": "stopIfEnoughMatches" + }, + "request": { + "path": "/1/indexes/*/queries", + "method": "POST", + "data": { + "requests": [ + { + "indexName": "theIndexName" + } + ], + "strategy": "stopIfEnoughMatches" + } + } + }, + { + "method": "multipleQueries", + "testName": "multipleQueries for multiple requests with all parameters", "parameters": { "requests": [ { @@ -9,6 +34,12 @@ "type": "facet", "facet": "theFacet", "params": "testParam" + }, + { + "indexName": "theIndexName", + "query": "test", + "type": "default", + "params": "testParam" } ], "strategy": "stopIfEnoughMatches" @@ -24,6 +55,12 @@ "type": "facet", "facet": "theFacet", "params": "testParam" + }, + { + "indexName": "theIndexName", + "query": "test", + "type": "default", + "params": "testParam" } ], "strategy": "stopIfEnoughMatches" 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..b165e0b4c2 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 @@ -1408,8 +1408,49 @@ void multipleBatchTest0() { } @Test - @DisplayName("multipleQueries") + @DisplayName("multipleQueries for a single request with minimal parameters") void multipleQueriesTest0() { + MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); + { + List requests1 = new ArrayList<>(); + { + MultipleQueries requests_02 = new MultipleQueries(); + { + String indexName3 = "theIndexName"; + + requests_02.setIndexName(indexName3); + } + 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\"}],\"strategy\":\"stopIfEnoughMatches\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); + } + + @Test + @DisplayName("multipleQueries for multiple requests with all parameters") + void multipleQueriesTest1() { MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); { List requests1 = new ArrayList<>(); @@ -1434,6 +1475,24 @@ void multipleQueriesTest0() { requests_02.setParams(params3); } requests1.add(requests_02); + + MultipleQueries requests_12 = new MultipleQueries(); + { + String indexName3 = "theIndexName"; + + requests_12.setIndexName(indexName3); + String query3 = "test"; + + requests_12.setQuery(query3); + + MultipleQueriesType type3 = MultipleQueriesType.fromValue("default"); + + requests_12.setType(type3); + String params3 = "testParam"; + + requests_12.setParams(params3); + } + requests1.add(requests_12); } multipleQueriesParams0.setRequests(requests1); @@ -1454,7 +1513,7 @@ void multipleQueriesTest0() { assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}", + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"},{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"default\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); diff --git a/tests/output/javascript/package.json b/tests/output/javascript/package.json index 3c52150a51..5c5b668fb8 100644 --- a/tests/output/javascript/package.json +++ b/tests/output/javascript/package.json @@ -5,6 +5,7 @@ "test": "jest" }, "dependencies": { + "@experimental-api-clients-automation/algoliasearch-lite": "0.0.5", "@experimental-api-clients-automation/client-abtesting": "0.0.5", "@experimental-api-clients-automation/client-analytics": "0.0.5", "@experimental-api-clients-automation/client-common": "0.0.5", diff --git a/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts new file mode 100644 index 0000000000..ff245af428 --- /dev/null +++ b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts @@ -0,0 +1,160 @@ +import { algoliasearchLiteClient } from '@experimental-api-clients-automation/algoliasearch-lite'; +import type { EchoResponse } from '@experimental-api-clients-automation/client-common'; +import { echoRequester } from '@experimental-api-clients-automation/requester-node-http'; + +const appId = process.env.ALGOLIA_APPLICATION_ID || 'test_app_id'; +const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; + +const client = algoliasearchLiteClient(appId, apiKey, { + requester: echoRequester(), +}); + +describe('multipleQueries', () => { + test('multipleQueries for a single request with minimal parameters', async () => { + const req = (await client.multipleQueries({ + requests: [{ indexName: 'theIndexName' }], + strategy: 'stopIfEnoughMatches', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/*/queries'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [{ indexName: 'theIndexName' }], + strategy: 'stopIfEnoughMatches', + }); + expect(req.searchParams).toEqual(undefined); + }); + + test('multipleQueries for multiple requests with all parameters', async () => { + const req = (await client.multipleQueries({ + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: 'testParam', + }, + { + indexName: 'theIndexName', + query: 'test', + type: 'default', + params: 'testParam', + }, + ], + strategy: 'stopIfEnoughMatches', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/*/queries'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [ + { + indexName: 'theIndexName', + query: 'test', + type: 'facet', + facet: 'theFacet', + params: 'testParam', + }, + { + indexName: 'theIndexName', + query: 'test', + type: 'default', + params: 'testParam', + }, + ], + strategy: 'stopIfEnoughMatches', + }); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + +describe('search', () => { + test('search with minimal parameters', async () => { + const req = (await client.search({ + indexName: 'indexName', + searchParams: { query: 'myQuery' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ query: 'myQuery' }); + expect(req.searchParams).toEqual(undefined); + }); + + test('search with facetFilters', async () => { + const req = (await client.search({ + indexName: 'indexName', + searchParams: { query: 'myQuery', facetFilters: ['tags:algolia'] }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/indexName/query'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + query: 'myQuery', + facetFilters: ['tags:algolia'], + }); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('searchForFacetValues', () => { + test('get searchForFacetValues results with minimal parameters', async () => { + const req = (await client.searchForFacetValues({ + indexName: 'indexName', + facetName: 'facetName', + })) as unknown as EchoResponse; + + 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); + }); + + test('get searchForFacetValues results with all parameters', async () => { + const req = (await client.searchForFacetValues({ + indexName: 'indexName', + facetName: 'facetName', + searchForFacetValuesRequest: { + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, + }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, + }); + expect(req.searchParams).toEqual(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..4415b2938d 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -738,7 +738,22 @@ describe('multipleBatch', () => { }); describe('multipleQueries', () => { - test('multipleQueries', async () => { + test('multipleQueries for a single request with minimal parameters', async () => { + const req = (await client.multipleQueries({ + requests: [{ indexName: 'theIndexName' }], + strategy: 'stopIfEnoughMatches', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/*/queries'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [{ indexName: 'theIndexName' }], + strategy: 'stopIfEnoughMatches', + }); + expect(req.searchParams).toEqual(undefined); + }); + + test('multipleQueries for multiple requests with all parameters', async () => { const req = (await client.multipleQueries({ requests: [ { @@ -748,6 +763,12 @@ describe('multipleQueries', () => { facet: 'theFacet', params: 'testParam', }, + { + indexName: 'theIndexName', + query: 'test', + type: 'default', + params: 'testParam', + }, ], strategy: 'stopIfEnoughMatches', })) as unknown as EchoResponse; @@ -763,6 +784,12 @@ describe('multipleQueries', () => { facet: 'theFacet', params: 'testParam', }, + { + indexName: 'theIndexName', + query: 'test', + type: 'default', + params: 'testParam', + }, ], strategy: 'stopIfEnoughMatches', }); diff --git a/yarn.lock b/yarn.lock index 5f8597aae7..7c6c2bb8a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2626,7 +2626,7 @@ __metadata: languageName: node linkType: hard -"@experimental-api-clients-automation/algoliasearch-lite@workspace:clients/algoliasearch-client-javascript/packages/algoliasearch-lite": +"@experimental-api-clients-automation/algoliasearch-lite@0.0.5, @experimental-api-clients-automation/algoliasearch-lite@workspace:clients/algoliasearch-client-javascript/packages/algoliasearch-lite": version: 0.0.0-use.local resolution: "@experimental-api-clients-automation/algoliasearch-lite@workspace:clients/algoliasearch-client-javascript/packages/algoliasearch-lite" dependencies: @@ -13220,6 +13220,7 @@ __metadata: version: 0.0.0-use.local resolution: "javascript-tests@workspace:tests/output/javascript" dependencies: + "@experimental-api-clients-automation/algoliasearch-lite": 0.0.5 "@experimental-api-clients-automation/client-abtesting": 0.0.5 "@experimental-api-clients-automation/client-analytics": 0.0.5 "@experimental-api-clients-automation/client-common": 0.0.5 From da9cae4a22edf88629abfdefeacfe1c61eacf1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 27 Apr 2022 12:09:04 +0200 Subject: [PATCH 2/6] millotp said 2 lines to change --- .../codegen/cts/AlgoliaCtsGenerator.java | 19 +- .../methods/requests/abtesting.test.java | 210 +- .../methods/requests/analytics.test.java | 898 +++---- .../methods/requests/insights.test.java | 158 +- .../requests/personalization.test.java | 244 +- .../requests/query-suggestions.test.java | 416 +-- .../methods/requests/recommend.test.java | 158 +- .../algolia/methods/requests/search.test.java | 2358 ++++++++--------- .../src/methods/requests/abtesting.test.ts | 118 +- .../requests/algoliasearch-lite.test.ts | 52 +- .../src/methods/requests/analytics.test.ts | 554 ++-- .../src/methods/requests/insights.test.ts | 68 +- .../methods/requests/personalization.test.ts | 118 +- .../requests/query-suggestions.test.ts | 204 +- .../src/methods/requests/recommend.test.ts | 68 +- .../src/methods/requests/search.test.ts | 1202 ++++----- .../src/methods/requests/sources.test.ts | 34 +- 17 files changed, 3438 insertions(+), 3441 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 62826cfe81..21bd8a0aa0 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -139,23 +139,20 @@ public Map postProcessSupportingFileData( List blocks = new ArrayList<>(); ParametersWithDataType paramsType = new ParametersWithDataType(models); - for (Entry entry : cts.entrySet()) { + for (Entry entry : operations.entrySet()) { String operationId = entry.getKey(); - if (!operations.containsKey(operationId)) { - // We only inform that it does not exist but skip the test generation - System.out.println( + if (!cts.containsKey(operationId)) { + throw new CTSException( "operationId " + operationId + " does not exist in the spec" ); - - continue; } - CodegenOperation op = operations.get(operationId); + Request[] op = cts.get(operationId); List tests = new ArrayList<>(); - for (int i = 0; i < entry.getValue().length; i++) { + for (int i = 0; i < op.length; i++) { Map test = paramsType.buildJSONForRequest( - entry.getValue()[i], - op, + op[i], + entry.getValue(), i ); tests.add(test); @@ -242,7 +239,7 @@ private HashMap buildOperations( result.put(ope.operationId, ope); } } - return result; + return result.keySet().stream().sorted().collect(Collectors.toList()); } private String createImportName() { 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..53345e57bf 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 @@ -29,80 +29,36 @@ void init() { } @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(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); - } + @DisplayName("deleteABTest") + void deleteABTestTest0() { + int id0 = 42; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addABTests(addABTestsRequest0); + return client.deleteABTest(id0); } ); - 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 - ); - }); + assertEquals(req.getPath(), "/2/abtests/42"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.post(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -112,13 +68,28 @@ void delTest1() { parameters0.put("query", query1); } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.post(path0, parameters0, body0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -143,17 +114,75 @@ void delTest1() { } @Test - @DisplayName("deleteABTest") - void deleteABTestTest0() { + @DisplayName("stopABTest") + void stopABTestTest0() { int id0 = 42; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteABTest(id0); + return client.stopABTest(id0); } ); - assertEquals(req.getPath(), "/2/abtests/42"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/2/abtests/42/stop"); + assertEquals(req.getMethod(), "POST"); + } + + @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(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 @@ -212,20 +241,6 @@ void getTest1() { } } - @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() { @@ -264,22 +279,22 @@ void listABTestsTest0() { } @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -289,28 +304,13 @@ void postTest1() { 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); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -406,16 +406,16 @@ void putTest1() { } @Test - @DisplayName("stopABTest") - void stopABTestTest0() { + @DisplayName("getABTest") + void getABTestTest0() { int id0 = 42; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.stopABTest(id0); + return client.getABTest(id0); } ); - assertEquals(req.getPath(), "/2/abtests/42/stop"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/2/abtests/42"); + assertEquals(req.getMethod(), "GET"); } } 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..24fa9b2dc0 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 @@ -29,41 +29,20 @@ void init() { } @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); - } + @DisplayName("get getTopSearches with minimal parameters") + void getTopSearchesTest0() { + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.getTopSearches(index0); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/2/searches"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -85,41 +64,46 @@ void delTest1() { } @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; + @DisplayName("get getTopSearches with all parameters") + void getTopSearchesTest1() { + String index0 = "index"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); + boolean clickAnalytics0 = true; - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - } + String startDate0 = "1999-09-19"; - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; + String endDate0 = "2001-01-01"; - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; + OrderBy orderBy0 = OrderBy.fromValue("searchCount"); - parameters0.put("query", query1); - } + Direction direction0 = Direction.fromValue("asc"); + + int limit0 = 21; + + int offset0 = 42; + + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); + return client.getTopSearches( + index0, + clickAnalytics0, + startDate0, + endDate0, + orderBy0, + direction0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"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(); @@ -141,16 +125,16 @@ void getTest1() { } @Test - @DisplayName("get getAverageClickPosition with minimal parameters") - void getAverageClickPositionTest0() { + @DisplayName("get getTopHits with minimal parameters") + void getTopHitsTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAverageClickPosition(index0); + return client.getTopHits(index0); } ); - assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); + assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -176,31 +160,43 @@ void getAverageClickPositionTest0() { } @Test - @DisplayName("get getAverageClickPosition with all parameters") - void getAverageClickPositionTest1() { + @DisplayName("get getTopHits with all parameters") + void getTopHitsTest1() { String index0 = "index"; + String search0 = "mySearch"; + + boolean clickAnalytics0 = true; + String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; + int limit0 = 21; + + int offset0 = 42; + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAverageClickPosition( + return client.getTopHits( index0, + search0, + clickAnalytics0, startDate0, endDate0, + limit0, + offset0, tags0 ); } ); - assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); + assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"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(); @@ -222,61 +218,41 @@ void getAverageClickPositionTest1() { } @Test - @DisplayName("get getClickPositions with minimal parameters") - void getClickPositionsTest0() { - String index0 = "index"; + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickPositions(index0); + return client.del(path0); } ); - assertEquals(req.getPath(), "/2/clicks/positions"); - assertEquals(req.getMethod(), "GET"); - - Map 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(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("get getClickPositions with all parameters") - void getClickPositionsTest1() { - String index0 = "index"; - - String startDate0 = "1999-09-19"; + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; - String endDate0 = "2001-01-01"; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; - String tags0 = "tag"; + parameters0.put("query", query1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickPositions(index0, startDate0, endDate0, tags0); + return client.del(path0, parameters0); } ); - assertEquals(req.getPath(), "/2/clicks/positions"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -298,16 +274,16 @@ void getClickPositionsTest1() { } @Test - @DisplayName("get getClickThroughRate with minimal parameters") - void getClickThroughRateTest0() { + @DisplayName("get getTopFiltersNoResults with minimal parameters") + void getTopFiltersNoResultsTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickThroughRate(index0); + return client.getTopFiltersNoResults(index0); } ); - assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); + assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -333,26 +309,40 @@ void getClickThroughRateTest0() { } @Test - @DisplayName("get getClickThroughRate with all parameters") - void getClickThroughRateTest1() { + @DisplayName("get getTopFiltersNoResults with all parameters") + void getTopFiltersNoResultsTest1() { String index0 = "index"; + String search0 = "mySearch"; + String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; + int limit0 = 21; + + int offset0 = 42; + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickThroughRate(index0, startDate0, endDate0, tags0); + return client.getTopFiltersNoResults( + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); + assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"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(); @@ -374,16 +364,16 @@ void getClickThroughRateTest1() { } @Test - @DisplayName("get getConversationRate with minimal parameters") - void getConversationRateTest0() { + @DisplayName("get getSearchesNoResults with minimal parameters") + void getSearchesNoResultsTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConversationRate(index0); + return client.getSearchesNoResults(index0); } ); - assertEquals(req.getPath(), "/2/conversions/conversionRate"); + assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -409,26 +399,37 @@ void getConversationRateTest0() { } @Test - @DisplayName("get getConversationRate with all parameters") - void getConversationRateTest1() { + @DisplayName("get getSearchesNoResults with all parameters") + void getSearchesNoResultsTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; + int limit0 = 21; + + int offset0 = 42; + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConversationRate(index0, startDate0, endDate0, tags0); + return client.getSearchesNoResults( + index0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/conversions/conversionRate"); + assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -450,16 +451,16 @@ void getConversationRateTest1() { } @Test - @DisplayName("get getNoClickRate with minimal parameters") - void getNoClickRateTest0() { + @DisplayName("get getStatus with minimal parameters") + void getStatusTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoClickRate(index0); + return client.getStatus(index0); } ); - assertEquals(req.getPath(), "/2/searches/noClickRate"); + assertEquals(req.getPath(), "/2/status"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -485,26 +486,20 @@ void getNoClickRateTest0() { } @Test - @DisplayName("get getNoClickRate with all parameters") - void getNoClickRateTest1() { + @DisplayName("get getClickPositions with minimal parameters") + void getClickPositionsTest0() { String index0 = "index"; - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; - - String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoClickRate(index0, startDate0, endDate0, tags0); + return client.getClickPositions(index0); } ); - assertEquals(req.getPath(), "/2/searches/noClickRate"); + 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\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -526,20 +521,26 @@ void getNoClickRateTest1() { } @Test - @DisplayName("get getNoResultsRate with minimal parameters") - void getNoResultsRateTest0() { + @DisplayName("get getClickPositions with all parameters") + void getClickPositionsTest1() { String index0 = "index"; + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + String tags0 = "tag"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoResultsRate(index0); + return client.getClickPositions(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/searches/noResultRate"); + assertEquals(req.getPath(), "/2/clicks/positions"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -561,26 +562,56 @@ void getNoResultsRateTest0() { } @Test - @DisplayName("get getNoResultsRate with all parameters") - void getNoResultsRateTest1() { - String index0 = "index"; + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; - String startDate0 = "1999-09-19"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); - String endDate0 = "2001-01-01"; + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + } - String tags0 = "tag"; + @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.getNoResultsRate(index0, startDate0, endDate0, tags0); + return client.put(path0, parameters0, body0); } ); - assertEquals(req.getPath(), "/2/searches/noResultRate"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -602,16 +633,18 @@ void getNoResultsRateTest1() { } @Test - @DisplayName("get getSearchesCount with minimal parameters") - void getSearchesCountTest0() { + @DisplayName("get getTopFilterForAttribute with minimal parameters") + void getTopFilterForAttributeTest0() { + String attribute0 = "myAttribute"; + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesCount(index0); + return client.getTopFilterForAttribute(attribute0, index0); } ); - assertEquals(req.getPath(), "/2/searches/count"); + assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -637,26 +670,24 @@ void getSearchesCountTest0() { } @Test - @DisplayName("get getSearchesCount with all parameters") - void getSearchesCountTest1() { - String index0 = "index"; - - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; + @DisplayName( + "get getTopFilterForAttribute with minimal parameters and multiple attributes" + ) + void getTopFilterForAttributeTest1() { + String attribute0 = "myAttribute1,myAttribute2"; - String tags0 = "tag"; + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesCount(index0, startDate0, endDate0, tags0); + return client.getTopFilterForAttribute(attribute0, index0); } ); - assertEquals(req.getPath(), "/2/searches/count"); + assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -678,20 +709,43 @@ void getSearchesCountTest1() { } @Test - @DisplayName("get getSearchesNoClicks with minimal parameters") - void getSearchesNoClicksTest0() { + @DisplayName("get getTopFilterForAttribute with all parameters") + void getTopFilterForAttributeTest2() { + String attribute0 = "myAttribute"; + String index0 = "index"; + String search0 = "mySearch"; + + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + int limit0 = 21; + + int offset0 = 42; + + String tags0 = "tag"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoClicks(index0); + return client.getTopFilterForAttribute( + attribute0, + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/searches/noClicks"); + assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", + "{\"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(); @@ -713,10 +767,16 @@ void getSearchesNoClicksTest0() { } @Test - @DisplayName("get getSearchesNoClicks with all parameters") - void getSearchesNoClicksTest1() { + @DisplayName( + "get getTopFilterForAttribute with all parameters and multiple attributes" + ) + void getTopFilterForAttributeTest3() { + String attribute0 = "myAttribute1,myAttribute2"; + String index0 = "index"; + String search0 = "mySearch"; + String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; @@ -728,8 +788,10 @@ void getSearchesNoClicksTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoClicks( + return client.getTopFilterForAttribute( + attribute0, index0, + search0, startDate0, endDate0, limit0, @@ -739,11 +801,11 @@ void getSearchesNoClicksTest1() { } ); - assertEquals(req.getPath(), "/2/searches/noClicks"); + assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + "{\"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(); @@ -765,16 +827,16 @@ void getSearchesNoClicksTest1() { } @Test - @DisplayName("get getSearchesNoResults with minimal parameters") - void getSearchesNoResultsTest0() { + @DisplayName("get getNoClickRate with minimal parameters") + void getNoClickRateTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoResults(index0); + return client.getNoClickRate(index0); } ); - assertEquals(req.getPath(), "/2/searches/noResults"); + assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -800,37 +862,26 @@ void getSearchesNoResultsTest0() { } @Test - @DisplayName("get getSearchesNoResults with all parameters") - void getSearchesNoResultsTest1() { + @DisplayName("get getNoClickRate with all parameters") + void getNoClickRateTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; - int limit0 = 21; - - int offset0 = 42; - String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoResults( - index0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); + return client.getNoClickRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/searches/noResults"); + assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -852,16 +903,16 @@ void getSearchesNoResultsTest1() { } @Test - @DisplayName("get getStatus with minimal parameters") - void getStatusTest0() { + @DisplayName("get getUsersCount with minimal parameters") + void getUsersCountTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getStatus(index0); + return client.getUsersCount(index0); } ); - assertEquals(req.getPath(), "/2/status"); + assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -887,16 +938,57 @@ void getStatusTest0() { } @Test - @DisplayName("get getTopCountries with minimal parameters") - void getTopCountriesTest0() { + @DisplayName("get getUsersCount with all parameters") + void getUsersCountTest1() { + String index0 = "index"; + + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + String tags0 = "tag"; + + 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() + ); + 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 getSearchesNoClicks with minimal parameters") + void getSearchesNoClicksTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopCountries(index0); + return client.getSearchesNoClicks(index0); } ); - assertEquals(req.getPath(), "/2/countries"); + assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -922,8 +1014,8 @@ void getTopCountriesTest0() { } @Test - @DisplayName("get getTopCountries with all parameters") - void getTopCountriesTest1() { + @DisplayName("get getSearchesNoClicks with all parameters") + void getSearchesNoClicksTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; @@ -937,7 +1029,7 @@ void getTopCountriesTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopCountries( + return client.getSearchesNoClicks( index0, startDate0, endDate0, @@ -948,7 +1040,7 @@ void getTopCountriesTest1() { } ); - assertEquals(req.getPath(), "/2/countries"); + assertEquals(req.getPath(), "/2/searches/noClicks"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -974,20 +1066,56 @@ void getTopCountriesTest1() { } @Test - @DisplayName("get getTopFilterAttributes with minimal parameters") - void getTopFilterAttributesTest0() { - String index0 = "index"; + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterAttributes(index0); + return client.post(path0); } ); - assertEquals(req.getPath(), "/2/filters"); - assertEquals(req.getMethod(), "GET"); + 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( - "{\"index\":\"index\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1009,40 +1137,20 @@ void getTopFilterAttributesTest0() { } @Test - @DisplayName("get getTopFilterAttributes with all parameters") - void getTopFilterAttributesTest1() { + @DisplayName("get getAverageClickPosition with minimal parameters") + void getAverageClickPositionTest0() { String index0 = "index"; - String search0 = "mySearch"; - - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; - - int limit0 = 21; - - int offset0 = 42; - - String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterAttributes( - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); + return client.getAverageClickPosition(index0); } ); - assertEquals(req.getPath(), "/2/filters"); + assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); 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\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1064,22 +1172,31 @@ void getTopFilterAttributesTest1() { } @Test - @DisplayName("get getTopFilterForAttribute with minimal parameters") - void getTopFilterForAttributeTest0() { - String attribute0 = "myAttribute"; - + @DisplayName("get getAverageClickPosition with all parameters") + void getAverageClickPositionTest1() { String index0 = "index"; + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + String tags0 = "tag"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute(attribute0, index0); + return client.getAverageClickPosition( + index0, + startDate0, + endDate0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/filters/myAttribute"); + assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1101,20 +1218,16 @@ void getTopFilterForAttributeTest0() { } @Test - @DisplayName( - "get getTopFilterForAttribute with minimal parameters and multiple attributes" - ) - void getTopFilterForAttributeTest1() { - String attribute0 = "myAttribute1,myAttribute2"; - + @DisplayName("get getSearchesCount with minimal parameters") + void getSearchesCountTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute(attribute0, index0); + return client.getSearchesCount(index0); } ); - assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); + assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1140,43 +1253,26 @@ void getTopFilterForAttributeTest1() { } @Test - @DisplayName("get getTopFilterForAttribute with all parameters") - void getTopFilterForAttributeTest2() { - String attribute0 = "myAttribute"; - - String index0 = "index"; - - String search0 = "mySearch"; - - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; - - int limit0 = 21; - - int offset0 = 42; - - String tags0 = "tag"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute( - attribute0, - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); + @DisplayName("get getSearchesCount with all parameters") + void getSearchesCountTest1() { + String index0 = "index"; + + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + String tags0 = "tag"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSearchesCount(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/filters/myAttribute"); + assertEquals(req.getPath(), "/2/searches/count"); 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\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1198,45 +1294,41 @@ void getTopFilterForAttributeTest2() { } @Test - @DisplayName( - "get getTopFilterForAttribute with all parameters and multiple attributes" - ) - void getTopFilterForAttributeTest3() { - String attribute0 = "myAttribute1,myAttribute2"; - - String index0 = "index"; - - String search0 = "mySearch"; + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; - String startDate0 = "1999-09-19"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); - String endDate0 = "2001-01-01"; + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + } - int limit0 = 21; + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; - int offset0 = 42; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; - String tags0 = "tag"; + parameters0.put("query", query1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute( - attribute0, - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); + return client.get(path0, parameters0); } ); - assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); + assertEquals(req.getPath(), "/1/test/all"); 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\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1258,16 +1350,16 @@ void getTopFilterForAttributeTest3() { } @Test - @DisplayName("get getTopFiltersNoResults with minimal parameters") - void getTopFiltersNoResultsTest0() { + @DisplayName("get getTopFilterAttributes with minimal parameters") + void getTopFilterAttributesTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFiltersNoResults(index0); + return client.getTopFilterAttributes(index0); } ); - assertEquals(req.getPath(), "/2/filters/noResults"); + assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1293,8 +1385,8 @@ void getTopFiltersNoResultsTest0() { } @Test - @DisplayName("get getTopFiltersNoResults with all parameters") - void getTopFiltersNoResultsTest1() { + @DisplayName("get getTopFilterAttributes with all parameters") + void getTopFilterAttributesTest1() { String index0 = "index"; String search0 = "mySearch"; @@ -1310,7 +1402,7 @@ void getTopFiltersNoResultsTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFiltersNoResults( + return client.getTopFilterAttributes( index0, search0, startDate0, @@ -1322,7 +1414,7 @@ void getTopFiltersNoResultsTest1() { } ); - assertEquals(req.getPath(), "/2/filters/noResults"); + assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1348,16 +1440,16 @@ void getTopFiltersNoResultsTest1() { } @Test - @DisplayName("get getTopHits with minimal parameters") - void getTopHitsTest0() { + @DisplayName("get getTopCountries with minimal parameters") + void getTopCountriesTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopHits(index0); + return client.getTopCountries(index0); } ); - assertEquals(req.getPath(), "/2/hits"); + assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1383,14 +1475,10 @@ void getTopHitsTest0() { } @Test - @DisplayName("get getTopHits with all parameters") - void getTopHitsTest1() { + @DisplayName("get getTopCountries with all parameters") + void getTopCountriesTest1() { String index0 = "index"; - String search0 = "mySearch"; - - boolean clickAnalytics0 = true; - String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; @@ -1402,10 +1490,8 @@ void getTopHitsTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopHits( + return client.getTopCountries( index0, - search0, - clickAnalytics0, startDate0, endDate0, limit0, @@ -1415,11 +1501,11 @@ void getTopHitsTest1() { } ); - assertEquals(req.getPath(), "/2/hits"); + assertEquals(req.getPath(), "/2/countries"); 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\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1441,16 +1527,16 @@ void getTopHitsTest1() { } @Test - @DisplayName("get getTopSearches with minimal parameters") - void getTopSearchesTest0() { + @DisplayName("get getConversationRate with minimal parameters") + void getConversationRateTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopSearches(index0); + return client.getConversationRate(index0); } ); - assertEquals(req.getPath(), "/2/searches"); + assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1476,46 +1562,26 @@ void getTopSearchesTest0() { } @Test - @DisplayName("get getTopSearches with all parameters") - void getTopSearchesTest1() { + @DisplayName("get getConversationRate with all parameters") + void getConversationRateTest1() { String index0 = "index"; - boolean clickAnalytics0 = true; - String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; - OrderBy orderBy0 = OrderBy.fromValue("searchCount"); - - Direction direction0 = Direction.fromValue("asc"); - - int limit0 = 21; - - int offset0 = 42; - String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopSearches( - index0, - clickAnalytics0, - startDate0, - endDate0, - orderBy0, - direction0, - limit0, - offset0, - tags0 - ); + return client.getConversationRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/searches"); + assertEquals(req.getPath(), "/2/conversions/conversionRate"); 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\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1537,16 +1603,16 @@ void getTopSearchesTest1() { } @Test - @DisplayName("get getUsersCount with minimal parameters") - void getUsersCountTest0() { + @DisplayName("get getNoResultsRate with minimal parameters") + void getNoResultsRateTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUsersCount(index0); + return client.getNoResultsRate(index0); } ); - assertEquals(req.getPath(), "/2/users/count"); + assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1572,8 +1638,8 @@ void getUsersCountTest0() { } @Test - @DisplayName("get getUsersCount with all parameters") - void getUsersCountTest1() { + @DisplayName("get getNoResultsRate with all parameters") + void getNoResultsRateTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; @@ -1583,11 +1649,11 @@ void getUsersCountTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUsersCount(index0, startDate0, endDate0, tags0); + return client.getNoResultsRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/users/count"); + assertEquals(req.getPath(), "/2/searches/noResultRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1613,56 +1679,20 @@ void getUsersCountTest1() { } @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); - } + @DisplayName("get getClickThroughRate with minimal parameters") + void getClickThroughRateTest0() { + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); + return client.getClickThroughRate(index0); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1684,56 +1714,26 @@ void postTest1() { } @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"; + @DisplayName("get getClickThroughRate with all parameters") + void getClickThroughRateTest1() { + String index0 = "index"; - parameters0.put("query", query1); - } + String startDate0 = "1999-09-19"; - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; + String endDate0 = "2001-01-01"; - body0.put("body", body1); - } + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); + return client.getClickThroughRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); 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..36c6437e72 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 @@ -29,22 +29,22 @@ void init() { } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.post(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -54,13 +54,28 @@ void delTest1() { parameters0.put("query", query1); } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.post(path0, parameters0, body0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -140,77 +155,6 @@ void getTest1() { } } - @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("pushEvents") void pushEventsTest0() { @@ -355,6 +299,62 @@ void pushEventsTest0() { }); } + @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("allow put method for a custom path with minimal parameters") void putTest0() { 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..43f109f002 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 @@ -29,22 +29,36 @@ void init() { } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("delete deleteUserProfile") + void deleteUserProfileTest0() { + String userToken0 = "UserToken"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteUserProfile(userToken0); + } + ); + + assertEquals(req.getPath(), "/1/profiles/UserToken"); + assertEquals(req.getMethod(), "DELETE"); + } + + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.post(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -54,13 +68,28 @@ void delTest1() { parameters0.put("query", query1); } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.post(path0, parameters0, body0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -84,20 +113,6 @@ void delTest1() { } } - @Test - @DisplayName("delete deleteUserProfile") - void deleteUserProfileTest0() { - String userToken0 = "UserToken"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteUserProfile(userToken0); - } - ); - - assertEquals(req.getPath(), "/1/profiles/UserToken"); - assertEquals(req.getMethod(), "DELETE"); - } - @Test @DisplayName("allow get method for a custom path with minimal parameters") void getTest0() { @@ -167,36 +182,22 @@ void getPersonalizationStrategyTest0() { } @Test - @DisplayName("get getUserTokenProfile") - void getUserTokenProfileTest0() { - String userToken0 = "UserToken"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUserTokenProfile(userToken0); - } - ); - - assertEquals(req.getPath(), "/1/profiles/personalization/UserToken"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -206,28 +207,13 @@ void postTest1() { 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); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -252,74 +238,17 @@ void postTest1() { } @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); - } + @DisplayName("get getUserTokenProfile") + void getUserTokenProfileTest0() { + String userToken0 = "UserToken"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); + return client.getUserTokenProfile(userToken0); } ); - 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" - ); - } + assertEquals(req.getPath(), "/1/profiles/personalization/UserToken"); + assertEquals(req.getMethod(), "GET"); } @Test @@ -385,4 +314,75 @@ void setPersonalizationStrategyTest0() { ); }); } + + @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" + ); + } + } } 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..017f746842 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 @@ -29,14 +29,97 @@ void init() { } @Test - @DisplayName("createConfig") - void createConfigTest0() { - QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = new QuerySuggestionsIndexWithIndexParam(); + @DisplayName("deleteConfig") + void deleteConfigTest0() { + String indexName0 = "theIndexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteConfig(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/configs/theIndexName"); + assertEquals(req.getMethod(), "DELETE"); + } + + @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 indexName1 = "theIndexName"; + String query1 = "parameters"; - querySuggestionsIndexWithIndexParam0.setIndexName(indexName1); + 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("updateConfig") + void updateConfigTest0() { + String indexName0 = "theIndexName"; + QuerySuggestionsIndexParam querySuggestionsIndexParam0 = new QuerySuggestionsIndexParam(); + { List sourceIndices1 = new ArrayList<>(); { SourceIndex sourceIndices_02 = new SourceIndex(); @@ -82,7 +165,7 @@ void createConfigTest0() { } sourceIndices1.add(sourceIndices_02); } - querySuggestionsIndexWithIndexParam0.setSourceIndices(sourceIndices1); + querySuggestionsIndexParam0.setSourceIndices(sourceIndices1); List languages1 = new ArrayList<>(); { @@ -90,7 +173,7 @@ void createConfigTest0() { languages1.add(languages_02); } - querySuggestionsIndexWithIndexParam0.setLanguages(languages1); + querySuggestionsIndexParam0.setLanguages(languages1); List exclude1 = new ArrayList<>(); { @@ -98,20 +181,20 @@ void createConfigTest0() { exclude1.add(exclude_02); } - querySuggestionsIndexWithIndexParam0.setExclude(exclude1); + querySuggestionsIndexParam0.setExclude(exclude1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.createConfig(querySuggestionsIndexWithIndexParam0); + return client.updateConfig(indexName0, querySuggestionsIndexParam0); } ); - assertEquals(req.getPath(), "/1/configs"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/configs/theIndexName"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", + "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -119,22 +202,22 @@ void createConfigTest0() { } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.get(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -145,12 +228,12 @@ void delTest1() { } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.get(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -175,36 +258,112 @@ void delTest1() { } @Test - @DisplayName("deleteConfig") - void deleteConfigTest0() { - String indexName0 = "theIndexName"; + @DisplayName("createConfig") + void createConfigTest0() { + QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = new QuerySuggestionsIndexWithIndexParam(); + { + String indexName1 = "theIndexName"; + + querySuggestionsIndexWithIndexParam0.setIndexName(indexName1); + + List sourceIndices1 = new ArrayList<>(); + { + SourceIndex sourceIndices_02 = new SourceIndex(); + { + String indexName3 = "testIndex"; + + sourceIndices_02.setIndexName(indexName3); + + List facets3 = new ArrayList<>(); + { + Map facets_04 = new HashMap<>(); + { + String attributes5 = "test"; + + facets_04.put("attributes", attributes5); + } + facets3.add(facets_04); + } + sourceIndices_02.setFacets(facets3); + + List> generate3 = new ArrayList<>(); + { + List generate_04 = new ArrayList<>(); + { + String generate_0_05 = "facetA"; + + generate_04.add(generate_0_05); + String generate_0_15 = "facetB"; + + generate_04.add(generate_0_15); + } + generate3.add(generate_04); + + List generate_14 = new ArrayList<>(); + { + String generate_1_05 = "facetC"; + + generate_14.add(generate_1_05); + } + generate3.add(generate_14); + } + sourceIndices_02.setGenerate(generate3); + } + sourceIndices1.add(sourceIndices_02); + } + querySuggestionsIndexWithIndexParam0.setSourceIndices(sourceIndices1); + + List languages1 = new ArrayList<>(); + { + String languages_02 = "french"; + + languages1.add(languages_02); + } + querySuggestionsIndexWithIndexParam0.setLanguages(languages1); + + List exclude1 = new ArrayList<>(); + { + String exclude_02 = "test"; + + exclude1.add(exclude_02); + } + querySuggestionsIndexWithIndexParam0.setExclude(exclude1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteConfig(indexName0); + return client.createConfig(querySuggestionsIndexWithIndexParam0); } ); - assertEquals(req.getPath(), "/1/configs/theIndexName"); - assertEquals(req.getMethod(), "DELETE"); + 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 + ); + }); } @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -215,12 +374,12 @@ void getTest1() { } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -244,32 +403,6 @@ void getTest1() { } } - @Test - @DisplayName("getAllConfigs") - void getAllConfigsTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAllConfigs(); - } - ); - - assertEquals(req.getPath(), "/1/configs"); - assertEquals(req.getMethod(), "GET"); - } - - @Test - @DisplayName("getConfig") - void getConfigTest0() { - String indexName0 = "theIndexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConfig(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/configs/theIndexName"); - assertEquals(req.getMethod(), "GET"); - } - @Test @DisplayName("getConfigStatus") void getConfigStatusTest0() { @@ -285,88 +418,29 @@ void getConfigStatusTest0() { } @Test - @DisplayName("getLogFile") - void getLogFileTest0() { - String indexName0 = "theIndexName"; - + @DisplayName("getAllConfigs") + void getAllConfigsTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogFile(indexName0); + return client.getAllConfigs(); } ); - assertEquals(req.getPath(), "/1/logs/theIndexName"); + assertEquals(req.getPath(), "/1/configs"); assertEquals(req.getMethod(), "GET"); } @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); - } + @DisplayName("getConfig") + void getConfigTest0() { + String indexName0 = "theIndexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); + return client.getConfig(indexName0); } ); - 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" - ); - } + assertEquals(req.getPath(), "/1/configs/theIndexName"); + assertEquals(req.getMethod(), "GET"); } @Test @@ -441,90 +515,16 @@ void putTest1() { } @Test - @DisplayName("updateConfig") - void updateConfigTest0() { + @DisplayName("getLogFile") + void getLogFileTest0() { String indexName0 = "theIndexName"; - QuerySuggestionsIndexParam querySuggestionsIndexParam0 = new QuerySuggestionsIndexParam(); - { - List sourceIndices1 = new ArrayList<>(); - { - SourceIndex sourceIndices_02 = new SourceIndex(); - { - String indexName3 = "testIndex"; - - sourceIndices_02.setIndexName(indexName3); - - List facets3 = new ArrayList<>(); - { - Map facets_04 = new HashMap<>(); - { - String attributes5 = "test"; - - facets_04.put("attributes", attributes5); - } - facets3.add(facets_04); - } - sourceIndices_02.setFacets(facets3); - - List> generate3 = new ArrayList<>(); - { - List generate_04 = new ArrayList<>(); - { - String generate_0_05 = "facetA"; - - generate_04.add(generate_0_05); - String generate_0_15 = "facetB"; - - generate_04.add(generate_0_15); - } - generate3.add(generate_04); - - List generate_14 = new ArrayList<>(); - { - String generate_1_05 = "facetC"; - - generate_14.add(generate_1_05); - } - generate3.add(generate_14); - } - sourceIndices_02.setGenerate(generate3); - } - sourceIndices1.add(sourceIndices_02); - } - querySuggestionsIndexParam0.setSourceIndices(sourceIndices1); - - List languages1 = new ArrayList<>(); - { - String languages_02 = "french"; - - languages1.add(languages_02); - } - querySuggestionsIndexParam0.setLanguages(languages1); - - List exclude1 = new ArrayList<>(); - { - String exclude_02 = "test"; - - exclude1.add(exclude_02); - } - querySuggestionsIndexParam0.setExclude(exclude1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.updateConfig(indexName0, querySuggestionsIndexParam0); + return client.getLogFile(indexName0); } ); - 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 - ); - }); + assertEquals(req.getPath(), "/1/logs/theIndexName"); + assertEquals(req.getMethod(), "GET"); } } 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..abeea99e42 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 @@ -29,22 +29,22 @@ void init() { } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.post(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -54,13 +54,28 @@ void delTest1() { parameters0.put("query", query1); } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.post(path0, parameters0, body0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -140,6 +155,62 @@ void getTest1() { } } + @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( "get recommendations for recommend model with minimal parameters" @@ -690,77 +761,6 @@ void getRecommendationsTest6() { }); } - @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() { 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 b165e0b4c2..dd2c53e855 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 @@ -29,147 +29,105 @@ void init() { } @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; + @DisplayName("batchAssignUserIds") + void batchAssignUserIdsTest0() { + String xAlgoliaUserID0 = "userID"; - apiKey0.setValidity(validity1); + BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); + { + String cluster1 = "theCluster"; - int maxQueriesPerIPPerHour1 = 100; + batchAssignUserIdsParams0.setCluster(cluster1); - apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); + List users1 = new ArrayList<>(); + { + String users_02 = "user1"; - int maxHitsPerQuery1 = 20; + users1.add(users_02); + String users_12 = "user2"; - apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); + users1.add(users_12); + } + batchAssignUserIdsParams0.setUsers(users1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addApiKey(apiKey0); + return client.batchAssignUserIds( + xAlgoliaUserID0, + batchAssignUserIdsParams0 + ); } ); - assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getPath(), "/1/clusters/mapping/batch"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api" + - " key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", + "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); - } - - @Test - @DisplayName("addOrUpdateObject") - void addOrUpdateObjectTest0() { - String indexName0 = "indexName"; - - String objectID0 = "uniqueID"; - - Map body0 = new HashMap<>(); - { - String key1 = "value"; - - body0.put("key", key1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addOrUpdateObject(indexName0, objectID0, body0); - } + Map expectedQuery = JSON.deserialize( + "{\"X-Algolia-User-ID\":\"userID\"}", + new TypeToken>() {}.getType() ); - - assertEquals(req.getPath(), "/1/indexes/indexName/uniqueID"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"key\":\"value\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER + 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("appendSource") - void appendSourceTest0() { - Source source0 = new Source(); - { - String source1 = "theSource"; - - source0.setSource(source1); - String description1 = "theDescription"; - - source0.setDescription(description1); - } + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.appendSource(source0); + return client.del(path0); } ); - assertEquals(req.getPath(), "/1/security/sources/append"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"source\":\"theSource\",\"description\":\"theDescription\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("assignUserId") - void assignUserIdTest0() { - String xAlgoliaUserID0 = "userID"; + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { + String path0 = "/test/all"; - AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); + Map parameters0 = new HashMap<>(); { - String cluster1 = "theCluster"; + String query1 = "parameters"; - assignUserIdParams0.setCluster(cluster1); + parameters0.put("query", query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.assignUserId(xAlgoliaUserID0, assignUserIdParams0); + return client.del(path0, parameters0); } ); - assertEquals(req.getPath(), "/1/clusters/mapping"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"cluster\":\"theCluster\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( - "{\"X-Algolia-User-ID\":\"userID\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -191,44 +149,28 @@ void assignUserIdTest0() { } @Test - @DisplayName("batch") - void batchTest0() { - String indexName0 = "theIndexName"; + @DisplayName("searchRules") + void searchRulesTest0() { + String indexName0 = "indexName"; - BatchWriteParams batchWriteParams0 = new BatchWriteParams(); + SearchRulesParams searchRulesParams0 = new SearchRulesParams(); { - 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"; + String query1 = "something"; - body3.put("key", key4); - } - requests_02.setBody(body3); - } - requests1.add(requests_02); - } - batchWriteParams0.setRequests(requests1); + searchRulesParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batch(indexName0, batchWriteParams0); + return client.searchRules(indexName0, searchRulesParams0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", + "{\"query\":\"something\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -236,49 +178,70 @@ void batchTest0() { } @Test - @DisplayName("batchAssignUserIds") - void batchAssignUserIdsTest0() { - String xAlgoliaUserID0 = "userID"; - - BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); - { - String cluster1 = "theCluster"; + @DisplayName("deleteIndex") + void deleteIndexTest0() { + String indexName0 = "theIndexName"; - batchAssignUserIdsParams0.setCluster(cluster1); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteIndex(indexName0); + } + ); - List users1 = new ArrayList<>(); - { - String users_02 = "user1"; + assertEquals(req.getPath(), "/1/indexes/theIndexName"); + assertEquals(req.getMethod(), "DELETE"); + } - users1.add(users_02); - String users_12 = "user2"; + @Test + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; - users1.add(users_12); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); } - batchAssignUserIdsParams0.setUsers(users1); + ); + + 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.batchAssignUserIds( - xAlgoliaUserID0, - batchAssignUserIdsParams0 - ); + return client.put(path0, parameters0, body0); } ); - assertEquals(req.getPath(), "/1/clusters/mapping/batch"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", + "{\"body\":\"parameters\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); Map expectedQuery = JSON.deserialize( - "{\"X-Algolia-User-ID\":\"userID\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -300,9 +263,58 @@ void batchAssignUserIdsTest0() { } @Test - @DisplayName("get batchDictionaryEntries results with minimal parameters") - void batchDictionaryEntriesTest0() { - DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); + @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 + ); + }); + } + + @Test + @DisplayName("get batchDictionaryEntries results with minimal parameters") + void batchDictionaryEntriesTest0() { + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); { @@ -635,110 +647,36 @@ void batchRulesTest0() { } @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"; + @DisplayName("restoreApiKey") + void restoreApiKeyTest0() { + String key0 = "myApiKey"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearRules(indexName0); + return client.restoreApiKey(key0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/clear"); + assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.post(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -748,13 +686,28 @@ void delTest1() { parameters0.put("query", query1); } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.post(path0, parameters0, body0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -779,65 +732,51 @@ void delTest1() { } @Test - @DisplayName("deleteApiKey") - void deleteApiKeyTest0() { - String key0 = "myTestApiKey"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteApiKey(key0); - } - ); + @DisplayName("multipleBatch") + void multipleBatchTest0() { + BatchParams batchParams0 = new BatchParams(); + { + List requests1 = new ArrayList<>(); + { + MultipleBatchOperation requests_02 = new MultipleBatchOperation(); + { + Action action3 = Action.fromValue("addObject"); - assertEquals(req.getPath(), "/1/keys/myTestApiKey"); - assertEquals(req.getMethod(), "DELETE"); - } + requests_02.setAction(action3); - @Test - @DisplayName("deleteBy") - void deleteByTest0() { - String indexName0 = "theIndexName"; + Map body3 = new HashMap<>(); + { + String key4 = "value"; - SearchParamsObject searchParams0 = new SearchParamsObject(); - { - String query1 = "testQuery"; + body3.put("key", key4); + } + requests_02.setBody(body3); + String indexName3 = "theIndexName"; - searchParams0.setQuery(query1); + requests_02.setIndexName(indexName3); + } + requests1.add(requests_02); + } + batchParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteBy( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); + return client.multipleBatch(batchParams0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); + assertEquals(req.getPath(), "/1/indexes/*/batch"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"testQuery\"}", + "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", 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() { @@ -855,87 +794,118 @@ void deleteObjectTest0() { } @Test - @DisplayName("deleteRule") - void deleteRuleTest0() { - String indexName0 = "indexName"; + @DisplayName("searchUserIds") + void searchUserIdsTest0() { + SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); + { + String query1 = "test"; - String objectID0 = "id1"; + 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.deleteRule(indexName0, objectID0); + return client.searchUserIds(searchUserIdsParams0); } ); - 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/clusters/mapping/search"); + assertEquals(req.getMethod(), "POST"); - assertEquals(req.getPath(), "/1/security/sources/theSource"); - assertEquals(req.getMethod(), "DELETE"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test - @DisplayName("deleteSynonym") - void deleteSynonymTest0() { - String indexName0 = "indexName"; + @DisplayName("replaceSources") + void replaceSourcesTest0() { + List source0 = new ArrayList<>(); + { + Source source_01 = new Source(); + { + String source2 = "theSource"; - String objectID0 = "id1"; + source_01.setSource(source2); + String description2 = "theDescription"; + + source_01.setDescription(description2); + } + source0.add(source_01); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSynonym(indexName0, objectID0); + return client.replaceSources(source0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/1/security/sources"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; + @DisplayName("removeUserId") + void removeUserIdTest0() { + String userID0 = "uniqueID"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); + return client.removeUserId(userID0); } ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; + @DisplayName("getObject") + void getObjectTest0() { + String indexName0 = "theIndexName"; - Map parameters0 = new HashMap<>(); + String objectID0 = "uniqueID"; + + List attributesToRetrieve0 = new ArrayList<>(); { - String query1 = "parameters"; + String attributesToRetrieve_01 = "attr1"; - parameters0.put("query", query1); + attributesToRetrieve0.add(attributesToRetrieve_01); + String attributesToRetrieve_11 = "attr2"; + + attributesToRetrieve0.add(attributesToRetrieve_11); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); + return client.getObject(indexName0, objectID0, attributesToRetrieve0); } ); - assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"attributesToRetrieve\":\"attr1,attr2\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -971,50 +941,35 @@ void getApiKeyTest0() { } @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; + @DisplayName("assignUserId") + void assignUserIdTest0() { + String xAlgoliaUserID0 = "userID"; - String indexName0 = "theIndexName"; + AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); + { + String cluster1 = "theCluster"; - LogType type0 = LogType.fromValue("all"); + assignUserIdParams0.setCluster(cluster1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogs(offset0, length0, indexName0, type0); + return client.assignUserId(xAlgoliaUserID0, assignUserIdParams0); } ); - assertEquals(req.getPath(), "/1/logs"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/clusters/mapping"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"cluster\":\"theCluster\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( - "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", + "{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1036,32 +991,56 @@ void getLogsTest0() { } @Test - @DisplayName("getObject") - void getObjectTest0() { - String indexName0 = "theIndexName"; + @DisplayName("deleteSynonym") + void deleteSynonymTest0() { + String indexName0 = "indexName"; - String objectID0 = "uniqueID"; + String objectID0 = "id1"; - List attributesToRetrieve0 = new ArrayList<>(); - { - String attributesToRetrieve_01 = "attr1"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteSynonym(indexName0, objectID0); + } + ); - attributesToRetrieve0.add(attributesToRetrieve_01); - String attributesToRetrieve_11 = "attr2"; + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "DELETE"); + } - attributesToRetrieve0.add(attributesToRetrieve_11); - } + @Test + @DisplayName("searchSynonyms") + void searchSynonymsTest0() { + String indexName0 = "indexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObject(indexName0, objectID0, attributesToRetrieve0); + return client.searchSynonyms(indexName0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/search"); + assertEquals(req.getMethod(), "POST"); + } + + @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( - "{\"attributesToRetrieve\":\"attr1,attr2\"}", + "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1083,47 +1062,44 @@ void getObjectTest0() { } @Test - @DisplayName("getObjects") - void getObjectsTest0() { - GetObjectsParams getObjectsParams0 = new GetObjectsParams(); + @DisplayName("batch") + void batchTest0() { + String indexName0 = "theIndexName"; + + BatchWriteParams batchWriteParams0 = new BatchWriteParams(); { - List requests1 = new ArrayList<>(); + List requests1 = new ArrayList<>(); { - MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); + BatchOperation requests_02 = new BatchOperation(); { - List attributesToRetrieve3 = new ArrayList<>(); - { - String attributesToRetrieve_04 = "attr1"; - - attributesToRetrieve3.add(attributesToRetrieve_04); - String attributesToRetrieve_14 = "attr2"; + Action action3 = Action.fromValue("delete"); - attributesToRetrieve3.add(attributesToRetrieve_14); - } - requests_02.setAttributesToRetrieve(attributesToRetrieve3); - String objectID3 = "uniqueID"; + requests_02.setAction(action3); - requests_02.setObjectID(objectID3); - String indexName3 = "theIndexName"; + Map body3 = new HashMap<>(); + { + String key4 = "value"; - requests_02.setIndexName(indexName3); + body3.put("key", key4); + } + requests_02.setBody(body3); } requests1.add(requests_02); } - getObjectsParams0.setRequests(requests1); + batchWriteParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObjects(getObjectsParams0); + return client.batch(indexName0, batchWriteParams0); } ); - assertEquals(req.getPath(), "/1/indexes/*/objects"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"attributesToRetrieve\":[\"attr1\",\"attr2\"],\"objectID\":\"uniqueID\",\"indexName\":\"theIndexName\"}]}", + "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1131,120 +1107,86 @@ void getObjectsTest0() { } @Test - @DisplayName("getRule") - void getRuleTest0() { + @DisplayName("addOrUpdateObject") + void addOrUpdateObjectTest0() { String indexName0 = "indexName"; - String objectID0 = "id1"; + String objectID0 = "uniqueID"; + + Map body0 = new HashMap<>(); + { + String key1 = "value"; + + body0.put("key", key1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRule(indexName0, objectID0); + return client.addOrUpdateObject(indexName0, objectID0, body0); } ); - 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/indexes/indexName/uniqueID"); + assertEquals(req.getMethod(), "PUT"); - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "GET"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"key\":\"value\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test - @DisplayName("getSynonym") - void getSynonymTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; + @DisplayName("clearObjects") + void clearObjectsTest0() { + String indexName0 = "theIndexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSynonym(indexName0, objectID0); + return client.clearObjects(indexName0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/clear"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("getTask") - void getTaskTest0() { + @DisplayName("setSettings") + void setSettingsTest0() { 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(); - } - ); + IndexSettings indexSettings0 = new IndexSettings(); + { + int paginationLimitedTo1 = 10; - assertEquals(req.getPath(), "/1/clusters/mapping/top"); - assertEquals(req.getMethod(), "GET"); - } + indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); + } - @Test - @DisplayName("getUserId") - void getUserIdTest0() { - String userID0 = "uniqueID"; + boolean forwardToReplicas0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUserId(userID0); + return client.setSettings( + indexName0, + indexSettings0, + forwardToReplicas0 + ); } ); - 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/indexes/theIndexName/settings"); + assertEquals(req.getMethod(), "PUT"); - assertEquals(req.getPath(), "/1/clusters/mapping/pending"); - assertEquals(req.getMethod(), "GET"); + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"paginationLimitedTo\":10}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( - "{\"getClusters\":\"true\"}", + "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1266,62 +1208,65 @@ void hasPendingMappingsTest0() { } @Test - @DisplayName("listApiKeys") - void listApiKeysTest0() { + @DisplayName("clearRules") + void clearRulesTest0() { + String indexName0 = "indexName"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listApiKeys(); + return client.clearRules(indexName0); } ); - assertEquals(req.getPath(), "/1/keys"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/clear"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("listClusters") - void listClustersTest0() { + @DisplayName("getSynonym") + void getSynonymTest0() { + String indexName0 = "indexName"; + + String objectID0 = "id1"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listClusters(); + return client.getSynonym(indexName0, objectID0); } ); - assertEquals(req.getPath(), "/1/clusters"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("listIndices") - void listIndicesTest0() { - int page0 = 8; + @DisplayName("deleteBy") + void deleteByTest0() { + String indexName0 = "theIndexName"; + + SearchParamsObject searchParams0 = new SearchParamsObject(); + { + String query1 = "testQuery"; + + searchParams0.setQuery(query1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listIndices(page0); + return client.deleteBy( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); } ); - assertEquals(req.getPath(), "/1/indexes"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); + assertEquals(req.getMethod(), "POST"); - 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" + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"testQuery\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER ); - } + }); } @Test @@ -1362,45 +1307,45 @@ void listUserIdsTest0() { } @Test - @DisplayName("multipleBatch") - void multipleBatchTest0() { - BatchParams batchParams0 = new BatchParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleBatchOperation requests_02 = new MultipleBatchOperation(); - { - Action action3 = Action.fromValue("addObject"); + @DisplayName("get browse results with minimal parameters") + void browseTest0() { + String indexName0 = "indexName"; - requests_02.setAction(action3); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.browse(indexName0); + } + ); - Map body3 = new HashMap<>(); - { - String key4 = "value"; + assertEquals(req.getPath(), "/1/indexes/indexName/browse"); + assertEquals(req.getMethod(), "POST"); + } - body3.put("key", key4); - } - requests_02.setBody(body3); - String indexName3 = "theIndexName"; + @Test + @DisplayName("get browse results with all parameters") + void browseTest1() { + String indexName0 = "indexName"; - requests_02.setIndexName(indexName3); - } - requests1.add(requests_02); - } - batchParams0.setRequests(requests1); + 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.multipleBatch(batchParams0); + return client.browse(indexName0, browseRequest0); } ); - assertEquals(req.getPath(), "/1/indexes/*/batch"); + assertEquals(req.getPath(), "/1/indexes/indexName/browse"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", + "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1408,21 +1353,151 @@ void multipleBatchTest0() { } @Test - @DisplayName("multipleQueries for a single request with minimal parameters") - void multipleQueriesTest0() { - MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); + @DisplayName("getObjects") + void getObjectsTest0() { + GetObjectsParams getObjectsParams0 = new GetObjectsParams(); { - List requests1 = new ArrayList<>(); + List requests1 = new ArrayList<>(); { - MultipleQueries requests_02 = new MultipleQueries(); + MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); { - String indexName3 = "theIndexName"; + List attributesToRetrieve3 = new ArrayList<>(); + { + String attributesToRetrieve_04 = "attr1"; - requests_02.setIndexName(indexName3); - } - requests1.add(requests_02); - } - multipleQueriesParams0.setRequests(requests1); + 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("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("multipleQueries for a single request with minimal parameters") + void multipleQueriesTest0() { + MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); + { + List requests1 = new ArrayList<>(); + { + MultipleQueries requests_02 = new MultipleQueries(); + { + String indexName3 = "theIndexName"; + + requests_02.setIndexName(indexName3); + } + requests1.add(requests_02); + } + multipleQueriesParams0.setRequests(requests1); MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue( "stopIfEnoughMatches" @@ -1521,111 +1596,92 @@ void multipleQueriesTest1() { } @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"); + @DisplayName("get searchForFacetValues results with minimal parameters") + void searchForFacetValuesTest0() { + String indexName0 = "indexName"; - scope1.add(scope_12); - } - operationIndexParams0.setScope(scope1); - } + String facetName0 = "facetName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.operationIndex(indexName0, operationIndexParams0); + return client.searchForFacetValues(indexName0, facetName0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); + assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); 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"; + @DisplayName("get searchForFacetValues results with all parameters") + void searchForFacetValuesTest1() { + String indexName0 = "indexName"; - String objectID0 = "uniqueID"; + String facetName0 = "facetName"; - List> attributeOrBuiltInOperation0 = new ArrayList<>(); + SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); { - Map attributeOrBuiltInOperation_01 = new HashMap<>(); - { - String id12 = "test"; + String params1 = "query=foo&facetFilters=['bar']"; - attributeOrBuiltInOperation_01.put( - "id1", - AttributeOrBuiltInOperation.ofString(id12) - ); + searchForFacetValuesRequest0.setParams(params1); + String facetQuery1 = "foo"; - BuiltInOperation id22 = new BuiltInOperation(); - { - BuiltInOperationType operation3 = BuiltInOperationType.fromValue( - "AddUnique" - ); + searchForFacetValuesRequest0.setFacetQuery(facetQuery1); - id22.setOperation(operation3); - String value3 = "test2"; + int maxFacetHits1 = 42; - id22.setValue(value3); - } - attributeOrBuiltInOperation_01.put( - "id2", - AttributeOrBuiltInOperation.ofBuiltInOperation(id22) - ); - } - attributeOrBuiltInOperation0.add(attributeOrBuiltInOperation_01); + searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); } - boolean createIfNotExists0 = true; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.partialUpdateObject( + return client.searchForFacetValues( indexName0, - objectID0, - attributeOrBuiltInOperation0, - createIfNotExists0 + facetName0, + searchForFacetValuesRequest0 ); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID/partial"); + assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]", + "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); + } + + @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("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( - "{\"createIfNotExists\":\"true\"}", + "{\"page\":\"8\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1647,127 +1703,171 @@ void partialUpdateObjectTest0() { } @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { - String path0 = "/test/minimal"; - + @DisplayName("get getDictionarySettings results") + void getDictionarySettingsTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); + return client.getDictionarySettings(); } ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { - String path0 = "/test/all"; + @DisplayName("deleteSource") + void deleteSourceTest0() { + String source0 = "theSource"; - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteSource(source0); + } + ); - parameters0.put("query", query1); - } + assertEquals(req.getPath(), "/1/security/sources/theSource"); + assertEquals(req.getMethod(), "DELETE"); + } - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; + @Test + @DisplayName("getSources") + void getSourcesTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getSources(); + } + ); - body0.put("body", body1); - } + assertEquals(req.getPath(), "/1/security/sources"); + assertEquals(req.getMethod(), "GET"); + } + @Test + @DisplayName("get getDictionaryLanguages") + void getDictionaryLanguagesTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); + return client.getDictionaryLanguages(); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/dictionaries/*/languages"); + assertEquals(req.getMethod(), "GET"); + } - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + @Test + @DisplayName("deleteApiKey") + void deleteApiKeyTest0() { + String key0 = "myTestApiKey"; - 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.deleteApiKey(key0); } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); - } + ); + + assertEquals(req.getPath(), "/1/keys/myTestApiKey"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow put method for a custom path with minimal parameters") - void putTest0() { - String path0 = "/test/minimal"; - + @DisplayName("listApiKeys") + void listApiKeysTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0); + return client.listApiKeys(); } ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("allow put method for a custom path with all parameters") - void putTest1() { - String path0 = "/test/all"; + @DisplayName("saveSynonyms") + void saveSynonymsTest0() { + String indexName0 = "indexName"; - Map parameters0 = new HashMap<>(); + List synonymHit0 = new ArrayList<>(); { - String query1 = "parameters"; + SynonymHit synonymHit_01 = new SynonymHit(); + { + String objectID2 = "id1"; - parameters0.put("query", query1); - } + synonymHit_01.setObjectID(objectID2); - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; + SynonymType type2 = SynonymType.fromValue("synonym"); - body0.put("body", body1); + 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.put(path0, parameters0, body0); + return client.saveSynonyms( + indexName0, + synonymHit0, + forwardToReplicas0, + replaceExistingSynonyms0 + ); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", + "[{\"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( - "{\"query\":\"parameters\"}", + "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1789,47 +1889,71 @@ void putTest1() { } @Test - @DisplayName("removeUserId") - void removeUserIdTest0() { - String userID0 = "uniqueID"; + @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.removeUserId(userID0); + return client.search( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); } ); - assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"myQuery\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test - @DisplayName("replaceSources") - void replaceSourcesTest0() { - List source0 = new ArrayList<>(); + @DisplayName("search with facetFilters") + void searchTest1() { + String indexName0 = "indexName"; + + SearchParamsObject searchParams0 = new SearchParamsObject(); { - Source source_01 = new Source(); - { - String source2 = "theSource"; + String query1 = "myQuery"; - source_01.setSource(source2); - String description2 = "theDescription"; + searchParams0.setQuery(query1); - source_01.setDescription(description2); + List facetFilters1 = new ArrayList<>(); + { + String facetFilters_02 = "tags:algolia"; + + facetFilters1.add(facetFilters_02); } - source0.add(source_01); + searchParams0.setFacetFilters(FacetFilters.ofListString(facetFilters1)); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.replaceSources(source0); + return client.search( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); } ); - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", + "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1837,118 +1961,76 @@ void replaceSourcesTest0() { } @Test - @DisplayName("restoreApiKey") - void restoreApiKeyTest0() { - String key0 = "myApiKey"; + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.restoreApiKey(key0); + return client.get(path0); } ); - assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("saveObject") - void saveObjectTest0() { - String indexName0 = "theIndexName"; + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; - Map body0 = new HashMap<>(); + Map parameters0 = new HashMap<>(); { - String objectID1 = "id"; - - body0.put("objectID", objectID1); - String test1 = "val"; + String query1 = "parameters"; - body0.put("test", test1); + parameters0.put("query", query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveObject(indexName0, body0); + return client.get(path0, parameters0); } ); - 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"; + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "GET"); - params2.setFilters(filters3); + 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; } - consequence1.setParams(params2); } - rule0.setConsequence(consequence1); + assertTrue( + found, + "Query parameter " + entry.getKey() + " not found in the actual query" + ); } + } - boolean forwardToReplicas0 = true; + @Test + @DisplayName("hasPendingMappings") + void hasPendingMappingsTest0() { + boolean getClusters0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveRule( - indexName0, - objectID0, - rule0, - forwardToReplicas0 - ); + return client.hasPendingMappings(getClusters0); } ); - 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 - ); - }); + assertEquals(req.getPath(), "/1/clusters/mapping/pending"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\"}", + "{\"getClusters\":\"true\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1970,172 +2052,206 @@ void saveRuleTest0() { } @Test - @DisplayName("saveSynonym") - void saveSynonymTest0() { - String indexName0 = "indexName"; + @DisplayName("getTopUserIds") + void getTopUserIdsTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTopUserIds(); + } + ); - String objectID0 = "id1"; + assertEquals(req.getPath(), "/1/clusters/mapping/top"); + assertEquals(req.getMethod(), "GET"); + } - SynonymHit synonymHit0 = new SynonymHit(); + @Test + @DisplayName("get setDictionarySettings results with minimal parameters") + void setDictionarySettingsTest0() { + DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); { - String objectID1 = "id1"; - - synonymHit0.setObjectID(objectID1); - - SynonymType type1 = SynonymType.fromValue("synonym"); + StandardEntries disableStandardEntries1 = new StandardEntries(); + { + Map plurals2 = new HashMap<>(); + { + boolean fr3 = false; - synonymHit0.setType(type1); + plurals2.put("fr", fr3); - List synonyms1 = new ArrayList<>(); - { - String synonyms_02 = "car"; + boolean en3 = false; - synonyms1.add(synonyms_02); - String synonyms_12 = "vehicule"; + plurals2.put("en", en3); - synonyms1.add(synonyms_12); - String synonyms_22 = "auto"; + boolean ru3 = true; - synonyms1.add(synonyms_22); + plurals2.put("ru", ru3); + } + disableStandardEntries1.setPlurals(plurals2); } - synonymHit0.setSynonyms(synonyms1); + dictionarySettingsParams0.setDisableStandardEntries( + disableStandardEntries1 + ); } - boolean forwardToReplicas0 = true; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonym( - indexName0, - objectID0, - synonymHit0, - forwardToReplicas0 - ); + return client.setDictionarySettings(dictionarySettingsParams0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", 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; + @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); } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" + 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("saveSynonyms") - void saveSynonymsTest0() { + @DisplayName("deleteRule") + void deleteRuleTest0() { String indexName0 = "indexName"; - List synonymHit0 = new ArrayList<>(); - { - SynonymHit synonymHit_01 = new SynonymHit(); - { - String objectID2 = "id1"; - - synonymHit_01.setObjectID(objectID2); + String objectID0 = "id1"; - SynonymType type2 = SynonymType.fromValue("synonym"); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteRule(indexName0, objectID0); + } + ); - synonymHit_01.setType(type2); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "DELETE"); + } - List synonyms2 = new ArrayList<>(); - { - String synonyms_03 = "car"; + @Test + @DisplayName("saveRule") + void saveRuleTest0() { + String indexName0 = "indexName"; - synonyms2.add(synonyms_03); - String synonyms_13 = "vehicule"; + String objectID0 = "id1"; - synonyms2.add(synonyms_13); - String synonyms_23 = "auto"; + Rule rule0 = new Rule(); + { + String objectID1 = "id1"; - synonyms2.add(synonyms_23); - } - synonymHit_01.setSynonyms(synonyms2); - } - synonymHit0.add(synonymHit_01); + rule0.setObjectID(objectID1); - SynonymHit synonymHit_11 = new SynonymHit(); + List conditions1 = new ArrayList<>(); { - String objectID2 = "id2"; - - synonymHit_11.setObjectID(objectID2); + Condition conditions_02 = new Condition(); + { + String pattern3 = "apple"; - SynonymType type2 = SynonymType.fromValue("onewaysynonym"); + conditions_02.setPattern(pattern3); - synonymHit_11.setType(type2); - String input2 = "iphone"; + Anchoring anchoring3 = Anchoring.fromValue("contains"); - synonymHit_11.setInput(input2); + conditions_02.setAnchoring(anchoring3); + } + conditions1.add(conditions_02); + } + rule0.setConditions(conditions1); - List synonyms2 = new ArrayList<>(); + Consequence consequence1 = new Consequence(); + { + ConsequenceParams params2 = new ConsequenceParams(); { - String synonyms_03 = "ephone"; - - synonyms2.add(synonyms_03); - String synonyms_13 = "aphone"; - - synonyms2.add(synonyms_13); - String synonyms_23 = "yphone"; + String filters3 = "brand:apple"; - synonyms2.add(synonyms_23); + params2.setFilters(filters3); } - synonymHit_11.setSynonyms(synonyms2); + consequence1.setParams(params2); } - synonymHit0.add(synonymHit_11); + rule0.setConsequence(consequence1); } boolean forwardToReplicas0 = true; - boolean replaceExistingSynonyms0 = false; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonyms( + return client.saveRule( indexName0, - synonymHit0, - forwardToReplicas0, - replaceExistingSynonyms0 + objectID0, + rule0, + forwardToReplicas0 ); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]", + "{\"objectID\":\"id1\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", + "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -2157,31 +2273,31 @@ void saveSynonymsTest0() { } @Test - @DisplayName("search with minimal parameters") - void searchTest0() { - String indexName0 = "indexName"; + @DisplayName("saveObject") + void saveObjectTest0() { + String indexName0 = "theIndexName"; - SearchParamsObject searchParams0 = new SearchParamsObject(); + Map body0 = new HashMap<>(); { - String query1 = "myQuery"; + String objectID1 = "id"; - searchParams0.setQuery(query1); + body0.put("objectID", objectID1); + String test1 = "val"; + + body0.put("test", test1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); + return client.saveObject(indexName0, body0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getPath(), "/1/indexes/theIndexName"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"myQuery\"}", + "{\"objectID\":\"id\",\"test\":\"val\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2189,172 +2305,106 @@ void searchTest0() { } @Test - @DisplayName("search with facetFilters") - void searchTest1() { + @DisplayName("saveSynonym") + void saveSynonymTest0() { 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"); + String objectID0 = "id1"; - SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); + SynonymHit synonymHit0 = new SynonymHit(); { - 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"); + String objectID1 = "id1"; - SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); - { - String query1 = "foo"; + synonymHit0.setObjectID(objectID1); - searchDictionaryEntriesParams0.setQuery(query1); + SynonymType type1 = SynonymType.fromValue("synonym"); - int page1 = 4; + synonymHit0.setType(type1); - searchDictionaryEntriesParams0.setPage(page1); + List synonyms1 = new ArrayList<>(); + { + String synonyms_02 = "car"; - int hitsPerPage1 = 2; + synonyms1.add(synonyms_02); + String synonyms_12 = "vehicule"; - searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); - String language1 = "fr"; + synonyms1.add(synonyms_12); + String synonyms_22 = "auto"; - searchDictionaryEntriesParams0.setLanguage(language1); + synonyms1.add(synonyms_22); + } + synonymHit0.setSynonyms(synonyms1); } + boolean forwardToReplicas0 = true; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchDictionaryEntries( - dictionaryName0, - searchDictionaryEntriesParams0 + return client.saveSynonym( + indexName0, + objectID0, + synonymHit0, + forwardToReplicas0 ); } ); - assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"foo\",\"page\":4,\"hitsPerPage\":2,\"language\":\"fr\"}", + "{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", 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); - } + Map expectedQuery = JSON.deserialize( + "{\"forwardToReplicas\":\"true\"}", + new TypeToken>() {}.getType() ); - - assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); - assertEquals(req.getMethod(), "POST"); + 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 searchForFacetValues results with all parameters") - void searchForFacetValuesTest1() { - String indexName0 = "indexName"; - - String facetName0 = "facetName"; - - SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); + @DisplayName("appendSource") + void appendSourceTest0() { + Source source0 = new Source(); { - String params1 = "query=foo&facetFilters=['bar']"; - - searchForFacetValuesRequest0.setParams(params1); - String facetQuery1 = "foo"; - - searchForFacetValuesRequest0.setFacetQuery(facetQuery1); + String source1 = "theSource"; - int maxFacetHits1 = 42; + source0.setSource(source1); + String description1 = "theDescription"; - searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); + source0.setDescription(description1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchForFacetValues( - indexName0, - facetName0, - searchForFacetValuesRequest0 - ); + return client.appendSource(source0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); + assertEquals(req.getPath(), "/1/security/sources/append"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", + "{\"source\":\"theSource\",\"description\":\"theDescription\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2362,80 +2412,73 @@ void searchForFacetValuesTest1() { } @Test - @DisplayName("searchRules") - void searchRulesTest0() { + @DisplayName("clearAllSynonyms") + void clearAllSynonymsTest0() { String indexName0 = "indexName"; - SearchRulesParams searchRulesParams0 = new SearchRulesParams(); - { - String query1 = "something"; - - searchRulesParams0.setQuery(query1); - } - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchRules(indexName0, searchRulesParams0); + return client.clearAllSynonyms(indexName0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"something\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/clear"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("searchSynonyms") - void searchSynonymsTest0() { + @DisplayName("getRule") + void getRuleTest0() { String indexName0 = "indexName"; + String objectID0 = "id1"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchSynonyms(indexName0); + return client.getRule(indexName0, objectID0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/search"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("searchUserIds") - void searchUserIdsTest0() { - SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); + @DisplayName("operationIndex") + void operationIndexTest0() { + String indexName0 = "theIndexName"; + + OperationIndexParams operationIndexParams0 = new OperationIndexParams(); { - String query1 = "test"; + OperationType operation1 = OperationType.fromValue("copy"); - searchUserIdsParams0.setQuery(query1); - String clusterName1 = "theClusterName"; + operationIndexParams0.setOperation(operation1); + String destination1 = "dest"; - searchUserIdsParams0.setClusterName(clusterName1); + operationIndexParams0.setDestination(destination1); - int page1 = 5; + List scope1 = new ArrayList<>(); + { + ScopeType scope_02 = ScopeType.fromValue("rules"); - searchUserIdsParams0.setPage(page1); + scope1.add(scope_02); - int hitsPerPage1 = 10; + ScopeType scope_12 = ScopeType.fromValue("settings"); - searchUserIdsParams0.setHitsPerPage(hitsPerPage1); + scope1.add(scope_12); + } + operationIndexParams0.setScope(scope1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchUserIds(searchUserIdsParams0); + return client.operationIndex(indexName0, operationIndexParams0); } ); - assertEquals(req.getPath(), "/1/clusters/mapping/search"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", + "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2443,44 +2486,31 @@ void searchUserIdsTest0() { } @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); + @DisplayName("get searchDictionaryEntries results with minimal parameters") + void searchDictionaryEntriesTest0() { + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - boolean ru3 = true; + SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); + { + String query1 = "foo"; - plurals2.put("ru", ru3); - } - disableStandardEntries1.setPlurals(plurals2); - } - dictionarySettingsParams0.setDisableStandardEntries( - disableStandardEntries1 - ); + searchDictionaryEntriesParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(dictionarySettingsParams0); + return client.searchDictionaryEntries( + dictionaryName0, + searchDictionaryEntriesParams0 + ); } ); - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", + "{\"query\":\"foo\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2488,60 +2518,42 @@ void setDictionarySettingsTest0() { } @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; + @DisplayName("get searchDictionaryEntries results with all parameters") + void searchDictionaryEntriesTest1() { + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - plurals2.put("en", en3); + SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); + { + String query1 = "foo"; - boolean ru3 = true; + searchDictionaryEntriesParams0.setQuery(query1); - plurals2.put("ru", ru3); - } - disableStandardEntries1.setPlurals(plurals2); + int page1 = 4; - Map stopwords2 = new HashMap<>(); - { - boolean fr3 = false; + searchDictionaryEntriesParams0.setPage(page1); - stopwords2.put("fr", fr3); - } - disableStandardEntries1.setStopwords(stopwords2); + int hitsPerPage1 = 2; - Map compounds2 = new HashMap<>(); - { - boolean ru3 = true; + searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); + String language1 = "fr"; - compounds2.put("ru", ru3); - } - disableStandardEntries1.setCompounds(compounds2); - } - dictionarySettingsParams0.setDisableStandardEntries( - disableStandardEntries1 - ); + searchDictionaryEntriesParams0.setLanguage(language1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(dictionarySettingsParams0); + return client.searchDictionaryEntries( + dictionaryName0, + searchDictionaryEntriesParams0 + ); } ); - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}", + "{\"query\":\"foo\",\"page\":4,\"hitsPerPage\":2,\"language\":\"fr\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2549,66 +2561,20 @@ void setDictionarySettingsTest1() { } @Test - @DisplayName("setSettings") - void setSettingsTest0() { - String indexName0 = "theIndexName"; - - IndexSettings indexSettings0 = new IndexSettings(); - { - int paginationLimitedTo1 = 10; - - indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); - } - - boolean forwardToReplicas0 = true; - + @DisplayName("listClusters") + void listClustersTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setSettings( - indexName0, - indexSettings0, - forwardToReplicas0 - ); + return client.listClusters(); } ); - 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" - ); - } + assertEquals(req.getPath(), "/1/clusters"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("updateApiKey") - void updateApiKeyTest0() { - String key0 = "myApiKey"; - + @DisplayName("addApiKey") + void addApiKeyTest0() { ApiKey apiKey0 = new ApiKey(); { List acl1 = new ArrayList<>(); @@ -2622,6 +2588,9 @@ void updateApiKeyTest0() { acl1.add(acl_12); } apiKey0.setAcl(acl1); + String description1 = "my new api key"; + + apiKey0.setDescription(description1); int validity1 = 300; @@ -2637,19 +2606,50 @@ void updateApiKeyTest0() { } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.updateApiKey(key0, apiKey0); + return client.addApiKey(apiKey0); } ); - assertEquals(req.getPath(), "/1/keys/myApiKey"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", + "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api" + + " key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); } + + @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("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"); + } } diff --git a/tests/output/javascript/src/methods/requests/abtesting.test.ts b/tests/output/javascript/src/methods/requests/abtesting.test.ts index 6ae5e9153e..6a77429916 100644 --- a/tests/output/javascript/src/methods/requests/abtesting.test.ts +++ b/tests/output/javascript/src/methods/requests/abtesting.test.ts @@ -9,69 +9,83 @@ const client = abtestingClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('addABTests', () => { - test('addABTests with minimal parameters', async () => { - const req = (await client.addABTests({ - endAt: '2022-12-31T00:00:00.000Z', - name: 'myABTest', - variant: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], +describe('deleteABTest', () => { + test('deleteABTest', async () => { + const req = (await client.deleteABTest({ + id: 42, })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/abtests'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - endAt: '2022-12-31T00:00:00.000Z', - name: 'myABTest', - variant: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], - }); + expect(req.path).toEqual('/2/abtests/42'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ path: '/test/all', parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('deleteABTest', () => { - test('deleteABTest', async () => { - const req = (await client.deleteABTest({ +describe('stopABTest', () => { + test('stopABTest', async () => { + const req = (await client.stopABTest({ id: 42, })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/abtests/42'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/2/abtests/42/stop'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); +describe('addABTests', () => { + test('addABTests with minimal parameters', async () => { + const req = (await client.addABTests({ + endAt: '2022-12-31T00:00:00.000Z', + name: 'myABTest', + variant: [ + { index: 'AB_TEST_1', trafficPercentage: 30 }, + { index: 'AB_TEST_2', trafficPercentage: 50 }, + ], + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/2/abtests'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + endAt: '2022-12-31T00:00:00.000Z', + name: 'myABTest', + variant: [ + { index: 'AB_TEST_1', trafficPercentage: 30 }, + { index: 'AB_TEST_2', trafficPercentage: 50 }, + ], + }); + expect(req.searchParams).toEqual(undefined); + }); +}); + describe('get', () => { test('allow get method for a custom path with minimal parameters', async () => { const req = (await client.get({ @@ -97,17 +111,6 @@ describe('get', () => { }); }); -describe('getABTest', () => { - test('getABTest', async () => { - const req = (await client.getABTest({ id: 42 })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests/42'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - describe('listABTests', () => { test('listABTests with minimal parameters', async () => { const req = (await client.listABTests({ @@ -122,28 +125,27 @@ describe('listABTests', () => { }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -174,14 +176,12 @@ describe('put', () => { }); }); -describe('stopABTest', () => { - test('stopABTest', async () => { - const req = (await client.stopABTest({ - id: 42, - })) as unknown as EchoResponse; +describe('getABTest', () => { + test('getABTest', async () => { + const req = (await client.getABTest({ id: 42 })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/abtests/42/stop'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/2/abtests/42'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); diff --git a/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts index ff245af428..0602286c71 100644 --- a/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts +++ b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts @@ -69,32 +69,6 @@ describe('multipleQueries', () => { }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - describe('search', () => { test('search with minimal parameters', async () => { const req = (await client.search({ @@ -158,3 +132,29 @@ describe('searchForFacetValues', () => { expect(req.searchParams).toEqual(undefined); }); }); + +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ 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 93f2e3dacc..0996fba98f 100644 --- a/tests/output/javascript/src/methods/requests/analytics.test.ts +++ b/tests/output/javascript/src/methods/requests/analytics.test.ts @@ -9,141 +9,221 @@ const client = analyticsClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', +describe('getTopSearches', () => { + test('get getTopSearches with minimal parameters', async () => { + const req = (await client.getTopSearches({ + index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/2/searches'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toEqual({ index: 'index' }); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, + test('get getTopSearches with all parameters', async () => { + const req = (await client.getTopSearches({ + index: 'index', + clickAnalytics: true, + startDate: '1999-09-19', + endDate: '2001-01-01', + orderBy: 'searchCount', + direction: 'asc', + limit: 21, + offset: 42, + tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/2/searches'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toEqual({ + index: 'index', + clickAnalytics: 'true', + startDate: '1999-09-19', + endDate: '2001-01-01', + orderBy: 'searchCount', + direction: 'asc', + limit: '21', + offset: '42', + tags: 'tag', + }); }); }); -describe('get', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.get({ +describe('getTopHits', () => { + test('get getTopHits with minimal parameters', async () => { + const req = (await client.getTopHits({ + index: 'index', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/2/hits'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ index: 'index' }); + }); + + test('get getTopHits with all parameters', async () => { + const req = (await client.getTopHits({ + index: 'index', + search: 'mySearch', + clickAnalytics: true, + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: 21, + offset: 42, + tags: 'tag', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/2/hits'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ + index: 'index', + search: 'mySearch', + clickAnalytics: 'true', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', + tags: 'tag', + }); + }); +}); + +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('GET'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.get({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('GET'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('getAverageClickPosition', () => { - test('get getAverageClickPosition with minimal parameters', async () => { - const req = (await client.getAverageClickPosition({ +describe('getTopFiltersNoResults', () => { + test('get getTopFiltersNoResults with minimal parameters', async () => { + const req = (await client.getTopFiltersNoResults({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/averageClickPosition'); + expect(req.path).toEqual('/2/filters/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getAverageClickPosition with all parameters', async () => { - const req = (await client.getAverageClickPosition({ + test('get getTopFiltersNoResults with all parameters', async () => { + const req = (await client.getTopFiltersNoResults({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/averageClickPosition'); + expect(req.path).toEqual('/2/filters/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('getClickPositions', () => { - test('get getClickPositions with minimal parameters', async () => { - const req = (await client.getClickPositions({ +describe('getSearchesNoResults', () => { + test('get getSearchesNoResults with minimal parameters', async () => { + const req = (await client.getSearchesNoResults({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/positions'); + expect(req.path).toEqual('/2/searches/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getClickPositions with all parameters', async () => { - const req = (await client.getClickPositions({ + test('get getSearchesNoResults with all parameters', async () => { + const req = (await client.getSearchesNoResults({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/positions'); + expect(req.path).toEqual('/2/searches/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('getClickThroughRate', () => { - test('get getClickThroughRate with minimal parameters', async () => { - const req = (await client.getClickThroughRate({ +describe('getStatus', () => { + test('get getStatus with minimal parameters', async () => { + const req = (await client.getStatus({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/clickThroughRate'); + expect(req.path).toEqual('/2/status'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); +}); - test('get getClickThroughRate with all parameters', async () => { - const req = (await client.getClickThroughRate({ +describe('getClickPositions', () => { + test('get getClickPositions with minimal parameters', async () => { + const req = (await client.getClickPositions({ + index: 'index', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/2/clicks/positions'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ index: 'index' }); + }); + + test('get getClickPositions with all parameters', async () => { + const req = (await client.getClickPositions({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/clickThroughRate'); + expect(req.path).toEqual('/2/clicks/positions'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -155,123 +235,131 @@ describe('getClickThroughRate', () => { }); }); -describe('getConversationRate', () => { - test('get getConversationRate with minimal parameters', async () => { - const req = (await client.getConversationRate({ - index: 'index', +describe('put', () => { + test('allow put method for a custom path with minimal parameters', async () => { + const req = (await client.put({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/conversions/conversionRate'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toEqual(undefined); }); - test('get getConversationRate with all parameters', async () => { - const req = (await client.getConversationRate({ + test('allow put method for a custom path with all parameters', async () => { + const req = (await client.put({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + +describe('getTopFilterForAttribute', () => { + test('get getTopFilterForAttribute with minimal parameters', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute', index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/conversions/conversionRate'); + expect(req.path).toEqual('/2/filters/myAttribute'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ - index: 'index', - startDate: '1999-09-19', - endDate: '2001-01-01', - tags: 'tag', - }); + expect(req.searchParams).toEqual({ index: 'index' }); }); -}); -describe('getNoClickRate', () => { - test('get getNoClickRate with minimal parameters', async () => { - const req = (await client.getNoClickRate({ + test('get getTopFilterForAttribute with minimal parameters and multiple attributes', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute1,myAttribute2', index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClickRate'); + expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getNoClickRate with all parameters', async () => { - const req = (await client.getNoClickRate({ + test('get getTopFilterForAttribute with all parameters', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute', index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClickRate'); + expect(req.path).toEqual('/2/filters/myAttribute'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); -}); -describe('getNoResultsRate', () => { - test('get getNoResultsRate with minimal parameters', async () => { - const req = (await client.getNoResultsRate({ - index: 'index', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches/noResultRate'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); - }); - - test('get getNoResultsRate with all parameters', async () => { - const req = (await client.getNoResultsRate({ + test('get getTopFilterForAttribute with all parameters and multiple attributes', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute1,myAttribute2', index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noResultRate'); + expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('getSearchesCount', () => { - test('get getSearchesCount with minimal parameters', async () => { - const req = (await client.getSearchesCount({ +describe('getNoClickRate', () => { + test('get getNoClickRate with minimal parameters', async () => { + const req = (await client.getNoClickRate({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/count'); + expect(req.path).toEqual('/2/searches/noClickRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getSearchesCount with all parameters', async () => { - const req = (await client.getSearchesCount({ + test('get getNoClickRate with all parameters', async () => { + const req = (await client.getNoClickRate({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/count'); + expect(req.path).toEqual('/2/searches/noClickRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -283,56 +371,52 @@ describe('getSearchesCount', () => { }); }); -describe('getSearchesNoClicks', () => { - test('get getSearchesNoClicks with minimal parameters', async () => { - const req = (await client.getSearchesNoClicks({ +describe('getUsersCount', () => { + test('get getUsersCount with minimal parameters', async () => { + const req = (await client.getUsersCount({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClicks'); + expect(req.path).toEqual('/2/users/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getSearchesNoClicks with all parameters', async () => { - const req = (await client.getSearchesNoClicks({ + test('get getUsersCount with all parameters', async () => { + const req = (await client.getUsersCount({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClicks'); + expect(req.path).toEqual('/2/users/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getSearchesNoResults', () => { - test('get getSearchesNoResults with minimal parameters', async () => { - const req = (await client.getSearchesNoResults({ +describe('getSearchesNoClicks', () => { + test('get getSearchesNoClicks with minimal parameters', async () => { + const req = (await client.getSearchesNoClicks({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noResults'); + expect(req.path).toEqual('/2/searches/noClicks'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getSearchesNoResults with all parameters', async () => { - const req = (await client.getSearchesNoResults({ + test('get getSearchesNoClicks with all parameters', async () => { + const req = (await client.getSearchesNoClicks({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -341,7 +425,7 @@ describe('getSearchesNoResults', () => { tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noResults'); + expect(req.path).toEqual('/2/searches/noClicks'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -355,147 +439,135 @@ describe('getSearchesNoResults', () => { }); }); -describe('getStatus', () => { - test('get getStatus with minimal parameters', async () => { - const req = (await client.getStatus({ - index: 'index', +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/status'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('getTopCountries', () => { - test('get getTopCountries with minimal parameters', async () => { - const req = (await client.getTopCountries({ +describe('getAverageClickPosition', () => { + test('get getAverageClickPosition with minimal parameters', async () => { + const req = (await client.getAverageClickPosition({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/countries'); + expect(req.path).toEqual('/2/clicks/averageClickPosition'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopCountries with all parameters', async () => { - const req = (await client.getTopCountries({ + test('get getAverageClickPosition with all parameters', async () => { + const req = (await client.getAverageClickPosition({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/countries'); + expect(req.path).toEqual('/2/clicks/averageClickPosition'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getTopFilterAttributes', () => { - test('get getTopFilterAttributes with minimal parameters', async () => { - const req = (await client.getTopFilterAttributes({ +describe('getSearchesCount', () => { + test('get getSearchesCount with minimal parameters', async () => { + const req = (await client.getSearchesCount({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters'); + expect(req.path).toEqual('/2/searches/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopFilterAttributes with all parameters', async () => { - const req = (await client.getTopFilterAttributes({ + test('get getSearchesCount with all parameters', async () => { + const req = (await client.getSearchesCount({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters'); + expect(req.path).toEqual('/2/searches/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getTopFilterForAttribute', () => { - test('get getTopFilterForAttribute with minimal parameters', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute', - index: 'index', +describe('get', () => { + test('allow get method for a custom path with minimal parameters', async () => { + const req = (await client.get({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute'); + expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toEqual(undefined); }); - test('get getTopFilterForAttribute with minimal parameters and multiple attributes', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute1,myAttribute2', - index: 'index', + test('allow get method for a custom path with all parameters', async () => { + const req = (await client.get({ + path: '/test/all', + parameters: { query: 'parameters' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); + expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); }); +}); - test('get getTopFilterForAttribute with all parameters', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute', +describe('getTopFilterAttributes', () => { + test('get getTopFilterAttributes with minimal parameters', async () => { + const req = (await client.getTopFilterAttributes({ index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute'); + expect(req.path).toEqual('/2/filters'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ - index: 'index', - search: 'mySearch', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); + expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopFilterForAttribute with all parameters and multiple attributes', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute1,myAttribute2', + test('get getTopFilterAttributes with all parameters', async () => { + const req = (await client.getTopFilterAttributes({ index: 'index', search: 'mySearch', startDate: '1999-09-19', @@ -505,7 +577,7 @@ describe('getTopFilterForAttribute', () => { tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); + expect(req.path).toEqual('/2/filters'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -520,22 +592,21 @@ describe('getTopFilterForAttribute', () => { }); }); -describe('getTopFiltersNoResults', () => { - test('get getTopFiltersNoResults with minimal parameters', async () => { - const req = (await client.getTopFiltersNoResults({ +describe('getTopCountries', () => { + test('get getTopCountries with minimal parameters', async () => { + const req = (await client.getTopCountries({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/noResults'); + expect(req.path).toEqual('/2/countries'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopFiltersNoResults with all parameters', async () => { - const req = (await client.getTopFiltersNoResults({ + test('get getTopCountries with all parameters', async () => { + const req = (await client.getTopCountries({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', limit: 21, @@ -543,12 +614,11 @@ describe('getTopFiltersNoResults', () => { tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/noResults'); + expect(req.path).toEqual('/2/countries'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', limit: '21', @@ -558,109 +628,91 @@ describe('getTopFiltersNoResults', () => { }); }); -describe('getTopHits', () => { - test('get getTopHits with minimal parameters', async () => { - const req = (await client.getTopHits({ +describe('getConversationRate', () => { + test('get getConversationRate with minimal parameters', async () => { + const req = (await client.getConversationRate({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/hits'); + expect(req.path).toEqual('/2/conversions/conversionRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopHits with all parameters', async () => { - const req = (await client.getTopHits({ + test('get getConversationRate with all parameters', async () => { + const req = (await client.getConversationRate({ index: 'index', - search: 'mySearch', - clickAnalytics: true, startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/hits'); + expect(req.path).toEqual('/2/conversions/conversionRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', - search: 'mySearch', - clickAnalytics: 'true', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getTopSearches', () => { - test('get getTopSearches with minimal parameters', async () => { - const req = (await client.getTopSearches({ +describe('getNoResultsRate', () => { + test('get getNoResultsRate with minimal parameters', async () => { + const req = (await client.getNoResultsRate({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches'); + expect(req.path).toEqual('/2/searches/noResultRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopSearches with all parameters', async () => { - const req = (await client.getTopSearches({ + test('get getNoResultsRate with all parameters', async () => { + const req = (await client.getNoResultsRate({ index: 'index', - clickAnalytics: true, startDate: '1999-09-19', endDate: '2001-01-01', - orderBy: 'searchCount', - direction: 'asc', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches'); + expect(req.path).toEqual('/2/searches/noResultRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', - clickAnalytics: 'true', startDate: '1999-09-19', endDate: '2001-01-01', - orderBy: 'searchCount', - direction: 'asc', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getUsersCount', () => { - test('get getUsersCount with minimal parameters', async () => { - const req = (await client.getUsersCount({ +describe('getClickThroughRate', () => { + test('get getClickThroughRate with minimal parameters', async () => { + const req = (await client.getClickThroughRate({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/users/count'); + expect(req.path).toEqual('/2/clicks/clickThroughRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getUsersCount with all parameters', async () => { - const req = (await client.getUsersCount({ + test('get getClickThroughRate with all parameters', async () => { + const req = (await client.getClickThroughRate({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/users/count'); + expect(req.path).toEqual('/2/clicks/clickThroughRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -671,55 +723,3 @@ describe('getUsersCount', () => { }); }); }); - -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - -describe('put', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.put({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.put({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ 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 a2a8e57792..784994ac0c 100644 --- a/tests/output/javascript/src/methods/requests/insights.test.ts +++ b/tests/output/javascript/src/methods/requests/insights.test.ts @@ -9,27 +9,28 @@ const client = insightsClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ path: '/test/all', parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -59,32 +60,6 @@ describe('get', () => { }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - describe('pushEvents', () => { test('pushEvents', async () => { const req = (await client.pushEvents({ @@ -156,6 +131,31 @@ describe('pushEvents', () => { }); }); +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + describe('put', () => { test('allow put method for a custom path with minimal parameters', async () => { const req = (await client.put({ diff --git a/tests/output/javascript/src/methods/requests/personalization.test.ts b/tests/output/javascript/src/methods/requests/personalization.test.ts index 3f97eefec3..c48ede72b8 100644 --- a/tests/output/javascript/src/methods/requests/personalization.test.ts +++ b/tests/output/javascript/src/methods/requests/personalization.test.ts @@ -9,41 +9,42 @@ const client = personalizationClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', +describe('deleteUserProfile', () => { + test('delete deleteUserProfile', async () => { + const req = (await client.deleteUserProfile({ + userToken: 'UserToken', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); + expect(req.path).toEqual('/1/profiles/UserToken'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); +}); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toEqual(undefined); }); -}); -describe('deleteUserProfile', () => { - test('delete deleteUserProfile', async () => { - const req = (await client.deleteUserProfile({ - userToken: 'UserToken', + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/profiles/UserToken'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -84,6 +85,31 @@ describe('getPersonalizationStrategy', () => { }); }); +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + describe('getUserTokenProfile', () => { test('get getUserTokenProfile', async () => { const req = (await client.getUserTokenProfile({ @@ -97,30 +123,23 @@ describe('getUserTokenProfile', () => { }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', +describe('setPersonalizationStrategy', () => { + test('set setPersonalizationStrategy', async () => { + const req = (await client.setPersonalizationStrategy({ + eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], + facetScoring: [{ score: 42, facetName: 'Event' }], + personalizationImpact: 42, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); + expect(req.path).toEqual('/1/strategies/personalization'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); + expect(req.data).toEqual({ + eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], + facetScoring: [{ score: 42, facetName: 'Event' }], + personalizationImpact: 42, + }); expect(req.searchParams).toEqual(undefined); }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); }); describe('put', () => { @@ -148,22 +167,3 @@ describe('put', () => { expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); - -describe('setPersonalizationStrategy', () => { - test('set setPersonalizationStrategy', async () => { - const req = (await client.setPersonalizationStrategy({ - eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], - facetScoring: [{ score: 42, facetName: 'Event' }], - personalizationImpact: 42, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/strategies/personalization'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], - facetScoring: [{ score: 42, facetName: 'Event' }], - personalizationImpact: 42, - }); - expect(req.searchParams).toEqual(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..805d5d29d6 100644 --- a/tests/output/javascript/src/methods/requests/query-suggestions.test.ts +++ b/tests/output/javascript/src/methods/requests/query-suggestions.test.ts @@ -9,73 +9,75 @@ const client = querySuggestionsClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('createConfig', () => { - test('createConfig', async () => { - const req = (await client.createConfig({ +describe('deleteConfig', () => { + test('deleteConfig', async () => { + const req = (await client.deleteConfig({ indexName: 'theIndexName', - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/configs'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - indexName: 'theIndexName', - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], - }); + expect(req.path).toEqual('/1/configs/theIndexName'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ path: '/test/all', parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('deleteConfig', () => { - test('deleteConfig', async () => { - const req = (await client.deleteConfig({ +describe('updateConfig', () => { + test('updateConfig', async () => { + const req = (await client.updateConfig({ indexName: 'theIndexName', + querySuggestionsIndexParam: { + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], + }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], + }); expect(req.searchParams).toEqual(undefined); }); }); @@ -105,28 +107,62 @@ describe('get', () => { }); }); -describe('getAllConfigs', () => { - test('getAllConfigs', async () => { - const req = (await client.getAllConfigs()) as unknown as EchoResponse; +describe('createConfig', () => { + test('createConfig', async () => { + const req = (await client.createConfig({ + indexName: 'theIndexName', + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], + })) as unknown as EchoResponse; expect(req.path).toEqual('/1/configs'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + indexName: 'theIndexName', + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], + }); expect(req.searchParams).toEqual(undefined); }); }); -describe('getConfig', () => { - test('getConfig', async () => { - const req = (await client.getConfig({ - indexName: 'theIndexName', +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); + + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); }); describe('getConfigStatus', () => { @@ -142,43 +178,28 @@ describe('getConfigStatus', () => { }); }); -describe('getLogFile', () => { - test('getLogFile', async () => { - const req = (await client.getLogFile({ - indexName: 'theIndexName', - })) as unknown as EchoResponse; +describe('getAllConfigs', () => { + test('getAllConfigs', async () => { + const req = (await client.getAllConfigs()) as unknown as EchoResponse; - expect(req.path).toEqual('/1/logs/theIndexName'); + expect(req.path).toEqual('/1/configs'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', +describe('getConfig', () => { + test('getConfig', async () => { + const req = (await client.getConfig({ + indexName: 'theIndexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/configs/theIndexName'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); }); describe('put', () => { @@ -207,36 +228,15 @@ describe('put', () => { }); }); -describe('updateConfig', () => { - test('updateConfig', async () => { - const req = (await client.updateConfig({ +describe('getLogFile', () => { + test('getLogFile', async () => { + const req = (await client.getLogFile({ indexName: 'theIndexName', - querySuggestionsIndexParam: { - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], - }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], - }); + expect(req.path).toEqual('/1/logs/theIndexName'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(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..e2d87bf55c 100644 --- a/tests/output/javascript/src/methods/requests/recommend.test.ts +++ b/tests/output/javascript/src/methods/requests/recommend.test.ts @@ -7,27 +7,28 @@ const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; const client = recommendClient(appId, apiKey, { requester: echoRequester() }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ path: '/test/all', parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -57,6 +58,31 @@ describe('get', () => { }); }); +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + describe('getRecommendations', () => { test('get recommendations for recommend model with minimal parameters', async () => { const req = (await client.getRecommendations({ @@ -288,32 +314,6 @@ describe('getRecommendations', () => { }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - describe('put', () => { test('allow put method for a custom path with minimal parameters', async () => { const req = (await client.put({ diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index 4415b2938d..20b6008421 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -7,110 +7,125 @@ const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; const client = searchClient(appId, apiKey, { requester: echoRequester() }); -describe('addApiKey', () => { - test('addApiKey', async () => { - const req = (await client.addApiKey({ - acl: ['search', 'addObject'], - description: 'my new api key', - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, +describe('batchAssignUserIds', () => { + test('batchAssignUserIds', async () => { + const req = (await client.batchAssignUserIds({ + xAlgoliaUserID: 'userID', + batchAssignUserIdsParams: { + cluster: 'theCluster', + users: ['user1', 'user2'], + }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys'); + expect(req.path).toEqual('/1/clusters/mapping/batch'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - acl: ['search', 'addObject'], - description: 'my new api key', - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, + cluster: 'theCluster', + users: ['user1', 'user2'], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toEqual({ 'X-Algolia-User-ID': 'userID' }); }); }); -describe('addOrUpdateObject', () => { - test('addOrUpdateObject', async () => { - const req = (await client.addOrUpdateObject({ - indexName: 'indexName', - objectID: 'uniqueID', - body: { key: 'value' }, +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/uniqueID'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ key: 'value' }); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); + + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); }); -describe('appendSource', () => { - test('appendSource', async () => { - const req = (await client.appendSource({ - source: 'theSource', - description: 'theDescription', +describe('searchRules', () => { + test('searchRules', async () => { + const req = (await client.searchRules({ + indexName: 'indexName', + searchRulesParams: { query: 'something' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/security/sources/append'); + expect(req.path).toEqual('/1/indexes/indexName/rules/search'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - source: 'theSource', - description: 'theDescription', - }); + expect(req.data).toEqual({ query: 'something' }); expect(req.searchParams).toEqual(undefined); }); }); -describe('assignUserId', () => { - test('assignUserId', async () => { - const req = (await client.assignUserId({ - xAlgoliaUserID: 'userID', - assignUserIdParams: { cluster: 'theCluster' }, +describe('deleteIndex', () => { + test('deleteIndex', async () => { + const req = (await client.deleteIndex({ + indexName: 'theIndexName', })) as unknown as EchoResponse; - 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.path).toEqual('/1/indexes/theIndexName'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); }); }); -describe('batch', () => { - test('batch', async () => { - const req = (await client.batch({ - indexName: 'theIndexName', - batchWriteParams: { - requests: [{ action: 'delete', body: { key: 'value' } }], - }, +describe('put', () => { + test('allow put method for a custom path with minimal parameters', async () => { + const req = (await client.put({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ action: 'delete', body: { key: 'value' } }], - }); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); + + test('allow put method for a custom path with all parameters', async () => { + const req = (await client.put({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); }); -describe('batchAssignUserIds', () => { - test('batchAssignUserIds', async () => { - const req = (await client.batchAssignUserIds({ - xAlgoliaUserID: 'userID', - batchAssignUserIdsParams: { - cluster: 'theCluster', - users: ['user1', 'user2'], +describe('updateApiKey', () => { + test('updateApiKey', async () => { + const req = (await client.updateApiKey({ + key: 'myApiKey', + apiKey: { + acl: ['search', 'addObject'], + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/batch'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/keys/myApiKey'); + expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ - cluster: 'theCluster', - users: ['user1', 'user2'], + acl: ['search', 'addObject'], + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, }); - expect(req.searchParams).toEqual({ 'X-Algolia-User-ID': 'userID' }); + expect(req.searchParams).toEqual(undefined); }); }); @@ -243,179 +258,174 @@ describe('batchRules', () => { }); }); -describe('browse', () => { - test('get browse results with minimal parameters', async () => { - const req = (await client.browse({ - indexName: 'indexName', +describe('restoreApiKey', () => { + test('restoreApiKey', async () => { + const req = (await client.restoreApiKey({ + key: 'myApiKey', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/browse'); + expect(req.path).toEqual('/1/keys/myApiKey/restore'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); +}); - test('get browse results with all parameters', async () => { - const req = (await client.browse({ - indexName: 'indexName', - browseRequest: { - params: "query=foo&facetFilters=['bar']", - cursor: 'cts', - }, +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/browse'); + expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - params: "query=foo&facetFilters=['bar']", - cursor: 'cts', - }); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); -}); -describe('clearAllSynonyms', () => { - test('clearAllSynonyms', async () => { - const req = (await client.clearAllSynonyms({ - indexName: 'indexName', + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/synonyms/clear'); + expect(req.path).toEqual('/1/test/all'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('clearObjects', () => { - test('clearObjects', async () => { - const req = (await client.clearObjects({ - indexName: 'theIndexName', +describe('multipleBatch', () => { + test('multipleBatch', async () => { + const req = (await client.multipleBatch({ + requests: [ + { + action: 'addObject', + body: { key: 'value' }, + indexName: 'theIndexName', + }, + ], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/clear'); + expect(req.path).toEqual('/1/indexes/*/batch'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); + expect(req.data).toEqual({ + requests: [ + { + action: 'addObject', + body: { key: 'value' }, + indexName: 'theIndexName', + }, + ], + }); expect(req.searchParams).toEqual(undefined); }); }); -describe('clearRules', () => { - test('clearRules', async () => { - const req = (await client.clearRules({ - indexName: 'indexName', +describe('deleteObject', () => { + test('deleteObject', async () => { + const req = (await client.deleteObject({ + indexName: 'theIndexName', + objectID: 'uniqueID', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/rules/clear'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', +describe('searchUserIds', () => { + test('searchUserIds', async () => { + const req = (await client.searchUserIds({ + query: 'test', + clusterName: 'theClusterName', + page: 5, + hitsPerPage: 10, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/1/clusters/mapping/search'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + query: 'test', + clusterName: 'theClusterName', + page: 5, + hitsPerPage: 10, + }); expect(req.searchParams).toEqual(undefined); }); +}); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - -describe('deleteApiKey', () => { - test('deleteApiKey', async () => { - const req = (await client.deleteApiKey({ - key: 'myTestApiKey', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys/myTestApiKey'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('deleteBy', () => { - test('deleteBy', async () => { - const req = (await client.deleteBy({ - indexName: 'theIndexName', - searchParams: { query: 'testQuery' }, +describe('replaceSources', () => { + test('replaceSources', async () => { + const req = (await client.replaceSources({ + source: [{ source: 'theSource', description: 'theDescription' }], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/deleteByQuery'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'testQuery' }); + expect(req.path).toEqual('/1/security/sources'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual([ + { source: 'theSource', description: 'theDescription' }, + ]); expect(req.searchParams).toEqual(undefined); }); }); -describe('deleteIndex', () => { - test('deleteIndex', async () => { - const req = (await client.deleteIndex({ - indexName: 'theIndexName', +describe('removeUserId', () => { + test('removeUserId', async () => { + const req = (await client.removeUserId({ + userID: 'uniqueID', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName'); + expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('deleteObject', () => { - test('deleteObject', async () => { - const req = (await client.deleteObject({ +describe('getObject', () => { + test('getObject', async () => { + const req = (await client.getObject({ indexName: 'theIndexName', objectID: 'uniqueID', + attributesToRetrieve: ['attr1', 'attr2'], })) as unknown as EchoResponse; expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toEqual({ attributesToRetrieve: 'attr1,attr2' }); }); }); -describe('deleteRule', () => { - test('deleteRule', async () => { - const req = (await client.deleteRule({ - indexName: 'indexName', - objectID: 'id1', +describe('getApiKey', () => { + test('getApiKey', async () => { + const req = (await client.getApiKey({ + key: 'myTestApiKey', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/1/keys/myTestApiKey'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('deleteSource', () => { - test('deleteSource', async () => { - const req = (await client.deleteSource({ - source: 'theSource', +describe('assignUserId', () => { + test('assignUserId', async () => { + const req = (await client.assignUserId({ + xAlgoliaUserID: 'userID', + assignUserIdParams: { cluster: 'theCluster' }, })) as unknown as EchoResponse; - 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.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' }); }); }); @@ -433,63 +443,14 @@ describe('deleteSynonym', () => { }); }); -describe('get', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.get({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.get({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - -describe('getApiKey', () => { - test('getApiKey', async () => { - const req = (await client.getApiKey({ - key: 'myTestApiKey', +describe('searchSynonyms', () => { + test('searchSynonyms', async () => { + const req = (await client.searchSynonyms({ + indexName: 'indexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys/myTestApiKey'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('getDictionaryLanguages', () => { - test('get getDictionaryLanguages', async () => { - const req = - (await client.getDictionaryLanguages()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/*/languages'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('getDictionarySettings', () => { - test('get getDictionarySettings results', async () => { - const req = - (await client.getDictionarySettings()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/indexes/indexName/synonyms/search'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); @@ -516,81 +477,75 @@ describe('getLogs', () => { }); }); -describe('getObject', () => { - test('getObject', async () => { - const req = (await client.getObject({ +describe('batch', () => { + test('batch', async () => { + const req = (await client.batch({ indexName: 'theIndexName', - objectID: 'uniqueID', - attributesToRetrieve: ['attr1', 'attr2'], + batchWriteParams: { + requests: [{ action: 'delete', body: { key: 'value' } }], + }, })) as unknown as EchoResponse; - 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.path).toEqual('/1/indexes/theIndexName/batch'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [{ action: 'delete', body: { key: 'value' } }], + }); + expect(req.searchParams).toEqual(undefined); }); }); -describe('getObjects', () => { - test('getObjects', async () => { - const req = (await client.getObjects({ - requests: [ - { - attributesToRetrieve: ['attr1', 'attr2'], - objectID: 'uniqueID', - indexName: 'theIndexName', - }, - ], +describe('addOrUpdateObject', () => { + test('addOrUpdateObject', async () => { + const req = (await client.addOrUpdateObject({ + indexName: 'indexName', + objectID: 'uniqueID', + body: { key: 'value' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/*/objects'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - attributesToRetrieve: ['attr1', 'attr2'], - objectID: 'uniqueID', - indexName: 'theIndexName', - }, - ], - }); + expect(req.path).toEqual('/1/indexes/indexName/uniqueID'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ key: 'value' }); expect(req.searchParams).toEqual(undefined); }); }); -describe('getRule', () => { - test('getRule', async () => { - const req = (await client.getRule({ - indexName: 'indexName', - objectID: 'id1', +describe('clearObjects', () => { + test('clearObjects', async () => { + const req = (await client.clearObjects({ + indexName: 'theIndexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/indexes/theIndexName/clear'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('getSettings', () => { - test('getSettings', async () => { - const req = (await client.getSettings({ +describe('setSettings', () => { + test('setSettings', async () => { + const req = (await client.setSettings({ indexName: 'theIndexName', + indexSettings: { paginationLimitedTo: 10 }, + forwardToReplicas: true, })) as unknown as EchoResponse; 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.method).toEqual('PUT'); + expect(req.data).toEqual({ paginationLimitedTo: 10 }); + expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); }); }); -describe('getSources', () => { - test('getSources', async () => { - const req = (await client.getSources()) as unknown as EchoResponse; +describe('clearRules', () => { + test('clearRules', async () => { + const req = (await client.clearRules({ + indexName: 'indexName', + })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/security/sources'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/indexes/indexName/rules/clear'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); @@ -610,125 +565,84 @@ describe('getSynonym', () => { }); }); -describe('getTask', () => { - test('getTask', async () => { - const req = (await client.getTask({ +describe('deleteBy', () => { + test('deleteBy', async () => { + const req = (await client.deleteBy({ indexName: 'theIndexName', - taskID: 123, + searchParams: { query: 'testQuery' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/task/123'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('getTopUserIds', () => { - test('getTopUserIds', async () => { - const req = (await client.getTopUserIds()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/top'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/1/indexes/theIndexName/deleteByQuery'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ query: 'testQuery' }); expect(req.searchParams).toEqual(undefined); }); }); -describe('getUserId', () => { - test('getUserId', async () => { - const req = (await client.getUserId({ - userID: 'uniqueID', +describe('listUserIds', () => { + test('listUserIds', async () => { + const req = (await client.listUserIds({ + page: 8, + hitsPerPage: 100, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); + expect(req.path).toEqual('/1/clusters/mapping'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toEqual({ page: '8', hitsPerPage: '100' }); }); }); -describe('hasPendingMappings', () => { - test('hasPendingMappings', async () => { - const req = (await client.hasPendingMappings({ - getClusters: true, +describe('browse', () => { + test('get browse results with minimal parameters', async () => { + const req = (await client.browse({ + indexName: 'indexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/pending'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ getClusters: 'true' }); - }); -}); - -describe('listApiKeys', () => { - test('listApiKeys', async () => { - const req = (await client.listApiKeys()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/keys'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('listClusters', () => { - test('listClusters', async () => { - const req = (await client.listClusters()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/indexes/indexName/browse'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); -}); - -describe('listIndices', () => { - test('listIndices', async () => { - const req = (await client.listIndices({ - page: 8, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ page: '8' }); - }); -}); -describe('listUserIds', () => { - test('listUserIds', async () => { - const req = (await client.listUserIds({ - page: 8, - hitsPerPage: 100, + test('get browse results with all parameters', async () => { + const req = (await client.browse({ + indexName: 'indexName', + browseRequest: { + params: "query=foo&facetFilters=['bar']", + cursor: 'cts', + }, })) as unknown as EchoResponse; - 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.path).toEqual('/1/indexes/indexName/browse'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + params: "query=foo&facetFilters=['bar']", + cursor: 'cts', + }); + expect(req.searchParams).toEqual(undefined); }); }); -describe('multipleBatch', () => { - test('multipleBatch', async () => { - const req = (await client.multipleBatch({ +describe('getObjects', () => { + test('getObjects', async () => { + const req = (await client.getObjects({ requests: [ { - action: 'addObject', - body: { key: 'value' }, + attributesToRetrieve: ['attr1', 'attr2'], + objectID: 'uniqueID', indexName: 'theIndexName', }, ], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/*/batch'); + expect(req.path).toEqual('/1/indexes/*/objects'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ requests: [ { - action: 'addObject', - body: { key: 'value' }, + attributesToRetrieve: ['attr1', 'attr2'], + objectID: 'uniqueID', indexName: 'theIndexName', }, ], @@ -737,6 +651,26 @@ describe('multipleBatch', () => { }); }); +describe('partialUpdateObject', () => { + test('partialUpdateObject', async () => { + const req = (await client.partialUpdateObject({ + indexName: 'theIndexName', + objectID: 'uniqueID', + attributeOrBuiltInOperation: [ + { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, + ], + createIfNotExists: true, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual([ + { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, + ]); + expect(req.searchParams).toEqual({ createIfNotExists: 'true' }); + }); +}); + describe('multipleQueries', () => { test('multipleQueries for a single request with minimal parameters', async () => { const req = (await client.multipleQueries({ @@ -797,200 +731,136 @@ describe('multipleQueries', () => { }); }); -describe('operationIndex', () => { - test('operationIndex', async () => { - const req = (await client.operationIndex({ - indexName: 'theIndexName', - operationIndexParams: { - operation: 'copy', - destination: 'dest', - scope: ['rules', 'settings'], - }, +describe('searchForFacetValues', () => { + test('get searchForFacetValues results with minimal parameters', async () => { + const req = (await client.searchForFacetValues({ + indexName: 'indexName', + facetName: 'facetName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/operation'); + expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - operation: 'copy', - destination: 'dest', - scope: ['rules', 'settings'], - }); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); -}); -describe('partialUpdateObject', () => { - test('partialUpdateObject', async () => { - const req = (await client.partialUpdateObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributeOrBuiltInOperation: [ - { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, - ], - createIfNotExists: true, + test('get searchForFacetValues results with all parameters', async () => { + const req = (await client.searchForFacetValues({ + indexName: 'indexName', + facetName: 'facetName', + searchForFacetValuesRequest: { + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, + }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); + expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual([ - { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, - ]); - expect(req.searchParams).toEqual({ createIfNotExists: 'true' }); + expect(req.data).toEqual({ + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, + }); + expect(req.searchParams).toEqual(undefined); }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', +describe('getSettings', () => { + test('getSettings', async () => { + const req = (await client.getSettings({ + indexName: 'theIndexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/indexes/theIndexName/settings'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); +}); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, +describe('listIndices', () => { + test('listIndices', async () => { + const req = (await client.listIndices({ + page: 8, })) as unknown as EchoResponse; - 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.path).toEqual('/1/indexes'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ page: '8' }); }); }); -describe('put', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.put({ - path: '/test/minimal', - })) as unknown as EchoResponse; +describe('getDictionarySettings', () => { + test('get getDictionarySettings results', async () => { + const req = + (await client.getDictionarySettings()) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('PUT'); + expect(req.path).toEqual('/1/dictionaries/*/settings'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.put({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); }); -describe('removeUserId', () => { - test('removeUserId', async () => { - const req = (await client.removeUserId({ - userID: 'uniqueID', +describe('deleteSource', () => { + test('deleteSource', async () => { + const req = (await client.deleteSource({ + source: 'theSource', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); + expect(req.path).toEqual('/1/security/sources/theSource'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('replaceSources', () => { - test('replaceSources', async () => { - const req = (await client.replaceSources({ - source: [{ source: 'theSource', description: 'theDescription' }], - })) as unknown as EchoResponse; +describe('getSources', () => { + test('getSources', async () => { + const req = (await client.getSources()) as unknown as EchoResponse; expect(req.path).toEqual('/1/security/sources'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual([ - { source: 'theSource', description: 'theDescription' }, - ]); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('restoreApiKey', () => { - test('restoreApiKey', async () => { - const req = (await client.restoreApiKey({ - key: 'myApiKey', - })) as unknown as EchoResponse; +describe('getDictionaryLanguages', () => { + test('get getDictionaryLanguages', async () => { + const req = + (await client.getDictionaryLanguages()) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys/myApiKey/restore'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/dictionaries/*/languages'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('saveObject', () => { - test('saveObject', async () => { - const req = (await client.saveObject({ - indexName: 'theIndexName', - body: { objectID: 'id', test: 'val' }, +describe('deleteApiKey', () => { + test('deleteApiKey', async () => { + const req = (await client.deleteApiKey({ + key: 'myTestApiKey', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ objectID: 'id', test: 'val' }); + expect(req.path).toEqual('/1/keys/myTestApiKey'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('saveRule', () => { - test('saveRule', async () => { - const req = (await client.saveRule({ - indexName: 'indexName', - objectID: 'id1', - rule: { - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains' }], - consequence: { params: { filters: 'brand:apple' } }, - }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains' }], - consequence: { params: { filters: 'brand:apple' } }, - }); - expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); - }); -}); - -describe('saveSynonym', () => { - test('saveSynonym', async () => { - const req = (await client.saveSynonym({ - indexName: 'indexName', - objectID: 'id1', - synonymHit: { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }, - forwardToReplicas: true, - })) as unknown as EchoResponse; +describe('listApiKeys', () => { + test('listApiKeys', async () => { + const req = (await client.listApiKeys()) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }); - expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + expect(req.path).toEqual('/1/keys'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); }); }); @@ -1066,192 +936,295 @@ describe('search', () => { }); }); -describe('searchDictionaryEntries', () => { - test('get searchDictionaryEntries results with minimal parameters', async () => { - const req = (await client.searchDictionaryEntries({ - dictionaryName: 'compounds', - searchDictionaryEntriesParams: { query: 'foo' }, +describe('get', () => { + test('allow get method for a custom path with minimal parameters', async () => { + const req = (await client.get({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/compounds/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'foo' }); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('get searchDictionaryEntries results with all parameters', async () => { - const req = (await client.searchDictionaryEntries({ - dictionaryName: 'compounds', - searchDictionaryEntriesParams: { - query: 'foo', - page: 4, - hitsPerPage: 2, - language: 'fr', + test('allow get method for a custom path with all parameters', async () => { + const req = (await client.get({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + +describe('hasPendingMappings', () => { + test('hasPendingMappings', async () => { + const req = (await client.hasPendingMappings({ + getClusters: true, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/clusters/mapping/pending'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ getClusters: 'true' }); + }); +}); + +describe('getTopUserIds', () => { + test('getTopUserIds', async () => { + const req = (await client.getTopUserIds()) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/clusters/mapping/top'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('setDictionarySettings', () => { + test('get setDictionarySettings results with minimal parameters', async () => { + const req = (await client.setDictionarySettings({ + disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/dictionaries/*/settings'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ + disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, + }); + expect(req.searchParams).toEqual(undefined); + }); + + test('get setDictionarySettings results with all parameters', async () => { + const req = (await client.setDictionarySettings({ + disableStandardEntries: { + plurals: { fr: false, en: false, ru: true }, + stopwords: { fr: false }, + compounds: { ru: true }, }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/compounds/search'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/dictionaries/*/settings'); + expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ - query: 'foo', - page: 4, - hitsPerPage: 2, - language: 'fr', + disableStandardEntries: { + plurals: { fr: false, en: false, ru: true }, + stopwords: { fr: false }, + compounds: { ru: true }, + }, }); expect(req.searchParams).toEqual(undefined); }); }); -describe('searchForFacetValues', () => { - test('get searchForFacetValues results with minimal parameters', async () => { - const req = (await client.searchForFacetValues({ +describe('deleteRule', () => { + test('deleteRule', async () => { + const req = (await client.deleteRule({ indexName: 'indexName', - facetName: 'facetName', + objectID: 'id1', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); +}); - test('get searchForFacetValues results with all parameters', async () => { - const req = (await client.searchForFacetValues({ +describe('saveRule', () => { + test('saveRule', async () => { + const req = (await client.saveRule({ indexName: 'indexName', - facetName: 'facetName', - searchForFacetValuesRequest: { - params: "query=foo&facetFilters=['bar']", - facetQuery: 'foo', - maxFacetHits: 42, + objectID: 'id1', + rule: { + objectID: 'id1', + conditions: [{ pattern: 'apple', anchoring: 'contains' }], + consequence: { params: { filters: 'brand:apple' } }, }, + forwardToReplicas: true, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); + expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ - params: "query=foo&facetFilters=['bar']", - facetQuery: 'foo', - maxFacetHits: 42, + objectID: 'id1', + conditions: [{ pattern: 'apple', anchoring: 'contains' }], + consequence: { params: { filters: 'brand:apple' } }, }); + expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + }); +}); + +describe('saveObject', () => { + test('saveObject', async () => { + const req = (await client.saveObject({ + indexName: 'theIndexName', + body: { objectID: 'id', test: 'val' }, + })) as unknown as EchoResponse; + + 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); }); }); -describe('searchRules', () => { - test('searchRules', async () => { - const req = (await client.searchRules({ +describe('saveSynonym', () => { + test('saveSynonym', async () => { + const req = (await client.saveSynonym({ indexName: 'indexName', - searchRulesParams: { query: 'something' }, + objectID: 'id1', + synonymHit: { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + forwardToReplicas: true, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/rules/search'); + expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }); + expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + }); +}); + +describe('appendSource', () => { + test('appendSource', async () => { + const req = (await client.appendSource({ + source: 'theSource', + description: 'theDescription', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/security/sources/append'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'something' }); + expect(req.data).toEqual({ + source: 'theSource', + description: 'theDescription', + }); expect(req.searchParams).toEqual(undefined); }); }); -describe('searchSynonyms', () => { - test('searchSynonyms', async () => { - const req = (await client.searchSynonyms({ +describe('clearAllSynonyms', () => { + test('clearAllSynonyms', async () => { + const req = (await client.clearAllSynonyms({ indexName: 'indexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/synonyms/search'); + expect(req.path).toEqual('/1/indexes/indexName/synonyms/clear'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('searchUserIds', () => { - test('searchUserIds', async () => { - const req = (await client.searchUserIds({ - query: 'test', - clusterName: 'theClusterName', - page: 5, - hitsPerPage: 10, +describe('getRule', () => { + test('getRule', async () => { + const req = (await client.getRule({ + indexName: 'indexName', + objectID: 'id1', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/search'); + expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('operationIndex', () => { + test('operationIndex', async () => { + const req = (await client.operationIndex({ + indexName: 'theIndexName', + operationIndexParams: { + operation: 'copy', + destination: 'dest', + scope: ['rules', 'settings'], + }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/theIndexName/operation'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - query: 'test', - clusterName: 'theClusterName', - page: 5, - hitsPerPage: 10, + operation: 'copy', + destination: 'dest', + scope: ['rules', 'settings'], }); expect(req.searchParams).toEqual(undefined); }); }); -describe('setDictionarySettings', () => { - test('get setDictionarySettings results with minimal parameters', async () => { - const req = (await client.setDictionarySettings({ - disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, +describe('searchDictionaryEntries', () => { + test('get searchDictionaryEntries results with minimal parameters', async () => { + const req = (await client.searchDictionaryEntries({ + dictionaryName: 'compounds', + searchDictionaryEntriesParams: { query: 'foo' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, - }); + expect(req.path).toEqual('/1/dictionaries/compounds/search'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ query: 'foo' }); expect(req.searchParams).toEqual(undefined); }); - test('get setDictionarySettings results with all parameters', async () => { - const req = (await client.setDictionarySettings({ - disableStandardEntries: { - plurals: { fr: false, en: false, ru: true }, - stopwords: { fr: false }, - compounds: { ru: true }, + test('get searchDictionaryEntries results with all parameters', async () => { + const req = (await client.searchDictionaryEntries({ + dictionaryName: 'compounds', + searchDictionaryEntriesParams: { + query: 'foo', + page: 4, + hitsPerPage: 2, + language: 'fr', }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('PUT'); + expect(req.path).toEqual('/1/dictionaries/compounds/search'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - disableStandardEntries: { - plurals: { fr: false, en: false, ru: true }, - stopwords: { fr: false }, - compounds: { ru: true }, - }, + query: 'foo', + page: 4, + hitsPerPage: 2, + language: 'fr', }); expect(req.searchParams).toEqual(undefined); }); }); -describe('setSettings', () => { - test('setSettings', async () => { - const req = (await client.setSettings({ - indexName: 'theIndexName', - indexSettings: { paginationLimitedTo: 10 }, - forwardToReplicas: true, - })) as unknown as EchoResponse; +describe('listClusters', () => { + test('listClusters', async () => { + const req = (await client.listClusters()) as unknown as EchoResponse; - 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.path).toEqual('/1/clusters'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); }); }); -describe('updateApiKey', () => { - test('updateApiKey', async () => { - const req = (await client.updateApiKey({ - key: 'myApiKey', - apiKey: { - acl: ['search', 'addObject'], - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, - }, +describe('addApiKey', () => { + test('addApiKey', async () => { + const req = (await client.addApiKey({ + acl: ['search', 'addObject'], + description: 'my new api key', + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys/myApiKey'); - expect(req.method).toEqual('PUT'); + expect(req.path).toEqual('/1/keys'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual({ acl: ['search', 'addObject'], + description: 'my new api key', validity: 300, maxQueriesPerIPPerHour: 100, maxHitsPerQuery: 20, @@ -1259,3 +1232,30 @@ describe('updateApiKey', () => { expect(req.searchParams).toEqual(undefined); }); }); + +describe('getTask', () => { + test('getTask', async () => { + const req = (await client.getTask({ + indexName: 'theIndexName', + taskID: 123, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/theIndexName/task/123'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('getUserId', () => { + test('getUserId', async () => { + const req = (await client.getUserId({ + userID: 'uniqueID', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(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..1a3b852e22 100644 --- a/tests/output/javascript/src/methods/requests/sources.test.ts +++ b/tests/output/javascript/src/methods/requests/sources.test.ts @@ -9,27 +9,28 @@ const client = sourcesClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ path: '/test/all', parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -59,28 +60,27 @@ describe('get', () => { }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); From 6924ca0a4a616b693799e38134002a9785a2e698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 27 Apr 2022 12:24:57 +0200 Subject: [PATCH 3/6] regen all --- .../codegen/cts/AlgoliaCtsGenerator.java | 2 +- .../src/methods/requests/AbtestingTest.php | 146 +- .../src/methods/requests/AnalyticsTest.php | 690 ++++----- .../php/src/methods/requests/InsightsTest.php | 106 +- .../methods/requests/PersonalizationTest.php | 158 +- .../methods/requests/QuerySuggestionsTest.php | 214 +-- .../src/methods/requests/RecommendTest.php | 106 +- .../php/src/methods/requests/SearchTest.php | 1367 +++++++++-------- 8 files changed, 1412 insertions(+), 1377 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 d38c7a02fc..3f60a1fcda 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -246,7 +246,7 @@ private HashMap buildOperations( result.put(ope.operationId, ope); } } - return result.keySet().stream().sorted().collect(Collectors.toList()); + return result; } private String createImportName() { diff --git a/tests/output/php/src/methods/requests/AbtestingTest.php b/tests/output/php/src/methods/requests/AbtestingTest.php index 255937ad9b..e5a517cd27 100644 --- a/tests/output/php/src/methods/requests/AbtestingTest.php +++ b/tests/output/php/src/methods/requests/AbtestingTest.php @@ -77,90 +77,110 @@ protected function getClient() } /** - * Test case for AddABTests - * addABTests with minimal parameters + * Test case for DeleteABTest + * deleteABTest */ - public function testAddABTests0() + public function testDeleteABTest0() { $client = $this->getClient(); - $client->addABTests([ - 'endAt' => '2022-12-31T00:00:00.000Z', - - 'name' => 'myABTest', - - 'variant' => [ - ['index' => 'AB_TEST_1', 'trafficPercentage' => 30], - - ['index' => 'AB_TEST_2', 'trafficPercentage' => 50], - ], - ]); + $client->deleteABTest(42); $this->assertRequests([ [ - 'path' => '/2/abtests', - 'method' => 'POST', - 'body' => json_decode( - "{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}" - ), + 'path' => '/2/abtests/42', + 'method' => 'DELETE', ], ]); } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testDel0() + public function testPost0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->post('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'method' => 'POST', ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testDel1() + public function testPost1() { $client = $this->getClient(); - $client->del( + $client->post( '/test/all', - ['query' => 'parameters'] + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'DELETE', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for DeleteABTest - * deleteABTest + * Test case for StopABTest + * stopABTest */ - public function testDeleteABTest0() + public function testStopABTest0() { $client = $this->getClient(); - $client->deleteABTest(42); + $client->stopABTest(42); $this->assertRequests([ [ - 'path' => '/2/abtests/42', - 'method' => 'DELETE', + 'path' => '/2/abtests/42/stop', + 'method' => 'POST', + ], + ]); + } + + /** + * Test case for AddABTests + * addABTests with minimal parameters + */ + public function testAddABTests0() + { + $client = $this->getClient(); + + $client->addABTests([ + 'endAt' => '2022-12-31T00:00:00.000Z', + + 'name' => 'myABTest', + + 'variant' => [ + ['index' => 'AB_TEST_1', 'trafficPercentage' => 30], + + ['index' => 'AB_TEST_2', 'trafficPercentage' => 50], + ], + ]); + + $this->assertRequests([ + [ + 'path' => '/2/abtests', + 'method' => 'POST', + 'body' => json_decode( + "{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}" + ), ], ]); } @@ -205,24 +225,6 @@ public function testGet1() ]); } - /** - * Test case for GetABTest - * getABTest - */ - public function testGetABTest0() - { - $client = $this->getClient(); - - $client->getABTest(42); - - $this->assertRequests([ - [ - 'path' => '/2/abtests/42', - 'method' => 'GET', - ], - ]); - } - /** * Test case for ListABTests * listABTests with minimal parameters @@ -248,42 +250,40 @@ public function testListABTests0() } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testPost0() + public function testDel0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->del('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'POST', + 'method' => 'DELETE', ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testPost1() + public function testDel1() { $client = $this->getClient(); - $client->post( + $client->del( '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + ['query' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), + 'method' => 'DELETE', 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); @@ -332,19 +332,19 @@ public function testPut1() } /** - * Test case for StopABTest - * stopABTest + * Test case for GetABTest + * getABTest */ - public function testStopABTest0() + public function testGetABTest0() { $client = $this->getClient(); - $client->stopABTest(42); + $client->getABTest(42); $this->assertRequests([ [ - 'path' => '/2/abtests/42/stop', - 'method' => 'POST', + 'path' => '/2/abtests/42', + 'method' => 'GET', ], ]); } diff --git a/tests/output/php/src/methods/requests/AnalyticsTest.php b/tests/output/php/src/methods/requests/AnalyticsTest.php index a64a4ff459..f6bb2c51cf 100644 --- a/tests/output/php/src/methods/requests/AnalyticsTest.php +++ b/tests/output/php/src/methods/requests/AnalyticsTest.php @@ -77,143 +77,157 @@ protected function getClient() } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for GetTopSearches + * get getTopSearches with minimal parameters */ - public function testDel0() + public function testGetTopSearches0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->getTopSearches('index'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'path' => '/2/searches', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for GetTopSearches + * get getTopSearches with all parameters */ - public function testDel1() + public function testGetTopSearches1() { $client = $this->getClient(); - $client->del( - '/test/all', - ['query' => 'parameters'] + $client->getTopSearches( + 'index', + true, + '1999-09-19', + '2001-01-01', + 'searchCount', + 'asc', + 21, + 42, + 'tag' ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/2/searches', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for Get - * allow get method for a custom path with minimal parameters + * Test case for GetTopHits + * get getTopHits with minimal parameters */ - public function testGet0() + public function testGetTopHits0() { $client = $this->getClient(); - $client->get('/test/minimal'); + $client->getTopHits('index'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', + 'path' => '/2/hits', 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for Get - * allow get method for a custom path with all parameters + * Test case for GetTopHits + * get getTopHits with all parameters */ - public function testGet1() + public function testGetTopHits1() { $client = $this->getClient(); - $client->get( - '/test/all', - ['query' => 'parameters'] + $client->getTopHits( + 'index', + 'mySearch', + true, + '1999-09-19', + '2001-01-01', + 21, + 42, + 'tag' ); $this->assertRequests([ [ - 'path' => '/1/test/all', + 'path' => '/2/hits', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'searchParams' => json_decode( + "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for GetAverageClickPosition - * get getAverageClickPosition with minimal parameters + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testGetAverageClickPosition0() + public function testDel0() { $client = $this->getClient(); - $client->getAverageClickPosition('index'); + $client->del('/test/minimal'); $this->assertRequests([ [ - 'path' => '/2/clicks/averageClickPosition', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'path' => '/1/test/minimal', + 'method' => 'DELETE', ], ]); } /** - * Test case for GetAverageClickPosition - * get getAverageClickPosition with all parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testGetAverageClickPosition1() + public function testDel1() { $client = $this->getClient(); - $client->getAverageClickPosition( - 'index', - '1999-09-19', - '2001-01-01', - 'tag' + $client->del( + '/test/all', + ['query' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/clicks/averageClickPosition', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" - ), + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for GetClickPositions - * get getClickPositions with minimal parameters + * Test case for GetTopFiltersNoResults + * get getTopFiltersNoResults with minimal parameters */ - public function testGetClickPositions0() + public function testGetTopFiltersNoResults0() { $client = $this->getClient(); - $client->getClickPositions('index'); + $client->getTopFiltersNoResults('index'); $this->assertRequests([ [ - 'path' => '/2/clicks/positions', + 'path' => '/2/filters/noResults', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -221,44 +235,47 @@ public function testGetClickPositions0() } /** - * Test case for GetClickPositions - * get getClickPositions with all parameters + * Test case for GetTopFiltersNoResults + * get getTopFiltersNoResults with all parameters */ - public function testGetClickPositions1() + public function testGetTopFiltersNoResults1() { $client = $this->getClient(); - $client->getClickPositions( + $client->getTopFiltersNoResults( 'index', + 'mySearch', '1999-09-19', '2001-01-01', + 21, + 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/clicks/positions', + 'path' => '/2/filters/noResults', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetClickThroughRate - * get getClickThroughRate with minimal parameters + * Test case for GetSearchesNoResults + * get getSearchesNoResults with minimal parameters */ - public function testGetClickThroughRate0() + public function testGetSearchesNoResults0() { $client = $this->getClient(); - $client->getClickThroughRate('index'); + $client->getSearchesNoResults('index'); $this->assertRequests([ [ - 'path' => '/2/clicks/clickThroughRate', + 'path' => '/2/searches/noResults', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -266,44 +283,46 @@ public function testGetClickThroughRate0() } /** - * Test case for GetClickThroughRate - * get getClickThroughRate with all parameters + * Test case for GetSearchesNoResults + * get getSearchesNoResults with all parameters */ - public function testGetClickThroughRate1() + public function testGetSearchesNoResults1() { $client = $this->getClient(); - $client->getClickThroughRate( + $client->getSearchesNoResults( 'index', '1999-09-19', '2001-01-01', + 21, + 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/clicks/clickThroughRate', + 'path' => '/2/searches/noResults', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetConversationRate - * get getConversationRate with minimal parameters + * Test case for GetStatus + * get getStatus with minimal parameters */ - public function testGetConversationRate0() + public function testGetStatus0() { $client = $this->getClient(); - $client->getConversationRate('index'); + $client->getStatus('index'); $this->assertRequests([ [ - 'path' => '/2/conversions/conversionRate', + 'path' => '/2/status', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -311,44 +330,18 @@ public function testGetConversationRate0() } /** - * Test case for GetConversationRate - * get getConversationRate with all parameters - */ - public function testGetConversationRate1() - { - $client = $this->getClient(); - - $client->getConversationRate( - 'index', - '1999-09-19', - '2001-01-01', - 'tag' - ); - - $this->assertRequests([ - [ - 'path' => '/2/conversions/conversionRate', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" - ), - ], - ]); - } - - /** - * Test case for GetNoClickRate - * get getNoClickRate with minimal parameters + * Test case for GetClickPositions + * get getClickPositions with minimal parameters */ - public function testGetNoClickRate0() + public function testGetClickPositions0() { $client = $this->getClient(); - $client->getNoClickRate('index'); + $client->getClickPositions('index'); $this->assertRequests([ [ - 'path' => '/2/searches/noClickRate', + 'path' => '/2/clicks/positions', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -356,14 +349,14 @@ public function testGetNoClickRate0() } /** - * Test case for GetNoClickRate - * get getNoClickRate with all parameters + * Test case for GetClickPositions + * get getClickPositions with all parameters */ - public function testGetNoClickRate1() + public function testGetClickPositions1() { $client = $this->getClient(); - $client->getNoClickRate( + $client->getClickPositions( 'index', '1999-09-19', '2001-01-01', @@ -372,7 +365,7 @@ public function testGetNoClickRate1() $this->assertRequests([ [ - 'path' => '/2/searches/noClickRate', + 'path' => '/2/clicks/positions', 'method' => 'GET', 'searchParams' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" @@ -382,63 +375,63 @@ public function testGetNoClickRate1() } /** - * Test case for GetNoResultsRate - * get getNoResultsRate with minimal parameters + * Test case for Put + * allow put method for a custom path with minimal parameters */ - public function testGetNoResultsRate0() + public function testPut0() { $client = $this->getClient(); - $client->getNoResultsRate('index'); + $client->put('/test/minimal'); $this->assertRequests([ [ - 'path' => '/2/searches/noResultRate', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'path' => '/1/test/minimal', + 'method' => 'PUT', ], ]); } /** - * Test case for GetNoResultsRate - * get getNoResultsRate with all parameters + * Test case for Put + * allow put method for a custom path with all parameters */ - public function testGetNoResultsRate1() + public function testPut1() { $client = $this->getClient(); - $client->getNoResultsRate( - 'index', - '1999-09-19', - '2001-01-01', - 'tag' + $client->put( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/searches/noResultRate', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" - ), + 'path' => '/1/test/all', + 'method' => 'PUT', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for GetSearchesCount - * get getSearchesCount with minimal parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with minimal parameters */ - public function testGetSearchesCount0() + public function testGetTopFilterForAttribute0() { $client = $this->getClient(); - $client->getSearchesCount('index'); + $client->getTopFilterForAttribute( + 'myAttribute', + 'index' + ); $this->assertRequests([ [ - 'path' => '/2/searches/count', + 'path' => '/2/filters/myAttribute', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -446,60 +439,69 @@ public function testGetSearchesCount0() } /** - * Test case for GetSearchesCount - * get getSearchesCount with all parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with minimal parameters and multiple attributes */ - public function testGetSearchesCount1() + public function testGetTopFilterForAttribute1() { $client = $this->getClient(); - $client->getSearchesCount( - 'index', - '1999-09-19', - '2001-01-01', - 'tag' + $client->getTopFilterForAttribute( + 'myAttribute1,myAttribute2', + 'index' ); $this->assertRequests([ [ - 'path' => '/2/searches/count', + 'path' => '/2/filters/myAttribute1%2CmyAttribute2', 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" - ), + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for GetSearchesNoClicks - * get getSearchesNoClicks with minimal parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with all parameters */ - public function testGetSearchesNoClicks0() + public function testGetTopFilterForAttribute2() { $client = $this->getClient(); - $client->getSearchesNoClicks('index'); + $client->getTopFilterForAttribute( + 'myAttribute', + 'index', + 'mySearch', + '1999-09-19', + '2001-01-01', + 21, + 42, + 'tag' + ); $this->assertRequests([ [ - 'path' => '/2/searches/noClicks', + 'path' => '/2/filters/myAttribute', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'searchParams' => json_decode( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for GetSearchesNoClicks - * get getSearchesNoClicks with all parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with all parameters and multiple attributes */ - public function testGetSearchesNoClicks1() + public function testGetTopFilterForAttribute3() { $client = $this->getClient(); - $client->getSearchesNoClicks( + $client->getTopFilterForAttribute( + 'myAttribute1,myAttribute2', 'index', + 'mySearch', '1999-09-19', '2001-01-01', 21, @@ -509,28 +511,28 @@ public function testGetSearchesNoClicks1() $this->assertRequests([ [ - 'path' => '/2/searches/noClicks', + 'path' => '/2/filters/myAttribute1%2CmyAttribute2', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetSearchesNoResults - * get getSearchesNoResults with minimal parameters + * Test case for GetNoClickRate + * get getNoClickRate with minimal parameters */ - public function testGetSearchesNoResults0() + public function testGetNoClickRate0() { $client = $this->getClient(); - $client->getSearchesNoResults('index'); + $client->getNoClickRate('index'); $this->assertRequests([ [ - 'path' => '/2/searches/noResults', + 'path' => '/2/searches/noClickRate', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -538,65 +540,44 @@ public function testGetSearchesNoResults0() } /** - * Test case for GetSearchesNoResults - * get getSearchesNoResults with all parameters + * Test case for GetNoClickRate + * get getNoClickRate with all parameters */ - public function testGetSearchesNoResults1() + public function testGetNoClickRate1() { $client = $this->getClient(); - $client->getSearchesNoResults( + $client->getNoClickRate( 'index', '1999-09-19', '2001-01-01', - 21, - 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/searches/noResults', + 'path' => '/2/searches/noClickRate', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetStatus - * get getStatus with minimal parameters - */ - public function testGetStatus0() - { - $client = $this->getClient(); - - $client->getStatus('index'); - - $this->assertRequests([ - [ - 'path' => '/2/status', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), - ], - ]); - } - - /** - * Test case for GetTopCountries - * get getTopCountries with minimal parameters + * Test case for GetUsersCount + * get getUsersCount with minimal parameters */ - public function testGetTopCountries0() + public function testGetUsersCount0() { $client = $this->getClient(); - $client->getTopCountries('index'); + $client->getUsersCount('index'); $this->assertRequests([ [ - 'path' => '/2/countries', + 'path' => '/2/users/count', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -604,46 +585,44 @@ public function testGetTopCountries0() } /** - * Test case for GetTopCountries - * get getTopCountries with all parameters + * Test case for GetUsersCount + * get getUsersCount with all parameters */ - public function testGetTopCountries1() + public function testGetUsersCount1() { $client = $this->getClient(); - $client->getTopCountries( + $client->getUsersCount( 'index', '1999-09-19', '2001-01-01', - 21, - 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/countries', + 'path' => '/2/users/count', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetTopFilterAttributes - * get getTopFilterAttributes with minimal parameters + * Test case for GetSearchesNoClicks + * get getSearchesNoClicks with minimal parameters */ - public function testGetTopFilterAttributes0() + public function testGetSearchesNoClicks0() { $client = $this->getClient(); - $client->getTopFilterAttributes('index'); + $client->getSearchesNoClicks('index'); $this->assertRequests([ [ - 'path' => '/2/filters', + 'path' => '/2/searches/noClicks', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -651,16 +630,15 @@ public function testGetTopFilterAttributes0() } /** - * Test case for GetTopFilterAttributes - * get getTopFilterAttributes with all parameters + * Test case for GetSearchesNoClicks + * get getSearchesNoClicks with all parameters */ - public function testGetTopFilterAttributes1() + public function testGetSearchesNoClicks1() { $client = $this->getClient(); - $client->getTopFilterAttributes( + $client->getSearchesNoClicks( 'index', - 'mySearch', '1999-09-19', '2001-01-01', 21, @@ -670,53 +648,70 @@ public function testGetTopFilterAttributes1() $this->assertRequests([ [ - 'path' => '/2/filters', + 'path' => '/2/searches/noClicks', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters + */ + public function testPost0() + { + $client = $this->getClient(); + + $client->post('/test/minimal'); + + $this->assertRequests([ + [ + 'path' => '/1/test/minimal', + 'method' => 'POST', + ], + ]); + } + + /** + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testGetTopFilterForAttribute0() + public function testPost1() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute', - 'index' + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'path' => '/1/test/all', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with minimal parameters and multiple attributes + * Test case for GetAverageClickPosition + * get getAverageClickPosition with minimal parameters */ - public function testGetTopFilterForAttribute1() + public function testGetAverageClickPosition0() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute1,myAttribute2', - 'index' - ); + $client->getAverageClickPosition('index'); $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute1%2CmyAttribute2', + 'path' => '/2/clicks/averageClickPosition', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -724,126 +719,129 @@ public function testGetTopFilterForAttribute1() } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with all parameters + * Test case for GetAverageClickPosition + * get getAverageClickPosition with all parameters */ - public function testGetTopFilterForAttribute2() + public function testGetAverageClickPosition1() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute', + $client->getAverageClickPosition( 'index', - 'mySearch', '1999-09-19', '2001-01-01', - 21, - 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute', + 'path' => '/2/clicks/averageClickPosition', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with all parameters and multiple attributes + * Test case for GetSearchesCount + * get getSearchesCount with minimal parameters */ - public function testGetTopFilterForAttribute3() + public function testGetSearchesCount0() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute1,myAttribute2', + $client->getSearchesCount('index'); + + $this->assertRequests([ + [ + 'path' => '/2/searches/count', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), + ], + ]); + } + + /** + * Test case for GetSearchesCount + * get getSearchesCount with all parameters + */ + public function testGetSearchesCount1() + { + $client = $this->getClient(); + + $client->getSearchesCount( 'index', - 'mySearch', '1999-09-19', '2001-01-01', - 21, - 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute1%2CmyAttribute2', + 'path' => '/2/searches/count', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetTopFiltersNoResults - * get getTopFiltersNoResults with minimal parameters + * Test case for Get + * allow get method for a custom path with minimal parameters */ - public function testGetTopFiltersNoResults0() + public function testGet0() { $client = $this->getClient(); - $client->getTopFiltersNoResults('index'); + $client->get('/test/minimal'); $this->assertRequests([ [ - 'path' => '/2/filters/noResults', + 'path' => '/1/test/minimal', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for GetTopFiltersNoResults - * get getTopFiltersNoResults with all parameters + * Test case for Get + * allow get method for a custom path with all parameters */ - public function testGetTopFiltersNoResults1() + public function testGet1() { $client = $this->getClient(); - $client->getTopFiltersNoResults( - 'index', - 'mySearch', - '1999-09-19', - '2001-01-01', - 21, - 42, - 'tag' + $client->get( + '/test/all', + ['query' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/filters/noResults', + 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" - ), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for GetTopHits - * get getTopHits with minimal parameters + * Test case for GetTopFilterAttributes + * get getTopFilterAttributes with minimal parameters */ - public function testGetTopHits0() + public function testGetTopFilterAttributes0() { $client = $this->getClient(); - $client->getTopHits('index'); + $client->getTopFilterAttributes('index'); $this->assertRequests([ [ - 'path' => '/2/hits', + 'path' => '/2/filters', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -851,17 +849,16 @@ public function testGetTopHits0() } /** - * Test case for GetTopHits - * get getTopHits with all parameters + * Test case for GetTopFilterAttributes + * get getTopFilterAttributes with all parameters */ - public function testGetTopHits1() + public function testGetTopFilterAttributes1() { $client = $this->getClient(); - $client->getTopHits( + $client->getTopFilterAttributes( 'index', 'mySearch', - true, '1999-09-19', '2001-01-01', 21, @@ -871,28 +868,28 @@ public function testGetTopHits1() $this->assertRequests([ [ - 'path' => '/2/hits', + 'path' => '/2/filters', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetTopSearches - * get getTopSearches with minimal parameters + * Test case for GetTopCountries + * get getTopCountries with minimal parameters */ - public function testGetTopSearches0() + public function testGetTopCountries0() { $client = $this->getClient(); - $client->getTopSearches('index'); + $client->getTopCountries('index'); $this->assertRequests([ [ - 'path' => '/2/searches', + 'path' => '/2/countries', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -900,20 +897,17 @@ public function testGetTopSearches0() } /** - * Test case for GetTopSearches - * get getTopSearches with all parameters + * Test case for GetTopCountries + * get getTopCountries with all parameters */ - public function testGetTopSearches1() + public function testGetTopCountries1() { $client = $this->getClient(); - $client->getTopSearches( + $client->getTopCountries( 'index', - true, '1999-09-19', '2001-01-01', - 'searchCount', - 'asc', 21, 42, 'tag' @@ -921,28 +915,28 @@ public function testGetTopSearches1() $this->assertRequests([ [ - 'path' => '/2/searches', + 'path' => '/2/countries', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetUsersCount - * get getUsersCount with minimal parameters + * Test case for GetConversationRate + * get getConversationRate with minimal parameters */ - public function testGetUsersCount0() + public function testGetConversationRate0() { $client = $this->getClient(); - $client->getUsersCount('index'); + $client->getConversationRate('index'); $this->assertRequests([ [ - 'path' => '/2/users/count', + 'path' => '/2/conversions/conversionRate', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -950,14 +944,14 @@ public function testGetUsersCount0() } /** - * Test case for GetUsersCount - * get getUsersCount with all parameters + * Test case for GetConversationRate + * get getConversationRate with all parameters */ - public function testGetUsersCount1() + public function testGetConversationRate1() { $client = $this->getClient(); - $client->getUsersCount( + $client->getConversationRate( 'index', '1999-09-19', '2001-01-01', @@ -966,7 +960,7 @@ public function testGetUsersCount1() $this->assertRequests([ [ - 'path' => '/2/users/count', + 'path' => '/2/conversions/conversionRate', 'method' => 'GET', 'searchParams' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" @@ -976,85 +970,91 @@ public function testGetUsersCount1() } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for GetNoResultsRate + * get getNoResultsRate with minimal parameters */ - public function testPost0() + public function testGetNoResultsRate0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->getNoResultsRate('index'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'POST', + 'path' => '/2/searches/noResultRate', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for GetNoResultsRate + * get getNoResultsRate with all parameters */ - public function testPost1() + public function testGetNoResultsRate1() { $client = $this->getClient(); - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + $client->getNoResultsRate( + 'index', + '1999-09-19', + '2001-01-01', + 'tag' ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/2/searches/noResultRate', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for Put - * allow put method for a custom path with minimal parameters + * Test case for GetClickThroughRate + * get getClickThroughRate with minimal parameters */ - public function testPut0() + public function testGetClickThroughRate0() { $client = $this->getClient(); - $client->put('/test/minimal'); + $client->getClickThroughRate('index'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'PUT', + 'path' => '/2/clicks/clickThroughRate', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for Put - * allow put method for a custom path with all parameters + * Test case for GetClickThroughRate + * get getClickThroughRate with all parameters */ - public function testPut1() + public function testGetClickThroughRate1() { $client = $this->getClient(); - $client->put( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + $client->getClickThroughRate( + 'index', + '1999-09-19', + '2001-01-01', + 'tag' ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'PUT', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/2/clicks/clickThroughRate', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + ), ], ]); } diff --git a/tests/output/php/src/methods/requests/InsightsTest.php b/tests/output/php/src/methods/requests/InsightsTest.php index 3c091e364d..c65d851e8e 100644 --- a/tests/output/php/src/methods/requests/InsightsTest.php +++ b/tests/output/php/src/methods/requests/InsightsTest.php @@ -77,40 +77,42 @@ protected function getClient() } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testDel0() + public function testPost0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->post('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'method' => 'POST', ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testDel1() + public function testPost1() { $client = $this->getClient(); - $client->del( + $client->post( '/test/all', - ['query' => 'parameters'] + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'DELETE', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); @@ -156,48 +158,6 @@ public function testGet1() ]); } - /** - * Test case for Post - * allow post method for a custom path with minimal parameters - */ - public function testPost0() - { - $client = $this->getClient(); - - $client->post('/test/minimal'); - - $this->assertRequests([ - [ - 'path' => '/1/test/minimal', - 'method' => 'POST', - ], - ]); - } - - /** - * Test case for Post - * allow post method for a custom path with all parameters - */ - public function testPost1() - { - $client = $this->getClient(); - - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), - ], - ]); - } - /** * Test case for PushEvents * pushEvents @@ -269,6 +229,46 @@ public function testPushEvents0() ]); } + /** + * Test case for Del + * allow del method for a custom path with minimal parameters + */ + public function testDel0() + { + $client = $this->getClient(); + + $client->del('/test/minimal'); + + $this->assertRequests([ + [ + 'path' => '/1/test/minimal', + 'method' => 'DELETE', + ], + ]); + } + + /** + * Test case for Del + * allow del method for a custom path with all parameters + */ + public function testDel1() + { + $client = $this->getClient(); + + $client->del( + '/test/all', + ['query' => 'parameters'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + ], + ]); + } + /** * Test case for Put * allow put method for a custom path with minimal parameters diff --git a/tests/output/php/src/methods/requests/PersonalizationTest.php b/tests/output/php/src/methods/requests/PersonalizationTest.php index 01795adbdc..c0f2b34acf 100644 --- a/tests/output/php/src/methods/requests/PersonalizationTest.php +++ b/tests/output/php/src/methods/requests/PersonalizationTest.php @@ -77,59 +77,61 @@ protected function getClient() } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for DeleteUserProfile + * delete deleteUserProfile */ - public function testDel0() + public function testDeleteUserProfile0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->deleteUserProfile('UserToken'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', + 'path' => '/1/profiles/UserToken', 'method' => 'DELETE', ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testDel1() + public function testPost0() { $client = $this->getClient(); - $client->del( - '/test/all', - ['query' => 'parameters'] - ); + $client->post('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/test/minimal', + 'method' => 'POST', ], ]); } /** - * Test case for DeleteUserProfile - * delete deleteUserProfile + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testDeleteUserProfile0() + public function testPost1() { $client = $this->getClient(); - $client->deleteUserProfile('UserToken'); + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/profiles/UserToken', - 'method' => 'DELETE', + 'path' => '/1/test/all', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -193,61 +195,94 @@ public function testGetPersonalizationStrategy0() } /** - * Test case for GetUserTokenProfile - * get getUserTokenProfile + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testGetUserTokenProfile0() + public function testDel0() { $client = $this->getClient(); - $client->getUserTokenProfile('UserToken'); + $client->del('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/profiles/personalization/UserToken', - 'method' => 'GET', + 'path' => '/1/test/minimal', + 'method' => 'DELETE', ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testPost0() + public function testDel1() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->del( + '/test/all', + ['query' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'POST', + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for GetUserTokenProfile + * get getUserTokenProfile */ - public function testPost1() + public function testGetUserTokenProfile0() { $client = $this->getClient(); - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] - ); + $client->getUserTokenProfile('UserToken'); $this->assertRequests([ [ - 'path' => '/1/test/all', + 'path' => '/1/profiles/personalization/UserToken', + 'method' => 'GET', + ], + ]); + } + + /** + * Test case for SetPersonalizationStrategy + * set setPersonalizationStrategy + */ + public function testSetPersonalizationStrategy0() + { + $client = $this->getClient(); + + $client->setPersonalizationStrategy([ + 'eventScoring' => [ + [ + 'score' => 42, + + 'eventName' => 'Algolia', + + 'eventType' => 'Event', + ], + ], + + 'facetScoring' => [['score' => 42, 'facetName' => 'Event']], + + 'personalizationImpact' => 42, + ]); + + $this->assertRequests([ + [ + 'path' => '/1/strategies/personalization', 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'body' => json_decode( + "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}" + ), ], ]); } @@ -293,39 +328,4 @@ public function testPut1() ], ]); } - - /** - * Test case for SetPersonalizationStrategy - * set setPersonalizationStrategy - */ - public function testSetPersonalizationStrategy0() - { - $client = $this->getClient(); - - $client->setPersonalizationStrategy([ - 'eventScoring' => [ - [ - 'score' => 42, - - 'eventName' => 'Algolia', - - 'eventType' => 'Event', - ], - ], - - 'facetScoring' => [['score' => 42, 'facetName' => 'Event']], - - 'personalizationImpact' => 42, - ]); - - $this->assertRequests([ - [ - 'path' => '/1/strategies/personalization', - 'method' => 'POST', - 'body' => json_decode( - "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}" - ), - ], - ]); - } } diff --git a/tests/output/php/src/methods/requests/QuerySuggestionsTest.php b/tests/output/php/src/methods/requests/QuerySuggestionsTest.php index 16d7d2ed13..0e0a1e685b 100644 --- a/tests/output/php/src/methods/requests/QuerySuggestionsTest.php +++ b/tests/output/php/src/methods/requests/QuerySuggestionsTest.php @@ -77,96 +77,99 @@ protected function getClient() } /** - * Test case for CreateConfig - * createConfig + * Test case for DeleteConfig + * deleteConfig */ - public function testCreateConfig0() + public function testDeleteConfig0() { $client = $this->getClient(); - $client->createConfig([ - 'indexName' => 'theIndexName', - - 'sourceIndices' => [ - [ - 'indexName' => 'testIndex', - - 'facets' => [['attributes' => 'test']], - - 'generate' => [['facetA', 'facetB'], ['facetC']], - ], - ], - - 'languages' => ['french'], - - 'exclude' => ['test'], - ]); + $client->deleteConfig('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/configs', - 'method' => 'POST', - 'body' => json_decode( - "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" - ), + 'path' => '/1/configs/theIndexName', + 'method' => 'DELETE', ], ]); } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testDel0() + public function testPost0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->post('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'method' => 'POST', ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testDel1() + public function testPost1() { $client = $this->getClient(); - $client->del( + $client->post( '/test/all', - ['query' => 'parameters'] + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'DELETE', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for DeleteConfig - * deleteConfig + * Test case for UpdateConfig + * updateConfig */ - public function testDeleteConfig0() + public function testUpdateConfig0() { $client = $this->getClient(); - $client->deleteConfig('theIndexName'); + $client->updateConfig( + 'theIndexName', + [ + 'sourceIndices' => [ + [ + 'indexName' => 'testIndex', + + 'facets' => [['attributes' => 'test']], + + 'generate' => [['facetA', 'facetB'], ['facetC']], + ], + ], + + 'languages' => ['french'], + + 'exclude' => ['test'], + ] + ); $this->assertRequests([ [ 'path' => '/1/configs/theIndexName', - 'method' => 'DELETE', + 'method' => 'PUT', + 'body' => json_decode( + "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" + ), ], ]); } @@ -212,115 +215,132 @@ public function testGet1() } /** - * Test case for GetAllConfigs - * getAllConfigs + * Test case for CreateConfig + * createConfig */ - public function testGetAllConfigs0() + public function testCreateConfig0() { $client = $this->getClient(); - $client->getAllConfigs(); + $client->createConfig([ + 'indexName' => 'theIndexName', + + 'sourceIndices' => [ + [ + 'indexName' => 'testIndex', + + 'facets' => [['attributes' => 'test']], + + 'generate' => [['facetA', 'facetB'], ['facetC']], + ], + ], + + 'languages' => ['french'], + + 'exclude' => ['test'], + ]); $this->assertRequests([ [ 'path' => '/1/configs', - 'method' => 'GET', + 'method' => 'POST', + 'body' => json_decode( + "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" + ), ], ]); } /** - * Test case for GetConfig - * getConfig + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testGetConfig0() + public function testDel0() { $client = $this->getClient(); - $client->getConfig('theIndexName'); + $client->del('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/configs/theIndexName', - 'method' => 'GET', + 'path' => '/1/test/minimal', + 'method' => 'DELETE', ], ]); } /** - * Test case for GetConfigStatus - * getConfigStatus + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testGetConfigStatus0() + public function testDel1() { $client = $this->getClient(); - $client->getConfigStatus('theIndexName'); + $client->del( + '/test/all', + ['query' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/configs/theIndexName/status', - 'method' => 'GET', + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for GetLogFile - * getLogFile + * Test case for GetConfigStatus + * getConfigStatus */ - public function testGetLogFile0() + public function testGetConfigStatus0() { $client = $this->getClient(); - $client->getLogFile('theIndexName'); + $client->getConfigStatus('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/logs/theIndexName', + 'path' => '/1/configs/theIndexName/status', 'method' => 'GET', ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for GetAllConfigs + * getAllConfigs */ - public function testPost0() + public function testGetAllConfigs0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->getAllConfigs(); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'POST', + 'path' => '/1/configs', + 'method' => 'GET', ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for GetConfig + * getConfig */ - public function testPost1() + public function testGetConfig0() { $client = $this->getClient(); - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] - ); + $client->getConfig('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/configs/theIndexName', + 'method' => 'GET', ], ]); } @@ -368,39 +388,19 @@ public function testPut1() } /** - * Test case for UpdateConfig - * updateConfig + * Test case for GetLogFile + * getLogFile */ - public function testUpdateConfig0() + public function testGetLogFile0() { $client = $this->getClient(); - $client->updateConfig( - 'theIndexName', - [ - 'sourceIndices' => [ - [ - 'indexName' => 'testIndex', - - 'facets' => [['attributes' => 'test']], - - 'generate' => [['facetA', 'facetB'], ['facetC']], - ], - ], - - 'languages' => ['french'], - - 'exclude' => ['test'], - ] - ); + $client->getLogFile('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/configs/theIndexName', - 'method' => 'PUT', - 'body' => json_decode( - "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" - ), + 'path' => '/1/logs/theIndexName', + 'method' => 'GET', ], ]); } diff --git a/tests/output/php/src/methods/requests/RecommendTest.php b/tests/output/php/src/methods/requests/RecommendTest.php index 70b6fe932d..c8b7caa371 100644 --- a/tests/output/php/src/methods/requests/RecommendTest.php +++ b/tests/output/php/src/methods/requests/RecommendTest.php @@ -77,40 +77,42 @@ protected function getClient() } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testDel0() + public function testPost0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->post('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'method' => 'POST', ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testDel1() + public function testPost1() { $client = $this->getClient(); - $client->del( + $client->post( '/test/all', - ['query' => 'parameters'] + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'DELETE', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); @@ -156,6 +158,46 @@ public function testGet1() ]); } + /** + * Test case for Del + * allow del method for a custom path with minimal parameters + */ + public function testDel0() + { + $client = $this->getClient(); + + $client->del('/test/minimal'); + + $this->assertRequests([ + [ + 'path' => '/1/test/minimal', + 'method' => 'DELETE', + ], + ]); + } + + /** + * Test case for Del + * allow del method for a custom path with all parameters + */ + public function testDel1() + { + $client = $this->getClient(); + + $client->del( + '/test/all', + ['query' => 'parameters'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + ], + ]); + } + /** * Test case for GetRecommendations * get recommendations for recommend model with minimal parameters @@ -463,48 +505,6 @@ public function testGetRecommendations6() ]); } - /** - * Test case for Post - * allow post method for a custom path with minimal parameters - */ - public function testPost0() - { - $client = $this->getClient(); - - $client->post('/test/minimal'); - - $this->assertRequests([ - [ - 'path' => '/1/test/minimal', - 'method' => 'POST', - ], - ]); - } - - /** - * Test case for Post - * allow post method for a custom path with all parameters - */ - public function testPost1() - { - $client = $this->getClient(); - - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), - ], - ]); - } - /** * Test case for Put * allow put method for a custom path with minimal parameters diff --git a/tests/output/php/src/methods/requests/SearchTest.php b/tests/output/php/src/methods/requests/SearchTest.php index 9a3fe78aea..4313f47940 100644 --- a/tests/output/php/src/methods/requests/SearchTest.php +++ b/tests/output/php/src/methods/requests/SearchTest.php @@ -77,159 +77,181 @@ protected function getClient() } /** - * Test case for AddApiKey - * addApiKey + * Test case for BatchAssignUserIds + * batchAssignUserIds */ - public function testAddApiKey0() + public function testBatchAssignUserIds0() { $client = $this->getClient(); - $client->addApiKey([ - 'acl' => ['search', 'addObject'], - - 'description' => 'my new api key', - - 'validity' => 300, - - 'maxQueriesPerIPPerHour' => 100, - - 'maxHitsPerQuery' => 20, - ]); + $client->batchAssignUserIds( + 'userID', + ['cluster' => 'theCluster', 'users' => ['user1', 'user2']] + ); $this->assertRequests([ [ - 'path' => '/1/keys', + 'path' => '/1/clusters/mapping/batch', 'method' => 'POST', 'body' => json_decode( - "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" + "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}" + ), + 'searchParams' => json_decode( + "{\"X-Algolia-User-ID\":\"userID\"}" ), ], ]); } /** - * Test case for AddOrUpdateObject - * addOrUpdateObject + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testAddOrUpdateObject0() + public function testDel0() { $client = $this->getClient(); - $client->addOrUpdateObject( - 'indexName', - 'uniqueID', - ['key' => 'value'] - ); + $client->del('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/uniqueID', - 'method' => 'PUT', - 'body' => json_decode("{\"key\":\"value\"}"), + 'path' => '/1/test/minimal', + 'method' => 'DELETE', ], ]); } /** - * Test case for AppendSource - * appendSource + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testAppendSource0() + public function testDel1() { $client = $this->getClient(); - $client->appendSource([ - 'source' => 'theSource', + $client->del( + '/test/all', + ['query' => 'parameters'] + ); - 'description' => 'theDescription', + $this->assertRequests([ + [ + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + ], ]); + } + + /** + * Test case for SearchRules + * searchRules + */ + public function testSearchRules0() + { + $client = $this->getClient(); + + $client->searchRules( + 'indexName', + ['query' => 'something'] + ); $this->assertRequests([ [ - 'path' => '/1/security/sources/append', + 'path' => '/1/indexes/indexName/rules/search', 'method' => 'POST', - 'body' => json_decode( - "{\"source\":\"theSource\",\"description\":\"theDescription\"}" - ), + 'body' => json_decode("{\"query\":\"something\"}"), ], ]); } /** - * Test case for AssignUserId - * assignUserId + * Test case for DeleteIndex + * deleteIndex */ - public function testAssignUserId0() + public function testDeleteIndex0() { $client = $this->getClient(); - $client->assignUserId( - 'userID', - ['cluster' => 'theCluster'] - ); + $client->deleteIndex('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping', - 'method' => 'POST', - 'body' => json_decode("{\"cluster\":\"theCluster\"}"), - 'searchParams' => json_decode( - "{\"X-Algolia-User-ID\":\"userID\"}" - ), + 'path' => '/1/indexes/theIndexName', + 'method' => 'DELETE', ], ]); } /** - * Test case for Batch - * batch + * Test case for Put + * allow put method for a custom path with minimal parameters */ - public function testBatch0() + public function testPut0() { $client = $this->getClient(); - $client->batch( - 'theIndexName', + $client->put('/test/minimal'); + + $this->assertRequests([ [ - 'requests' => [ - ['action' => 'delete', 'body' => ['key' => 'value']], - ], - ] + 'path' => '/1/test/minimal', + 'method' => 'PUT', + ], + ]); + } + + /** + * Test case for Put + * allow put method for a custom path with all parameters + */ + public function testPut1() + { + $client = $this->getClient(); + + $client->put( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/batch', - 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}" - ), + 'path' => '/1/test/all', + 'method' => 'PUT', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for BatchAssignUserIds - * batchAssignUserIds + * Test case for UpdateApiKey + * updateApiKey */ - public function testBatchAssignUserIds0() + public function testUpdateApiKey0() { $client = $this->getClient(); - $client->batchAssignUserIds( - 'userID', - ['cluster' => 'theCluster', 'users' => ['user1', 'user2']] + $client->updateApiKey( + 'myApiKey', + [ + 'acl' => ['search', 'addObject'], + + 'validity' => 300, + + 'maxQueriesPerIPPerHour' => 100, + + 'maxHitsPerQuery' => 20, + ] ); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/batch', - 'method' => 'POST', + 'path' => '/1/keys/myApiKey', + 'method' => 'PUT', 'body' => json_decode( - "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}" - ), - 'searchParams' => json_decode( - "{\"X-Algolia-User-ID\":\"userID\"}" + "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" ), ], ]); @@ -389,420 +411,536 @@ public function testBatchRules0() } /** - * Test case for Browse - * get browse results with minimal parameters + * Test case for RestoreApiKey + * restoreApiKey */ - public function testBrowse0() + public function testRestoreApiKey0() { $client = $this->getClient(); - $client->browse('indexName'); + $client->restoreApiKey('myApiKey'); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/browse', + 'path' => '/1/keys/myApiKey/restore', 'method' => 'POST', ], ]); } /** - * Test case for Browse - * get browse results with all parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testBrowse1() + public function testPost0() { $client = $this->getClient(); - $client->browse( - 'indexName', - ['params' => "query=foo&facetFilters=['bar']", 'cursor' => 'cts'] - ); + $client->post('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/browse', + 'path' => '/1/test/minimal', 'method' => 'POST', - 'body' => json_decode( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}" - ), ], ]); } /** - * Test case for ClearAllSynonyms - * clearAllSynonyms + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testClearAllSynonyms0() + public function testPost1() { $client = $this->getClient(); - $client->clearAllSynonyms('indexName'); + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/clear', + 'path' => '/1/test/all', 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for ClearObjects - * clearObjects + * Test case for MultipleBatch + * multipleBatch */ - public function testClearObjects0() + public function testMultipleBatch0() { $client = $this->getClient(); - $client->clearObjects('theIndexName'); + $client->multipleBatch([ + 'requests' => [ + [ + 'action' => 'addObject', + + 'body' => ['key' => 'value'], + 'indexName' => 'theIndexName', + ], + ], + ]); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/clear', + 'path' => '/1/indexes/*/batch', 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}" + ), ], ]); } /** - * Test case for ClearRules - * clearRules + * Test case for DeleteObject + * deleteObject */ - public function testClearRules0() + public function testDeleteObject0() { $client = $this->getClient(); - $client->clearRules('indexName'); + $client->deleteObject( + 'theIndexName', + 'uniqueID' + ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/clear', - 'method' => 'POST', + 'path' => '/1/indexes/theIndexName/uniqueID', + 'method' => 'DELETE', ], ]); } /** - * Test case for Del - * allow del method for a custom path with minimal parameters - */ - public function testDel0() + * Test case for SearchUserIds + * searchUserIds + */ + public function testSearchUserIds0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->searchUserIds([ + 'query' => 'test', + + 'clusterName' => 'theClusterName', + + 'page' => 5, + + 'hitsPerPage' => 10, + ]); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'path' => '/1/clusters/mapping/search', + 'method' => 'POST', + 'body' => json_decode( + "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}" + ), ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for ReplaceSources + * replaceSources */ - public function testDel1() + public function testReplaceSources0() { $client = $this->getClient(); - $client->del( - '/test/all', - ['query' => 'parameters'] - ); + $client->replaceSources([ + ['source' => 'theSource', 'description' => 'theDescription'], + ]); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/security/sources', + 'method' => 'PUT', + 'body' => json_decode( + "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]" + ), ], ]); } /** - * Test case for DeleteApiKey - * deleteApiKey + * Test case for RemoveUserId + * removeUserId */ - public function testDeleteApiKey0() + public function testRemoveUserId0() { $client = $this->getClient(); - $client->deleteApiKey('myTestApiKey'); + $client->removeUserId('uniqueID'); $this->assertRequests([ [ - 'path' => '/1/keys/myTestApiKey', + 'path' => '/1/clusters/mapping/uniqueID', 'method' => 'DELETE', ], ]); } /** - * Test case for DeleteBy - * deleteBy + * Test case for GetObject + * getObject */ - public function testDeleteBy0() + public function testGetObject0() { $client = $this->getClient(); - $client->deleteBy( + $client->getObject( 'theIndexName', - ['query' => 'testQuery'] + 'uniqueID', + ['attr1', 'attr2'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/deleteByQuery', - 'method' => 'POST', - 'body' => json_decode("{\"query\":\"testQuery\"}"), + 'path' => '/1/indexes/theIndexName/uniqueID', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"attributesToRetrieve\":\"attr1,attr2\"}" + ), ], ]); } /** - * Test case for DeleteIndex - * deleteIndex + * Test case for GetApiKey + * getApiKey */ - public function testDeleteIndex0() + public function testGetApiKey0() { $client = $this->getClient(); - $client->deleteIndex('theIndexName'); + $client->getApiKey('myTestApiKey'); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName', - 'method' => 'DELETE', + 'path' => '/1/keys/myTestApiKey', + 'method' => 'GET', ], ]); } /** - * Test case for DeleteObject - * deleteObject + * Test case for AssignUserId + * assignUserId */ - public function testDeleteObject0() + public function testAssignUserId0() { $client = $this->getClient(); - $client->deleteObject( - 'theIndexName', - 'uniqueID' + $client->assignUserId( + 'userID', + ['cluster' => 'theCluster'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/uniqueID', - 'method' => 'DELETE', + 'path' => '/1/clusters/mapping', + 'method' => 'POST', + 'body' => json_decode("{\"cluster\":\"theCluster\"}"), + 'searchParams' => json_decode( + "{\"X-Algolia-User-ID\":\"userID\"}" + ), ], ]); } /** - * Test case for DeleteRule - * deleteRule + * Test case for DeleteSynonym + * deleteSynonym */ - public function testDeleteRule0() + public function testDeleteSynonym0() { $client = $this->getClient(); - $client->deleteRule( + $client->deleteSynonym( 'indexName', 'id1' ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/id1', + 'path' => '/1/indexes/indexName/synonyms/id1', 'method' => 'DELETE', ], ]); } /** - * Test case for DeleteSource - * deleteSource + * Test case for SearchSynonyms + * searchSynonyms */ - public function testDeleteSource0() + public function testSearchSynonyms0() { $client = $this->getClient(); - $client->deleteSource('theSource'); + $client->searchSynonyms('indexName'); $this->assertRequests([ [ - 'path' => '/1/security/sources/theSource', - 'method' => 'DELETE', + 'path' => '/1/indexes/indexName/synonyms/search', + 'method' => 'POST', ], ]); } /** - * Test case for DeleteSynonym - * deleteSynonym + * Test case for GetLogs + * getLogs */ - public function testDeleteSynonym0() + public function testGetLogs0() { $client = $this->getClient(); - $client->deleteSynonym( - 'indexName', - 'id1' + $client->getLogs( + 5, + 10, + 'theIndexName', + 'all' ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/id1', - 'method' => 'DELETE', + 'path' => '/1/logs', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}" + ), ], ]); } /** - * Test case for Get - * allow get method for a custom path with minimal parameters + * Test case for Batch + * batch */ - public function testGet0() + public function testBatch0() { $client = $this->getClient(); - $client->get('/test/minimal'); + $client->batch( + 'theIndexName', + [ + 'requests' => [ + ['action' => 'delete', 'body' => ['key' => 'value']], + ], + ] + ); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'GET', + 'path' => '/1/indexes/theIndexName/batch', + 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}" + ), ], ]); } /** - * Test case for Get - * allow get method for a custom path with all parameters + * Test case for AddOrUpdateObject + * addOrUpdateObject */ - public function testGet1() + public function testAddOrUpdateObject0() { $client = $this->getClient(); - $client->get( - '/test/all', - ['query' => 'parameters'] + $client->addOrUpdateObject( + 'indexName', + 'uniqueID', + ['key' => 'value'] ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/indexes/indexName/uniqueID', + 'method' => 'PUT', + 'body' => json_decode("{\"key\":\"value\"}"), ], ]); } /** - * Test case for GetApiKey - * getApiKey + * Test case for ClearObjects + * clearObjects */ - public function testGetApiKey0() + public function testClearObjects0() { $client = $this->getClient(); - $client->getApiKey('myTestApiKey'); + $client->clearObjects('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/keys/myTestApiKey', - 'method' => 'GET', + 'path' => '/1/indexes/theIndexName/clear', + 'method' => 'POST', ], ]); } /** - * Test case for GetDictionaryLanguages - * get getDictionaryLanguages + * Test case for SetSettings + * setSettings */ - public function testGetDictionaryLanguages0() + public function testSetSettings0() { $client = $this->getClient(); - $client->getDictionaryLanguages(); + $client->setSettings( + 'theIndexName', + ['paginationLimitedTo' => 10], + true + ); $this->assertRequests([ [ - 'path' => '/1/dictionaries/*/languages', - 'method' => 'GET', + 'path' => '/1/indexes/theIndexName/settings', + 'method' => 'PUT', + 'body' => json_decode("{\"paginationLimitedTo\":10}"), + 'searchParams' => json_decode( + "{\"forwardToReplicas\":\"true\"}" + ), ], ]); } /** - * Test case for GetDictionarySettings - * get getDictionarySettings results + * Test case for ClearRules + * clearRules */ - public function testGetDictionarySettings0() + public function testClearRules0() { $client = $this->getClient(); - $client->getDictionarySettings(); + $client->clearRules('indexName'); $this->assertRequests([ [ - 'path' => '/1/dictionaries/*/settings', - 'method' => 'GET', + 'path' => '/1/indexes/indexName/rules/clear', + 'method' => 'POST', ], ]); } /** - * Test case for GetLogs - * getLogs + * Test case for GetSynonym + * getSynonym */ - public function testGetLogs0() + public function testGetSynonym0() { $client = $this->getClient(); - $client->getLogs( - 5, - 10, - 'theIndexName', - 'all' + $client->getSynonym( + 'indexName', + 'id1' ); $this->assertRequests([ [ - 'path' => '/1/logs', + 'path' => '/1/indexes/indexName/synonyms/id1', 'method' => 'GET', - 'searchParams' => json_decode( - "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}" - ), ], ]); } /** - * Test case for GetObject - * getObject + * Test case for DeleteBy + * deleteBy */ - public function testGetObject0() + public function testDeleteBy0() { $client = $this->getClient(); - $client->getObject( + $client->deleteBy( 'theIndexName', - 'uniqueID', - ['attr1', 'attr2'] + ['query' => 'testQuery'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/uniqueID', + 'path' => '/1/indexes/theIndexName/deleteByQuery', + 'method' => 'POST', + 'body' => json_decode("{\"query\":\"testQuery\"}"), + ], + ]); + } + + /** + * Test case for ListUserIds + * listUserIds + */ + public function testListUserIds0() + { + $client = $this->getClient(); + + $client->listUserIds( + 8, + 100 + ); + + $this->assertRequests([ + [ + 'path' => '/1/clusters/mapping', 'method' => 'GET', 'searchParams' => json_decode( - "{\"attributesToRetrieve\":\"attr1,attr2\"}" + "{\"page\":\"8\",\"hitsPerPage\":\"100\"}" + ), + ], + ]); + } + + /** + * Test case for Browse + * get browse results with minimal parameters + */ + public function testBrowse0() + { + $client = $this->getClient(); + + $client->browse('indexName'); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/indexName/browse', + 'method' => 'POST', + ], + ]); + } + + /** + * Test case for Browse + * get browse results with all parameters + */ + public function testBrowse1() + { + $client = $this->getClient(); + + $client->browse( + 'indexName', + ['params' => "query=foo&facetFilters=['bar']", 'cursor' => 'cts'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/indexName/browse', + 'method' => 'POST', + 'body' => json_decode( + "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}" ), ], ]); @@ -840,540 +978,557 @@ public function testGetObjects0() } /** - * Test case for GetRule - * getRule + * Test case for PartialUpdateObject + * partialUpdateObject */ - public function testGetRule0() + public function testPartialUpdateObject0() { $client = $this->getClient(); - $client->getRule( - 'indexName', - 'id1' + $client->partialUpdateObject( + 'theIndexName', + 'uniqueID', + [ + [ + 'id1' => 'test', + + 'id2' => ['_operation' => 'AddUnique', 'value' => 'test2'], + ], + ], + true ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/id1', - 'method' => 'GET', + 'path' => '/1/indexes/theIndexName/uniqueID/partial', + 'method' => 'POST', + 'body' => json_decode( + "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]" + ), + 'searchParams' => json_decode( + "{\"createIfNotExists\":\"true\"}" + ), ], ]); } /** - * Test case for GetSettings - * getSettings + * Test case for MultipleQueries + * multipleQueries for a single request with minimal parameters */ - public function testGetSettings0() + public function testMultipleQueries0() { $client = $this->getClient(); - $client->getSettings('theIndexName'); + $client->multipleQueries([ + 'requests' => [['indexName' => 'theIndexName']], + + 'strategy' => 'stopIfEnoughMatches', + ]); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/settings', - 'method' => 'GET', + 'path' => '/1/indexes/*/queries', + 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"indexName\":\"theIndexName\"}],\"strategy\":\"stopIfEnoughMatches\"}" + ), ], ]); } /** - * Test case for GetSources - * getSources + * Test case for MultipleQueries + * multipleQueries for multiple requests with all parameters */ - public function testGetSources0() + public function testMultipleQueries1() { $client = $this->getClient(); - $client->getSources(); + $client->multipleQueries([ + 'requests' => [ + [ + 'indexName' => 'theIndexName', + + 'query' => 'test', + + 'type' => 'facet', + + 'facet' => 'theFacet', + + 'params' => 'testParam', + ], + + [ + 'indexName' => 'theIndexName', + + 'query' => 'test', + + 'type' => 'default', + + 'params' => 'testParam', + ], + ], + + 'strategy' => 'stopIfEnoughMatches', + ]); $this->assertRequests([ [ - 'path' => '/1/security/sources', - 'method' => 'GET', + 'path' => '/1/indexes/*/queries', + 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"},{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"default\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}" + ), ], ]); } /** - * Test case for GetSynonym - * getSynonym + * Test case for SearchForFacetValues + * get searchForFacetValues results with minimal parameters */ - public function testGetSynonym0() + public function testSearchForFacetValues0() { $client = $this->getClient(); - $client->getSynonym( + $client->searchForFacetValues( 'indexName', - 'id1' + 'facetName' ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/id1', - 'method' => 'GET', + 'path' => '/1/indexes/indexName/facets/facetName/query', + 'method' => 'POST', ], ]); } /** - * Test case for GetTask - * getTask + * Test case for SearchForFacetValues + * get searchForFacetValues results with all parameters */ - public function testGetTask0() + public function testSearchForFacetValues1() { $client = $this->getClient(); - $client->getTask( - 'theIndexName', - 123 + $client->searchForFacetValues( + 'indexName', + 'facetName', + [ + 'params' => "query=foo&facetFilters=['bar']", + + 'facetQuery' => 'foo', + + 'maxFacetHits' => 42, + ] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/task/123', - 'method' => 'GET', + 'path' => '/1/indexes/indexName/facets/facetName/query', + 'method' => 'POST', + 'body' => json_decode( + "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}" + ), ], ]); } /** - * Test case for GetTopUserIds - * getTopUserIds + * Test case for GetSettings + * getSettings */ - public function testGetTopUserIds0() + public function testGetSettings0() { $client = $this->getClient(); - $client->getTopUserIds(); + $client->getSettings('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/top', + 'path' => '/1/indexes/theIndexName/settings', 'method' => 'GET', ], ]); } /** - * Test case for GetUserId - * getUserId + * Test case for ListIndices + * listIndices */ - public function testGetUserId0() + public function testListIndices0() { $client = $this->getClient(); - $client->getUserId('uniqueID'); + $client->listIndices(8); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/uniqueID', + 'path' => '/1/indexes', 'method' => 'GET', + 'searchParams' => json_decode("{\"page\":\"8\"}"), ], ]); } /** - * Test case for HasPendingMappings - * hasPendingMappings + * Test case for GetDictionarySettings + * get getDictionarySettings results */ - public function testHasPendingMappings0() + public function testGetDictionarySettings0() { $client = $this->getClient(); - $client->hasPendingMappings(true); + $client->getDictionarySettings(); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/pending', + 'path' => '/1/dictionaries/*/settings', 'method' => 'GET', - 'searchParams' => json_decode("{\"getClusters\":\"true\"}"), ], ]); } /** - * Test case for ListApiKeys - * listApiKeys + * Test case for DeleteSource + * deleteSource */ - public function testListApiKeys0() + public function testDeleteSource0() { $client = $this->getClient(); - $client->listApiKeys(); + $client->deleteSource('theSource'); $this->assertRequests([ [ - 'path' => '/1/keys', - 'method' => 'GET', + 'path' => '/1/security/sources/theSource', + 'method' => 'DELETE', ], ]); } /** - * Test case for ListClusters - * listClusters + * Test case for GetSources + * getSources */ - public function testListClusters0() + public function testGetSources0() { $client = $this->getClient(); - $client->listClusters(); + $client->getSources(); $this->assertRequests([ [ - 'path' => '/1/clusters', + 'path' => '/1/security/sources', 'method' => 'GET', ], ]); } /** - * Test case for ListIndices - * listIndices + * Test case for GetDictionaryLanguages + * get getDictionaryLanguages */ - public function testListIndices0() + public function testGetDictionaryLanguages0() { $client = $this->getClient(); - $client->listIndices(8); + $client->getDictionaryLanguages(); $this->assertRequests([ [ - 'path' => '/1/indexes', + 'path' => '/1/dictionaries/*/languages', 'method' => 'GET', - 'searchParams' => json_decode("{\"page\":\"8\"}"), ], ]); } /** - * Test case for ListUserIds - * listUserIds + * Test case for DeleteApiKey + * deleteApiKey */ - public function testListUserIds0() + public function testDeleteApiKey0() { $client = $this->getClient(); - $client->listUserIds( - 8, - 100 - ); + $client->deleteApiKey('myTestApiKey'); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"page\":\"8\",\"hitsPerPage\":\"100\"}" - ), + 'path' => '/1/keys/myTestApiKey', + 'method' => 'DELETE', ], ]); } /** - * Test case for MultipleBatch - * multipleBatch + * Test case for ListApiKeys + * listApiKeys */ - public function testMultipleBatch0() + public function testListApiKeys0() { $client = $this->getClient(); - $client->multipleBatch([ - 'requests' => [ - [ - 'action' => 'addObject', - - 'body' => ['key' => 'value'], - 'indexName' => 'theIndexName', - ], - ], - ]); + $client->listApiKeys(); $this->assertRequests([ [ - 'path' => '/1/indexes/*/batch', - 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}" - ), + 'path' => '/1/keys', + 'method' => 'GET', ], ]); } /** - * Test case for MultipleQueries - * multipleQueries + * Test case for SaveSynonyms + * saveSynonyms */ - public function testMultipleQueries0() + public function testSaveSynonyms0() { $client = $this->getClient(); - $client->multipleQueries([ - 'requests' => [ + $client->saveSynonyms( + 'indexName', + [ [ - 'indexName' => 'theIndexName', + 'objectID' => 'id1', - 'query' => 'test', + 'type' => 'synonym', - 'type' => 'facet', + 'synonyms' => ['car', 'vehicule', 'auto'], + ], - 'facet' => 'theFacet', + [ + 'objectID' => 'id2', - 'params' => 'testParam', + 'type' => 'onewaysynonym', + + 'input' => 'iphone', + + 'synonyms' => ['ephone', 'aphone', 'yphone'], ], ], - - 'strategy' => 'stopIfEnoughMatches', - ]); + true, + false + ); $this->assertRequests([ [ - 'path' => '/1/indexes/*/queries', + 'path' => '/1/indexes/indexName/synonyms/batch', 'method' => 'POST', 'body' => json_decode( - "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}" + "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]" + ), + 'searchParams' => json_decode( + "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}" ), ], ]); } /** - * Test case for OperationIndex - * operationIndex + * Test case for Search + * search with minimal parameters */ - public function testOperationIndex0() + public function testSearch0() { $client = $this->getClient(); - $client->operationIndex( - 'theIndexName', - [ - 'operation' => 'copy', - - 'destination' => 'dest', - - 'scope' => ['rules', 'settings'], - ] + $client->search( + 'indexName', + ['query' => 'myQuery'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/operation', + 'path' => '/1/indexes/indexName/query', 'method' => 'POST', - 'body' => json_decode( - "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}" - ), + 'body' => json_decode("{\"query\":\"myQuery\"}"), ], ]); } /** - * Test case for PartialUpdateObject - * partialUpdateObject + * Test case for Search + * search with facetFilters */ - public function testPartialUpdateObject0() + public function testSearch1() { $client = $this->getClient(); - $client->partialUpdateObject( - 'theIndexName', - 'uniqueID', - [ - [ - 'id1' => 'test', - - 'id2' => ['_operation' => 'AddUnique', 'value' => 'test2'], - ], - ], - true + $client->search( + 'indexName', + ['query' => 'myQuery', 'facetFilters' => ['tags:algolia']] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/uniqueID/partial', + 'path' => '/1/indexes/indexName/query', 'method' => 'POST', 'body' => json_decode( - "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]" - ), - 'searchParams' => json_decode( - "{\"createIfNotExists\":\"true\"}" + "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}" ), ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Get + * allow get method for a custom path with minimal parameters */ - public function testPost0() + public function testGet0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->get('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'POST', + 'method' => 'GET', ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for Get + * allow get method for a custom path with all parameters */ - public function testPost1() + public function testGet1() { $client = $this->getClient(); - $client->post( + $client->get( '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + ['query' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), + 'method' => 'GET', 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for Put - * allow put method for a custom path with minimal parameters + * Test case for HasPendingMappings + * hasPendingMappings */ - public function testPut0() + public function testHasPendingMappings0() { $client = $this->getClient(); - $client->put('/test/minimal'); + $client->hasPendingMappings(true); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'PUT', + 'path' => '/1/clusters/mapping/pending', + 'method' => 'GET', + 'searchParams' => json_decode("{\"getClusters\":\"true\"}"), ], ]); } /** - * Test case for Put - * allow put method for a custom path with all parameters + * Test case for GetTopUserIds + * getTopUserIds */ - public function testPut1() + public function testGetTopUserIds0() { $client = $this->getClient(); - $client->put( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] - ); + $client->getTopUserIds(); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'PUT', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/clusters/mapping/top', + 'method' => 'GET', ], ]); } /** - * Test case for RemoveUserId - * removeUserId + * Test case for SetDictionarySettings + * get setDictionarySettings results with minimal parameters */ - public function testRemoveUserId0() + public function testSetDictionarySettings0() { $client = $this->getClient(); - $client->removeUserId('uniqueID'); + $client->setDictionarySettings([ + 'disableStandardEntries' => [ + 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], + ], + ]); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/uniqueID', - 'method' => 'DELETE', + 'path' => '/1/dictionaries/*/settings', + 'method' => 'PUT', + 'body' => json_decode( + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}" + ), ], ]); } /** - * Test case for ReplaceSources - * replaceSources + * Test case for SetDictionarySettings + * get setDictionarySettings results with all parameters */ - public function testReplaceSources0() + public function testSetDictionarySettings1() { $client = $this->getClient(); - $client->replaceSources([ - ['source' => 'theSource', 'description' => 'theDescription'], + $client->setDictionarySettings([ + 'disableStandardEntries' => [ + 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], + 'stopwords' => ['fr' => false], + 'compounds' => ['ru' => true], + ], ]); $this->assertRequests([ [ - 'path' => '/1/security/sources', + 'path' => '/1/dictionaries/*/settings', 'method' => 'PUT', 'body' => json_decode( - "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]" + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}" ), ], ]); } /** - * Test case for RestoreApiKey - * restoreApiKey + * Test case for DeleteRule + * deleteRule */ - public function testRestoreApiKey0() + public function testDeleteRule0() { $client = $this->getClient(); - $client->restoreApiKey('myApiKey'); + $client->deleteRule( + 'indexName', + 'id1' + ); $this->assertRequests([ [ - 'path' => '/1/keys/myApiKey/restore', - 'method' => 'POST', + 'path' => '/1/indexes/indexName/rules/id1', + 'method' => 'DELETE', ], ]); } /** - * Test case for SaveObject - * saveObject + * Test case for SaveRule + * saveRule */ - public function testSaveObject0() - { - $client = $this->getClient(); - - $client->saveObject( - 'theIndexName', - ['objectID' => 'id', 'test' => 'val'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/theIndexName', - 'method' => 'POST', - 'body' => json_decode("{\"objectID\":\"id\",\"test\":\"val\"}"), - ], - ]); - } - - /** - * Test case for SaveRule - * saveRule - */ - public function testSaveRule0() + public function testSaveRule0() { $client = $this->getClient(); @@ -1406,6 +1561,28 @@ public function testSaveRule0() ]); } + /** + * Test case for SaveObject + * saveObject + */ + public function testSaveObject0() + { + $client = $this->getClient(); + + $client->saveObject( + 'theIndexName', + ['objectID' => 'id', 'test' => 'val'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/theIndexName', + 'method' => 'POST', + 'body' => json_decode("{\"objectID\":\"id\",\"test\":\"val\"}"), + ], + ]); + } + /** * Test case for SaveSynonym * saveSynonym @@ -1442,93 +1619,94 @@ public function testSaveSynonym0() } /** - * Test case for SaveSynonyms - * saveSynonyms + * Test case for AppendSource + * appendSource */ - public function testSaveSynonyms0() + public function testAppendSource0() { $client = $this->getClient(); - $client->saveSynonyms( - 'indexName', - [ - [ - 'objectID' => 'id1', - - 'type' => 'synonym', - - 'synonyms' => ['car', 'vehicule', 'auto'], - ], + $client->appendSource([ + 'source' => 'theSource', - [ - 'objectID' => 'id2', + 'description' => 'theDescription', + ]); - 'type' => 'onewaysynonym', + $this->assertRequests([ + [ + 'path' => '/1/security/sources/append', + 'method' => 'POST', + 'body' => json_decode( + "{\"source\":\"theSource\",\"description\":\"theDescription\"}" + ), + ], + ]); + } - 'input' => 'iphone', + /** + * Test case for ClearAllSynonyms + * clearAllSynonyms + */ + public function testClearAllSynonyms0() + { + $client = $this->getClient(); - 'synonyms' => ['ephone', 'aphone', 'yphone'], - ], - ], - true, - false - ); + $client->clearAllSynonyms('indexName'); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/batch', + 'path' => '/1/indexes/indexName/synonyms/clear', 'method' => 'POST', - 'body' => json_decode( - "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]" - ), - 'searchParams' => json_decode( - "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}" - ), ], ]); } /** - * Test case for Search - * search with minimal parameters + * Test case for GetRule + * getRule */ - public function testSearch0() + public function testGetRule0() { $client = $this->getClient(); - $client->search( + $client->getRule( 'indexName', - ['query' => 'myQuery'] + 'id1' ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/query', - 'method' => 'POST', - 'body' => json_decode("{\"query\":\"myQuery\"}"), + 'path' => '/1/indexes/indexName/rules/id1', + 'method' => 'GET', ], ]); } /** - * Test case for Search - * search with facetFilters + * Test case for OperationIndex + * operationIndex */ - public function testSearch1() + public function testOperationIndex0() { $client = $this->getClient(); - $client->search( - 'indexName', - ['query' => 'myQuery', 'facetFilters' => ['tags:algolia']] + $client->operationIndex( + 'theIndexName', + [ + 'operation' => 'copy', + + 'destination' => 'dest', + + 'scope' => ['rules', 'settings'], + ] ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/query', + 'path' => '/1/indexes/theIndexName/operation', 'method' => 'POST', 'body' => json_decode( - "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}" + "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}" ), ], ]); @@ -1589,232 +1767,89 @@ public function testSearchDictionaryEntries1() } /** - * Test case for SearchForFacetValues - * get searchForFacetValues results with minimal parameters - */ - public function testSearchForFacetValues0() - { - $client = $this->getClient(); - - $client->searchForFacetValues( - 'indexName', - 'facetName' - ); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/indexName/facets/facetName/query', - 'method' => 'POST', - ], - ]); - } - - /** - * Test case for SearchForFacetValues - * get searchForFacetValues results with all parameters - */ - public function testSearchForFacetValues1() - { - $client = $this->getClient(); - - $client->searchForFacetValues( - 'indexName', - 'facetName', - [ - 'params' => "query=foo&facetFilters=['bar']", - - 'facetQuery' => 'foo', - - 'maxFacetHits' => 42, - ] - ); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/indexName/facets/facetName/query', - 'method' => 'POST', - 'body' => json_decode( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}" - ), - ], - ]); - } - - /** - * Test case for SearchRules - * searchRules + * Test case for ListClusters + * listClusters */ - public function testSearchRules0() + public function testListClusters0() { $client = $this->getClient(); - $client->searchRules( - 'indexName', - ['query' => 'something'] - ); + $client->listClusters(); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/search', - 'method' => 'POST', - 'body' => json_decode("{\"query\":\"something\"}"), + 'path' => '/1/clusters', + 'method' => 'GET', ], ]); } /** - * Test case for SearchSynonyms - * searchSynonyms + * Test case for AddApiKey + * addApiKey */ - public function testSearchSynonyms0() + public function testAddApiKey0() { $client = $this->getClient(); - $client->searchSynonyms('indexName'); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/indexName/synonyms/search', - 'method' => 'POST', - ], - ]); - } - - /** - * Test case for SearchUserIds - * searchUserIds - */ - public function testSearchUserIds0() - { - $client = $this->getClient(); + $client->addApiKey([ + 'acl' => ['search', 'addObject'], - $client->searchUserIds([ - 'query' => 'test', + 'description' => 'my new api key', - 'clusterName' => 'theClusterName', + 'validity' => 300, - 'page' => 5, + 'maxQueriesPerIPPerHour' => 100, - 'hitsPerPage' => 10, + 'maxHitsPerQuery' => 20, ]); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/search', + 'path' => '/1/keys', 'method' => 'POST', 'body' => json_decode( - "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}" - ), - ], - ]); - } - - /** - * Test case for SetDictionarySettings - * get setDictionarySettings results with minimal parameters - */ - public function testSetDictionarySettings0() - { - $client = $this->getClient(); - - $client->setDictionarySettings([ - 'disableStandardEntries' => [ - 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], - ], - ]); - - $this->assertRequests([ - [ - 'path' => '/1/dictionaries/*/settings', - 'method' => 'PUT', - 'body' => json_decode( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}" - ), - ], - ]); - } - - /** - * Test case for SetDictionarySettings - * get setDictionarySettings results with all parameters - */ - public function testSetDictionarySettings1() - { - $client = $this->getClient(); - - $client->setDictionarySettings([ - 'disableStandardEntries' => [ - 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], - 'stopwords' => ['fr' => false], - 'compounds' => ['ru' => true], - ], - ]); - - $this->assertRequests([ - [ - 'path' => '/1/dictionaries/*/settings', - 'method' => 'PUT', - 'body' => json_decode( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}" + "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" ), ], ]); } /** - * Test case for SetSettings - * setSettings + * Test case for GetTask + * getTask */ - public function testSetSettings0() + public function testGetTask0() { $client = $this->getClient(); - $client->setSettings( + $client->getTask( 'theIndexName', - ['paginationLimitedTo' => 10], - true + 123 ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/settings', - 'method' => 'PUT', - 'body' => json_decode("{\"paginationLimitedTo\":10}"), - 'searchParams' => json_decode( - "{\"forwardToReplicas\":\"true\"}" - ), + 'path' => '/1/indexes/theIndexName/task/123', + 'method' => 'GET', ], ]); } /** - * Test case for UpdateApiKey - * updateApiKey + * Test case for GetUserId + * getUserId */ - public function testUpdateApiKey0() + public function testGetUserId0() { $client = $this->getClient(); - $client->updateApiKey( - 'myApiKey', - [ - 'acl' => ['search', 'addObject'], - - 'validity' => 300, - - 'maxQueriesPerIPPerHour' => 100, - - 'maxHitsPerQuery' => 20, - ] - ); + $client->getUserId('uniqueID'); $this->assertRequests([ [ - 'path' => '/1/keys/myApiKey', - 'method' => 'PUT', - 'body' => json_decode( - "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" - ), + 'path' => '/1/clusters/mapping/uniqueID', + 'method' => 'GET', ], ]); } From 2f737100a8a636402280089da5cb49dfdf737ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 27 Apr 2022 14:38:35 +0200 Subject: [PATCH 4/6] add javascript clause --- .../java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 3f60a1fcda..ae68d604f4 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -193,8 +193,11 @@ private Map loadCTS() String clientName = client; // This special case allow us to read the `search` CTS to generated the - // tests for the `algoliasearch-lite` client. - if (clientName.equals("algoliasearch-lite")) { + // tests for the `algoliasearch-lite` client, which is only available + // in JavaScript + if ( + language.equals("javascript") && clientName.equals("algoliasearch-lite") + ) { clientName = "search"; } From b3a36004590ca41ee4f262edc59904d6fd4e99e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 27 Apr 2022 16:31:07 +0200 Subject: [PATCH 5/6] is it sorted --- .../codegen/cts/AlgoliaCtsGenerator.java | 11 +- .../methods/requests/abtesting.test.java | 210 +- .../methods/requests/analytics.test.java | 882 +++---- .../methods/requests/insights.test.java | 158 +- .../requests/personalization.test.java | 244 +- .../requests/query-suggestions.test.java | 416 +-- .../methods/requests/recommend.test.java | 158 +- .../algolia/methods/requests/search.test.java | 2334 ++++++++--------- .../src/methods/requests/abtesting.test.ts | 118 +- .../requests/algoliasearch-lite.test.ts | 52 +- .../src/methods/requests/analytics.test.ts | 554 ++-- .../src/methods/requests/insights.test.ts | 68 +- .../methods/requests/personalization.test.ts | 118 +- .../requests/query-suggestions.test.ts | 204 +- .../src/methods/requests/recommend.test.ts | 68 +- .../src/methods/requests/search.test.ts | 1214 ++++----- .../src/methods/requests/sources.test.ts | 34 +- .../src/methods/requests/AbtestingTest.php | 146 +- .../src/methods/requests/AnalyticsTest.php | 690 ++--- .../php/src/methods/requests/InsightsTest.php | 106 +- .../methods/requests/PersonalizationTest.php | 158 +- .../methods/requests/QuerySuggestionsTest.php | 214 +- .../src/methods/requests/RecommendTest.php | 106 +- .../php/src/methods/requests/SearchTest.php | 1384 +++++----- 24 files changed, 4827 insertions(+), 4820 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 ae68d604f4..e4ea3c5641 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -10,7 +10,10 @@ import java.io.File; import java.io.IOException; import java.util.*; +import java.util.Collections; import java.util.Map.Entry; +import java.util.TreeMap; +import java.util.stream.Collectors; import org.openapitools.codegen.*; @SuppressWarnings("unchecked") @@ -228,7 +231,7 @@ private Map loadCTS() } // operationId -> CodegenOperation - private HashMap buildOperations( + private TreeMap buildOperations( Map objs ) { HashMap result = new HashMap<>(); @@ -236,20 +239,24 @@ private HashMap buildOperations( ((Map>>) objs.get("apiInfo")).get( "apis" ); + for (Map api : apis) { String apiName = ((String) api.get("baseName")).toLowerCase(); if (!apiName.equals(client.replace("-", ""))) { continue; } + List operations = ((Map>) api.get("operations")).get( "operation" ); + for (CodegenOperation ope : operations) { result.put(ope.operationId, ope); } } - return result; + + return new TreeMap(result); } private String createImportName() { 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 53345e57bf..0185285041 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 @@ -29,36 +29,80 @@ void init() { } @Test - @DisplayName("deleteABTest") - void deleteABTestTest0() { - int id0 = 42; + @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(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.deleteABTest(id0); + return client.addABTests(addABTestsRequest0); } ); - assertEquals(req.getPath(), "/2/abtests/42"); - assertEquals(req.getMethod(), "DELETE"); + 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 post method for a custom path with minimal parameters") - void postTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -68,28 +112,13 @@ void postTest1() { 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); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -114,75 +143,17 @@ void postTest1() { } @Test - @DisplayName("stopABTest") - void stopABTestTest0() { + @DisplayName("deleteABTest") + void deleteABTestTest0() { int id0 = 42; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.stopABTest(id0); - } - ); - - assertEquals(req.getPath(), "/2/abtests/42/stop"); - assertEquals(req.getMethod(), "POST"); - } - - @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(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); + return client.deleteABTest(id0); } ); - 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 - ); - }); + assertEquals(req.getPath(), "/2/abtests/42"); + assertEquals(req.getMethod(), "DELETE"); } @Test @@ -241,6 +212,20 @@ void getTest1() { } } + @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() { @@ -279,22 +264,22 @@ void listABTestsTest0() { } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.post(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -304,13 +289,28 @@ void delTest1() { parameters0.put("query", query1); } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.post(path0, parameters0, body0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -406,16 +406,16 @@ void putTest1() { } @Test - @DisplayName("getABTest") - void getABTestTest0() { + @DisplayName("stopABTest") + void stopABTestTest0() { int id0 = 42; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getABTest(id0); + return client.stopABTest(id0); } ); - assertEquals(req.getPath(), "/2/abtests/42"); - assertEquals(req.getMethod(), "GET"); + 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 24fa9b2dc0..9b353c7f8e 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 @@ -29,20 +29,41 @@ void init() { } @Test - @DisplayName("get getTopSearches with minimal parameters") - void getTopSearchesTest0() { - String index0 = "index"; + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopSearches(index0); + return client.del(path0); } ); - assertEquals(req.getPath(), "/2/searches"); - assertEquals(req.getMethod(), "GET"); + 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( - "{\"index\":\"index\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -64,46 +85,41 @@ void getTopSearchesTest0() { } @Test - @DisplayName("get getTopSearches with all parameters") - void getTopSearchesTest1() { - String index0 = "index"; - - boolean clickAnalytics0 = true; - - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; - OrderBy orderBy0 = OrderBy.fromValue("searchCount"); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.get(path0); + } + ); - Direction direction0 = Direction.fromValue("asc"); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); + } - int limit0 = 21; + @Test + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; - int offset0 = 42; + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; - String tags0 = "tag"; + parameters0.put("query", query1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopSearches( - index0, - clickAnalytics0, - startDate0, - endDate0, - orderBy0, - direction0, - limit0, - offset0, - tags0 - ); + return client.get(path0, parameters0); } ); - assertEquals(req.getPath(), "/2/searches"); + assertEquals(req.getPath(), "/1/test/all"); 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\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -125,16 +141,16 @@ void getTopSearchesTest1() { } @Test - @DisplayName("get getTopHits with minimal parameters") - void getTopHitsTest0() { + @DisplayName("get getAverageClickPosition with minimal parameters") + void getAverageClickPositionTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopHits(index0); + return client.getAverageClickPosition(index0); } ); - assertEquals(req.getPath(), "/2/hits"); + assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -160,43 +176,31 @@ void getTopHitsTest0() { } @Test - @DisplayName("get getTopHits with all parameters") - void getTopHitsTest1() { + @DisplayName("get getAverageClickPosition with all parameters") + void getAverageClickPositionTest1() { String index0 = "index"; - String search0 = "mySearch"; - - boolean clickAnalytics0 = true; - String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; - int limit0 = 21; - - int offset0 = 42; - String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopHits( + return client.getAverageClickPosition( index0, - search0, - clickAnalytics0, startDate0, endDate0, - limit0, - offset0, tags0 ); } ); - assertEquals(req.getPath(), "/2/hits"); + assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); 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\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -218,41 +222,61 @@ void getTopHitsTest1() { } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; + @DisplayName("get getClickPositions with minimal parameters") + void getClickPositionsTest0() { + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.getClickPositions(index0); } ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/2/clicks/positions"); + assertEquals(req.getMethod(), "GET"); + + Map 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" + ); + } } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; + @DisplayName("get getClickPositions with all parameters") + void getClickPositionsTest1() { + String index0 = "index"; - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; + String startDate0 = "1999-09-19"; - parameters0.put("query", query1); - } + String endDate0 = "2001-01-01"; + + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.getClickPositions(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/2/clicks/positions"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -274,16 +298,16 @@ void delTest1() { } @Test - @DisplayName("get getTopFiltersNoResults with minimal parameters") - void getTopFiltersNoResultsTest0() { + @DisplayName("get getClickThroughRate with minimal parameters") + void getClickThroughRateTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFiltersNoResults(index0); + return client.getClickThroughRate(index0); } ); - assertEquals(req.getPath(), "/2/filters/noResults"); + assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -309,40 +333,26 @@ void getTopFiltersNoResultsTest0() { } @Test - @DisplayName("get getTopFiltersNoResults with all parameters") - void getTopFiltersNoResultsTest1() { + @DisplayName("get getClickThroughRate with all parameters") + void getClickThroughRateTest1() { String index0 = "index"; - String search0 = "mySearch"; - String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; - int limit0 = 21; - - int offset0 = 42; - String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFiltersNoResults( - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); + return client.getClickThroughRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/filters/noResults"); + assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); 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\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -364,16 +374,16 @@ void getTopFiltersNoResultsTest1() { } @Test - @DisplayName("get getSearchesNoResults with minimal parameters") - void getSearchesNoResultsTest0() { + @DisplayName("get getConversationRate with minimal parameters") + void getConversationRateTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoResults(index0); + return client.getConversationRate(index0); } ); - assertEquals(req.getPath(), "/2/searches/noResults"); + assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -399,37 +409,26 @@ void getSearchesNoResultsTest0() { } @Test - @DisplayName("get getSearchesNoResults with all parameters") - void getSearchesNoResultsTest1() { + @DisplayName("get getConversationRate with all parameters") + void getConversationRateTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; - int limit0 = 21; - - int offset0 = 42; - String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoResults( - index0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); + return client.getConversationRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/searches/noResults"); + assertEquals(req.getPath(), "/2/conversions/conversionRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -451,16 +450,16 @@ void getSearchesNoResultsTest1() { } @Test - @DisplayName("get getStatus with minimal parameters") - void getStatusTest0() { + @DisplayName("get getNoClickRate with minimal parameters") + void getNoClickRateTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getStatus(index0); + return client.getNoClickRate(index0); } ); - assertEquals(req.getPath(), "/2/status"); + assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -486,20 +485,26 @@ void getStatusTest0() { } @Test - @DisplayName("get getClickPositions with minimal parameters") - void getClickPositionsTest0() { + @DisplayName("get getNoClickRate with all parameters") + void getNoClickRateTest1() { String index0 = "index"; + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + String tags0 = "tag"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickPositions(index0); + return client.getNoClickRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/clicks/positions"); + assertEquals(req.getPath(), "/2/searches/noClickRate"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -521,26 +526,20 @@ void getClickPositionsTest0() { } @Test - @DisplayName("get getClickPositions with all parameters") - void getClickPositionsTest1() { + @DisplayName("get getNoResultsRate with minimal parameters") + void getNoResultsRateTest0() { String index0 = "index"; - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; - - String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickPositions(index0, startDate0, endDate0, tags0); + return client.getNoResultsRate(index0); } ); - assertEquals(req.getPath(), "/2/clicks/positions"); + 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\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -562,56 +561,26 @@ void getClickPositionsTest1() { } @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"; + @DisplayName("get getNoResultsRate with all parameters") + void getNoResultsRateTest1() { + String index0 = "index"; - parameters0.put("query", query1); - } + String startDate0 = "1999-09-19"; - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; + String endDate0 = "2001-01-01"; - body0.put("body", body1); - } + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); + return client.getNoResultsRate(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/2/searches/noResultRate"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -633,18 +602,16 @@ void putTest1() { } @Test - @DisplayName("get getTopFilterForAttribute with minimal parameters") - void getTopFilterForAttributeTest0() { - String attribute0 = "myAttribute"; - + @DisplayName("get getSearchesCount with minimal parameters") + void getSearchesCountTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute(attribute0, index0); + return client.getSearchesCount(index0); } ); - assertEquals(req.getPath(), "/2/filters/myAttribute"); + assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -670,24 +637,26 @@ void getTopFilterForAttributeTest0() { } @Test - @DisplayName( - "get getTopFilterForAttribute with minimal parameters and multiple attributes" - ) - void getTopFilterForAttributeTest1() { - String attribute0 = "myAttribute1,myAttribute2"; - + @DisplayName("get getSearchesCount with all parameters") + void getSearchesCountTest1() { String index0 = "index"; + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + String tags0 = "tag"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute(attribute0, index0); + return client.getSearchesCount(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); + assertEquals(req.getPath(), "/2/searches/count"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -709,43 +678,20 @@ void getTopFilterForAttributeTest1() { } @Test - @DisplayName("get getTopFilterForAttribute with all parameters") - void getTopFilterForAttributeTest2() { - String attribute0 = "myAttribute"; - - String index0 = "index"; - - String search0 = "mySearch"; - - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; - - int limit0 = 21; - - int offset0 = 42; - - String tags0 = "tag"; + @DisplayName("get getSearchesNoClicks with minimal parameters") + void getSearchesNoClicksTest0() { + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute( - attribute0, - index0, - search0, - startDate0, - endDate0, - limit0, - offset0, - tags0 - ); + return client.getSearchesNoClicks(index0); } ); - assertEquals(req.getPath(), "/2/filters/myAttribute"); + assertEquals(req.getPath(), "/2/searches/noClicks"); 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\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -767,16 +713,10 @@ void getTopFilterForAttributeTest2() { } @Test - @DisplayName( - "get getTopFilterForAttribute with all parameters and multiple attributes" - ) - void getTopFilterForAttributeTest3() { - String attribute0 = "myAttribute1,myAttribute2"; - + @DisplayName("get getSearchesNoClicks with all parameters") + void getSearchesNoClicksTest1() { String index0 = "index"; - String search0 = "mySearch"; - String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; @@ -788,10 +728,8 @@ void getTopFilterForAttributeTest3() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterForAttribute( - attribute0, + return client.getSearchesNoClicks( index0, - search0, startDate0, endDate0, limit0, @@ -801,11 +739,11 @@ void getTopFilterForAttributeTest3() { } ); - assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); + assertEquals(req.getPath(), "/2/searches/noClicks"); 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\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -827,16 +765,16 @@ void getTopFilterForAttributeTest3() { } @Test - @DisplayName("get getNoClickRate with minimal parameters") - void getNoClickRateTest0() { + @DisplayName("get getSearchesNoResults with minimal parameters") + void getSearchesNoResultsTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoClickRate(index0); + return client.getSearchesNoResults(index0); } ); - assertEquals(req.getPath(), "/2/searches/noClickRate"); + assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -862,61 +800,37 @@ void getNoClickRateTest0() { } @Test - @DisplayName("get getNoClickRate with all parameters") - void getNoClickRateTest1() { + @DisplayName("get getSearchesNoResults with all parameters") + void getSearchesNoResultsTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; - String tags0 = "tag"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoClickRate(index0, startDate0, endDate0, tags0); - } - ); - - assertEquals(req.getPath(), "/2/searches/noClickRate"); - assertEquals(req.getMethod(), "GET"); + int limit0 = 21; - Map 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" - ); - } - } + int offset0 = 42; - @Test - @DisplayName("get getUsersCount with minimal parameters") - void getUsersCountTest0() { - String index0 = "index"; + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUsersCount(index0); + return client.getSearchesNoResults( + index0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/users/count"); + assertEquals(req.getPath(), "/2/searches/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -938,26 +852,20 @@ void getUsersCountTest0() { } @Test - @DisplayName("get getUsersCount with all parameters") - void getUsersCountTest1() { + @DisplayName("get getStatus with minimal parameters") + void getStatusTest0() { String index0 = "index"; - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; - - String tags0 = "tag"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUsersCount(index0, startDate0, endDate0, tags0); + return client.getStatus(index0); } ); - assertEquals(req.getPath(), "/2/users/count"); + assertEquals(req.getPath(), "/2/status"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -979,16 +887,16 @@ void getUsersCountTest1() { } @Test - @DisplayName("get getSearchesNoClicks with minimal parameters") - void getSearchesNoClicksTest0() { + @DisplayName("get getTopCountries with minimal parameters") + void getTopCountriesTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoClicks(index0); + return client.getTopCountries(index0); } ); - assertEquals(req.getPath(), "/2/searches/noClicks"); + assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1014,8 +922,8 @@ void getSearchesNoClicksTest0() { } @Test - @DisplayName("get getSearchesNoClicks with all parameters") - void getSearchesNoClicksTest1() { + @DisplayName("get getTopCountries with all parameters") + void getTopCountriesTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; @@ -1029,7 +937,7 @@ void getSearchesNoClicksTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesNoClicks( + return client.getTopCountries( index0, startDate0, endDate0, @@ -1040,7 +948,7 @@ void getSearchesNoClicksTest1() { } ); - assertEquals(req.getPath(), "/2/searches/noClicks"); + assertEquals(req.getPath(), "/2/countries"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1066,56 +974,20 @@ void getSearchesNoClicksTest1() { } @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); - } + @DisplayName("get getTopFilterAttributes with minimal parameters") + void getTopFilterAttributesTest0() { + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0, parameters0, body0); + return client.getTopFilterAttributes(index0); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/2/filters"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1137,20 +1009,40 @@ void postTest1() { } @Test - @DisplayName("get getAverageClickPosition with minimal parameters") - void getAverageClickPositionTest0() { + @DisplayName("get getTopFilterAttributes with all parameters") + void getTopFilterAttributesTest1() { String index0 = "index"; + String search0 = "mySearch"; + + String startDate0 = "1999-09-19"; + + String endDate0 = "2001-01-01"; + + int limit0 = 21; + + int offset0 = 42; + + String tags0 = "tag"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAverageClickPosition(index0); + return client.getTopFilterAttributes( + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); + assertEquals(req.getPath(), "/2/filters"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\"}", + "{\"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(); @@ -1172,31 +1064,22 @@ void getAverageClickPositionTest0() { } @Test - @DisplayName("get getAverageClickPosition with all parameters") - void getAverageClickPositionTest1() { - String index0 = "index"; - - String startDate0 = "1999-09-19"; - - String endDate0 = "2001-01-01"; + @DisplayName("get getTopFilterForAttribute with minimal parameters") + void getTopFilterForAttributeTest0() { + String attribute0 = "myAttribute"; - String tags0 = "tag"; + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAverageClickPosition( - index0, - startDate0, - endDate0, - tags0 - ); + return client.getTopFilterForAttribute(attribute0, index0); } ); - assertEquals(req.getPath(), "/2/clicks/averageClickPosition"); + assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"index\":\"index\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1218,16 +1101,20 @@ void getAverageClickPositionTest1() { } @Test - @DisplayName("get getSearchesCount with minimal parameters") - void getSearchesCountTest0() { + @DisplayName( + "get getTopFilterForAttribute with minimal parameters and multiple attributes" + ) + void getTopFilterForAttributeTest1() { + String attribute0 = "myAttribute1,myAttribute2"; + String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesCount(index0); + return client.getTopFilterForAttribute(attribute0, index0); } ); - assertEquals(req.getPath(), "/2/searches/count"); + assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1253,26 +1140,43 @@ void getSearchesCountTest0() { } @Test - @DisplayName("get getSearchesCount with all parameters") - void getSearchesCountTest1() { + @DisplayName("get getTopFilterForAttribute with all parameters") + void getTopFilterForAttributeTest2() { + String attribute0 = "myAttribute"; + String index0 = "index"; + String search0 = "mySearch"; + String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; + int limit0 = 21; + + int offset0 = 42; + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSearchesCount(index0, startDate0, endDate0, tags0); + return client.getTopFilterForAttribute( + attribute0, + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/searches/count"); + assertEquals(req.getPath(), "/2/filters/myAttribute"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"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(); @@ -1294,41 +1198,45 @@ void getSearchesCountTest1() { } @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; + @DisplayName( + "get getTopFilterForAttribute with all parameters and multiple attributes" + ) + void getTopFilterForAttributeTest3() { + String attribute0 = "myAttribute1,myAttribute2"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); + String index0 = "index"; - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - } + String search0 = "mySearch"; - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; + String startDate0 = "1999-09-19"; - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; + String endDate0 = "2001-01-01"; - parameters0.put("query", query1); - } + int limit0 = 21; + + int offset0 = 42; + + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); + return client.getTopFilterForAttribute( + attribute0, + index0, + search0, + startDate0, + endDate0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getPath(), "/2/filters/myAttribute1%2CmyAttribute2"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"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(); @@ -1350,16 +1258,16 @@ void getTest1() { } @Test - @DisplayName("get getTopFilterAttributes with minimal parameters") - void getTopFilterAttributesTest0() { + @DisplayName("get getTopFiltersNoResults with minimal parameters") + void getTopFiltersNoResultsTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterAttributes(index0); + return client.getTopFiltersNoResults(index0); } ); - assertEquals(req.getPath(), "/2/filters"); + assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1385,8 +1293,8 @@ void getTopFilterAttributesTest0() { } @Test - @DisplayName("get getTopFilterAttributes with all parameters") - void getTopFilterAttributesTest1() { + @DisplayName("get getTopFiltersNoResults with all parameters") + void getTopFiltersNoResultsTest1() { String index0 = "index"; String search0 = "mySearch"; @@ -1402,7 +1310,7 @@ void getTopFilterAttributesTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopFilterAttributes( + return client.getTopFiltersNoResults( index0, search0, startDate0, @@ -1414,7 +1322,7 @@ void getTopFilterAttributesTest1() { } ); - assertEquals(req.getPath(), "/2/filters"); + assertEquals(req.getPath(), "/2/filters/noResults"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1440,16 +1348,16 @@ void getTopFilterAttributesTest1() { } @Test - @DisplayName("get getTopCountries with minimal parameters") - void getTopCountriesTest0() { + @DisplayName("get getTopHits with minimal parameters") + void getTopHitsTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopCountries(index0); + return client.getTopHits(index0); } ); - assertEquals(req.getPath(), "/2/countries"); + assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1475,10 +1383,14 @@ void getTopCountriesTest0() { } @Test - @DisplayName("get getTopCountries with all parameters") - void getTopCountriesTest1() { + @DisplayName("get getTopHits with all parameters") + void getTopHitsTest1() { String index0 = "index"; + String search0 = "mySearch"; + + boolean clickAnalytics0 = true; + String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; @@ -1490,8 +1402,10 @@ void getTopCountriesTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopCountries( + return client.getTopHits( index0, + search0, + clickAnalytics0, startDate0, endDate0, limit0, @@ -1501,11 +1415,11 @@ void getTopCountriesTest1() { } ); - assertEquals(req.getPath(), "/2/countries"); + assertEquals(req.getPath(), "/2/hits"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}", + "{\"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(); @@ -1527,16 +1441,16 @@ void getTopCountriesTest1() { } @Test - @DisplayName("get getConversationRate with minimal parameters") - void getConversationRateTest0() { + @DisplayName("get getTopSearches with minimal parameters") + void getTopSearchesTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConversationRate(index0); + return client.getTopSearches(index0); } ); - assertEquals(req.getPath(), "/2/conversions/conversionRate"); + assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1562,26 +1476,46 @@ void getConversationRateTest0() { } @Test - @DisplayName("get getConversationRate with all parameters") - void getConversationRateTest1() { + @DisplayName("get getTopSearches with all parameters") + void getTopSearchesTest1() { String index0 = "index"; + boolean clickAnalytics0 = true; + String startDate0 = "1999-09-19"; String endDate0 = "2001-01-01"; + OrderBy orderBy0 = OrderBy.fromValue("searchCount"); + + Direction direction0 = Direction.fromValue("asc"); + + int limit0 = 21; + + int offset0 = 42; + String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConversationRate(index0, startDate0, endDate0, tags0); + return client.getTopSearches( + index0, + clickAnalytics0, + startDate0, + endDate0, + orderBy0, + direction0, + limit0, + offset0, + tags0 + ); } ); - assertEquals(req.getPath(), "/2/conversions/conversionRate"); + assertEquals(req.getPath(), "/2/searches"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"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(); @@ -1603,16 +1537,16 @@ void getConversationRateTest1() { } @Test - @DisplayName("get getNoResultsRate with minimal parameters") - void getNoResultsRateTest0() { + @DisplayName("get getUsersCount with minimal parameters") + void getUsersCountTest0() { String index0 = "index"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoResultsRate(index0); + return client.getUsersCount(index0); } ); - assertEquals(req.getPath(), "/2/searches/noResultRate"); + assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1638,8 +1572,8 @@ void getNoResultsRateTest0() { } @Test - @DisplayName("get getNoResultsRate with all parameters") - void getNoResultsRateTest1() { + @DisplayName("get getUsersCount with all parameters") + void getUsersCountTest1() { String index0 = "index"; String startDate0 = "1999-09-19"; @@ -1649,11 +1583,11 @@ void getNoResultsRateTest1() { String tags0 = "tag"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getNoResultsRate(index0, startDate0, endDate0, tags0); + return client.getUsersCount(index0, startDate0, endDate0, tags0); } ); - assertEquals(req.getPath(), "/2/searches/noResultRate"); + assertEquals(req.getPath(), "/2/users/count"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( @@ -1679,20 +1613,56 @@ void getNoResultsRateTest1() { } @Test - @DisplayName("get getClickThroughRate with minimal parameters") - void getClickThroughRateTest0() { - String index0 = "index"; + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getClickThroughRate(index0); + return client.post(path0); } ); - assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); - assertEquals(req.getMethod(), "GET"); + 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( - "{\"index\":\"index\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1714,26 +1684,56 @@ void getClickThroughRateTest0() { } @Test - @DisplayName("get getClickThroughRate with all parameters") - void getClickThroughRateTest1() { - String index0 = "index"; + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; - String startDate0 = "1999-09-19"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.put(path0); + } + ); - String endDate0 = "2001-01-01"; + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); + } - String tags0 = "tag"; + @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.getClickThroughRate(index0, startDate0, endDate0, tags0); + return client.put(path0, parameters0, body0); } ); - assertEquals(req.getPath(), "/2/clicks/clickThroughRate"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); 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 36c6437e72..426a5b7c76 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 @@ -29,22 +29,22 @@ void init() { } @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -54,28 +54,13 @@ void postTest1() { 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); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -155,6 +140,77 @@ void getTest1() { } } + @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("pushEvents") void pushEventsTest0() { @@ -299,62 +355,6 @@ void pushEventsTest0() { }); } - @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("allow put method for a custom path with minimal parameters") void putTest0() { 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 43f109f002..0d53385e91 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 @@ -29,36 +29,22 @@ void init() { } @Test - @DisplayName("delete deleteUserProfile") - void deleteUserProfileTest0() { - String userToken0 = "UserToken"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteUserProfile(userToken0); - } - ); - - assertEquals(req.getPath(), "/1/profiles/UserToken"); - assertEquals(req.getMethod(), "DELETE"); - } - - @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -68,28 +54,13 @@ void postTest1() { 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); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -113,6 +84,20 @@ void postTest1() { } } + @Test + @DisplayName("delete deleteUserProfile") + void deleteUserProfileTest0() { + String userToken0 = "UserToken"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteUserProfile(userToken0); + } + ); + + assertEquals(req.getPath(), "/1/profiles/UserToken"); + assertEquals(req.getMethod(), "DELETE"); + } + @Test @DisplayName("allow get method for a custom path with minimal parameters") void getTest0() { @@ -182,22 +167,36 @@ void getPersonalizationStrategyTest0() { } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("get getUserTokenProfile") + void getUserTokenProfileTest0() { + String userToken0 = "UserToken"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getUserTokenProfile(userToken0); + } + ); + + assertEquals(req.getPath(), "/1/profiles/personalization/UserToken"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.post(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -207,13 +206,28 @@ void delTest1() { parameters0.put("query", query1); } + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; + + body0.put("body", body1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.post(path0, parameters0, body0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -238,17 +252,74 @@ void delTest1() { } @Test - @DisplayName("get getUserTokenProfile") - void getUserTokenProfileTest0() { - String userToken0 = "UserToken"; + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUserTokenProfile(userToken0); + return client.put(path0); } ); - assertEquals(req.getPath(), "/1/profiles/personalization/UserToken"); - assertEquals(req.getMethod(), "GET"); + 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 @@ -314,75 +385,4 @@ void setPersonalizationStrategyTest0() { ); }); } - - @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" - ); - } - } } 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 017f746842..a0fd0c2093 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 @@ -29,97 +29,14 @@ void init() { } @Test - @DisplayName("deleteConfig") - void deleteConfigTest0() { - String indexName0 = "theIndexName"; - - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteConfig(indexName0); - } - ); - - assertEquals(req.getPath(), "/1/configs/theIndexName"); - assertEquals(req.getMethod(), "DELETE"); - } - - @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<>(); + @DisplayName("createConfig") + void createConfigTest0() { + QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = new QuerySuggestionsIndexWithIndexParam(); { - 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" - ); - } - } + String indexName1 = "theIndexName"; - @Test - @DisplayName("updateConfig") - void updateConfigTest0() { - String indexName0 = "theIndexName"; + querySuggestionsIndexWithIndexParam0.setIndexName(indexName1); - QuerySuggestionsIndexParam querySuggestionsIndexParam0 = new QuerySuggestionsIndexParam(); - { List sourceIndices1 = new ArrayList<>(); { SourceIndex sourceIndices_02 = new SourceIndex(); @@ -165,7 +82,7 @@ void updateConfigTest0() { } sourceIndices1.add(sourceIndices_02); } - querySuggestionsIndexParam0.setSourceIndices(sourceIndices1); + querySuggestionsIndexWithIndexParam0.setSourceIndices(sourceIndices1); List languages1 = new ArrayList<>(); { @@ -173,7 +90,7 @@ void updateConfigTest0() { languages1.add(languages_02); } - querySuggestionsIndexParam0.setLanguages(languages1); + querySuggestionsIndexWithIndexParam0.setLanguages(languages1); List exclude1 = new ArrayList<>(); { @@ -181,20 +98,20 @@ void updateConfigTest0() { exclude1.add(exclude_02); } - querySuggestionsIndexParam0.setExclude(exclude1); + querySuggestionsIndexWithIndexParam0.setExclude(exclude1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.updateConfig(indexName0, querySuggestionsIndexParam0); + return client.createConfig(querySuggestionsIndexWithIndexParam0); } ); - assertEquals(req.getPath(), "/1/configs/theIndexName"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/configs"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", + "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -202,22 +119,22 @@ void updateConfigTest0() { } @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -228,12 +145,12 @@ void getTest1() { } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -258,112 +175,36 @@ void getTest1() { } @Test - @DisplayName("createConfig") - void createConfigTest0() { - QuerySuggestionsIndexWithIndexParam querySuggestionsIndexWithIndexParam0 = new QuerySuggestionsIndexWithIndexParam(); - { - String indexName1 = "theIndexName"; - - querySuggestionsIndexWithIndexParam0.setIndexName(indexName1); - - List sourceIndices1 = new ArrayList<>(); - { - SourceIndex sourceIndices_02 = new SourceIndex(); - { - String indexName3 = "testIndex"; - - sourceIndices_02.setIndexName(indexName3); - - List facets3 = new ArrayList<>(); - { - Map facets_04 = new HashMap<>(); - { - String attributes5 = "test"; - - facets_04.put("attributes", attributes5); - } - facets3.add(facets_04); - } - sourceIndices_02.setFacets(facets3); - - List> generate3 = new ArrayList<>(); - { - List generate_04 = new ArrayList<>(); - { - String generate_0_05 = "facetA"; - - generate_04.add(generate_0_05); - String generate_0_15 = "facetB"; - - generate_04.add(generate_0_15); - } - generate3.add(generate_04); - - List generate_14 = new ArrayList<>(); - { - String generate_1_05 = "facetC"; - - generate_14.add(generate_1_05); - } - generate3.add(generate_14); - } - sourceIndices_02.setGenerate(generate3); - } - sourceIndices1.add(sourceIndices_02); - } - querySuggestionsIndexWithIndexParam0.setSourceIndices(sourceIndices1); - - List languages1 = new ArrayList<>(); - { - String languages_02 = "french"; - - languages1.add(languages_02); - } - querySuggestionsIndexWithIndexParam0.setLanguages(languages1); - - List exclude1 = new ArrayList<>(); - { - String exclude_02 = "test"; - - exclude1.add(exclude_02); - } - querySuggestionsIndexWithIndexParam0.setExclude(exclude1); - } + @DisplayName("deleteConfig") + void deleteConfigTest0() { + String indexName0 = "theIndexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.createConfig(querySuggestionsIndexWithIndexParam0); + return client.deleteConfig(indexName0); } ); - 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 - ); - }); + assertEquals(req.getPath(), "/1/configs/theIndexName"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0); + return client.get(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("allow del method for a custom path with all parameters") - void delTest1() { + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -374,12 +215,12 @@ void delTest1() { } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.get(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -403,6 +244,32 @@ void delTest1() { } } + @Test + @DisplayName("getAllConfigs") + void getAllConfigsTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getAllConfigs(); + } + ); + + assertEquals(req.getPath(), "/1/configs"); + assertEquals(req.getMethod(), "GET"); + } + + @Test + @DisplayName("getConfig") + void getConfigTest0() { + String indexName0 = "theIndexName"; + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getConfig(indexName0); + } + ); + + assertEquals(req.getPath(), "/1/configs/theIndexName"); + assertEquals(req.getMethod(), "GET"); + } + @Test @DisplayName("getConfigStatus") void getConfigStatusTest0() { @@ -418,29 +285,88 @@ void getConfigStatusTest0() { } @Test - @DisplayName("getAllConfigs") - void getAllConfigsTest0() { + @DisplayName("getLogFile") + void getLogFileTest0() { + String indexName0 = "theIndexName"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getAllConfigs(); + return client.getLogFile(indexName0); } ); - assertEquals(req.getPath(), "/1/configs"); + assertEquals(req.getPath(), "/1/logs/theIndexName"); assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("getConfig") - void getConfigTest0() { - String indexName0 = "theIndexName"; + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getConfig(indexName0); + return client.post(path0); } ); - assertEquals(req.getPath(), "/1/configs/theIndexName"); - assertEquals(req.getMethod(), "GET"); + 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 @@ -515,16 +441,90 @@ void putTest1() { } @Test - @DisplayName("getLogFile") - void getLogFileTest0() { + @DisplayName("updateConfig") + void updateConfigTest0() { String indexName0 = "theIndexName"; + QuerySuggestionsIndexParam querySuggestionsIndexParam0 = new QuerySuggestionsIndexParam(); + { + List sourceIndices1 = new ArrayList<>(); + { + SourceIndex sourceIndices_02 = new SourceIndex(); + { + String indexName3 = "testIndex"; + + sourceIndices_02.setIndexName(indexName3); + + List facets3 = new ArrayList<>(); + { + Map facets_04 = new HashMap<>(); + { + String attributes5 = "test"; + + facets_04.put("attributes", attributes5); + } + facets3.add(facets_04); + } + sourceIndices_02.setFacets(facets3); + + List> generate3 = new ArrayList<>(); + { + List generate_04 = new ArrayList<>(); + { + String generate_0_05 = "facetA"; + + generate_04.add(generate_0_05); + String generate_0_15 = "facetB"; + + generate_04.add(generate_0_15); + } + generate3.add(generate_04); + + List generate_14 = new ArrayList<>(); + { + String generate_1_05 = "facetC"; + + generate_14.add(generate_1_05); + } + generate3.add(generate_14); + } + sourceIndices_02.setGenerate(generate3); + } + sourceIndices1.add(sourceIndices_02); + } + querySuggestionsIndexParam0.setSourceIndices(sourceIndices1); + + List languages1 = new ArrayList<>(); + { + String languages_02 = "french"; + + languages1.add(languages_02); + } + querySuggestionsIndexParam0.setLanguages(languages1); + + List exclude1 = new ArrayList<>(); + { + String exclude_02 = "test"; + + exclude1.add(exclude_02); + } + querySuggestionsIndexParam0.setExclude(exclude1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogFile(indexName0); + return client.updateConfig(indexName0, querySuggestionsIndexParam0); } ); - assertEquals(req.getPath(), "/1/logs/theIndexName"); - assertEquals(req.getMethod(), "GET"); + 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 + ); + }); } } 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 abeea99e42..bbc86aeda7 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 @@ -29,22 +29,22 @@ void init() { } @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { + @DisplayName("allow del method for a custom path with minimal parameters") + void delTest0() { String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.post(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -54,28 +54,13 @@ void postTest1() { 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); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -155,62 +140,6 @@ void getTest1() { } } - @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( "get recommendations for recommend model with minimal parameters" @@ -761,6 +690,77 @@ void getRecommendationsTest6() { }); } + @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() { 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 dd2c53e855..b165e0b4c2 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 @@ -29,105 +29,147 @@ void init() { } @Test - @DisplayName("batchAssignUserIds") - void batchAssignUserIdsTest0() { - String xAlgoliaUserID0 = "userID"; - - BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); + @DisplayName("addApiKey") + void addApiKeyTest0() { + ApiKey apiKey0 = new ApiKey(); { - String cluster1 = "theCluster"; - - batchAssignUserIdsParams0.setCluster(cluster1); - - List users1 = new ArrayList<>(); + List acl1 = new ArrayList<>(); { - String users_02 = "user1"; + Acl acl_02 = Acl.fromValue("search"); - users1.add(users_02); - String users_12 = "user2"; + acl1.add(acl_02); - users1.add(users_12); + Acl acl_12 = Acl.fromValue("addObject"); + + acl1.add(acl_12); } - batchAssignUserIdsParams0.setUsers(users1); + apiKey0.setAcl(acl1); + String description1 = "my new api key"; + + apiKey0.setDescription(description1); + + int validity1 = 300; + + apiKey0.setValidity(validity1); + + int maxQueriesPerIPPerHour1 = 100; + + apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); + + int maxHitsPerQuery1 = 20; + + apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batchAssignUserIds( - xAlgoliaUserID0, - batchAssignUserIdsParams0 - ); + return client.addApiKey(apiKey0); } ); - assertEquals(req.getPath(), "/1/clusters/mapping/batch"); + assertEquals(req.getPath(), "/1/keys"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", + "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api" + + " key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", 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; - } + @Test + @DisplayName("addOrUpdateObject") + void addOrUpdateObjectTest0() { + String indexName0 = "indexName"; + + String objectID0 = "uniqueID"; + + Map body0 = new HashMap<>(); + { + String key1 = "value"; + + body0.put("key", key1); + } + + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.addOrUpdateObject(indexName0, objectID0, body0); } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" + ); + + assertEquals(req.getPath(), "/1/indexes/indexName/uniqueID"); + assertEquals(req.getMethod(), "PUT"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"key\":\"value\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER ); - } + }); } @Test - @DisplayName("allow del method for a custom path with minimal parameters") - void delTest0() { - String path0 = "/test/minimal"; + @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.del(path0); + return client.appendSource(source0); } ); - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "DELETE"); + 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("allow del method for a custom path with all parameters") - void delTest1() { - String path0 = "/test/all"; + @DisplayName("assignUserId") + void assignUserIdTest0() { + String xAlgoliaUserID0 = "userID"; - Map parameters0 = new HashMap<>(); + AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); { - String query1 = "parameters"; + String cluster1 = "theCluster"; - parameters0.put("query", query1); + assignUserIdParams0.setCluster(cluster1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.del(path0, parameters0); + return client.assignUserId(xAlgoliaUserID0, assignUserIdParams0); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/1/clusters/mapping"); + assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"cluster\":\"theCluster\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -149,28 +191,44 @@ void delTest1() { } @Test - @DisplayName("searchRules") - void searchRulesTest0() { - String indexName0 = "indexName"; + @DisplayName("batch") + void batchTest0() { + String indexName0 = "theIndexName"; - SearchRulesParams searchRulesParams0 = new SearchRulesParams(); + BatchWriteParams batchWriteParams0 = new BatchWriteParams(); { - String query1 = "something"; + List requests1 = new ArrayList<>(); + { + BatchOperation requests_02 = new BatchOperation(); + { + Action action3 = Action.fromValue("delete"); - searchRulesParams0.setQuery(query1); + 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.searchRules(indexName0, searchRulesParams0); + return client.batch(indexName0, batchWriteParams0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"something\"}", + "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -178,70 +236,49 @@ void searchRulesTest0() { } @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("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"; + @DisplayName("batchAssignUserIds") + void batchAssignUserIdsTest0() { + String xAlgoliaUserID0 = "userID"; - Map parameters0 = new HashMap<>(); + BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); { - String query1 = "parameters"; + String cluster1 = "theCluster"; - parameters0.put("query", query1); - } + batchAssignUserIdsParams0.setCluster(cluster1); - Map body0 = new HashMap<>(); - { - String body1 = "parameters"; + List users1 = new ArrayList<>(); + { + String users_02 = "user1"; - body0.put("body", body1); + users1.add(users_02); + String users_12 = "user2"; + + users1.add(users_12); + } + batchAssignUserIdsParams0.setUsers(users1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.put(path0, parameters0, body0); + return client.batchAssignUserIds( + xAlgoliaUserID0, + batchAssignUserIdsParams0 + ); } ); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/clusters/mapping/batch"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", + "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); Map expectedQuery = JSON.deserialize( - "{\"query\":\"parameters\"}", + "{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -262,55 +299,6 @@ void putTest1() { } } - @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 - ); - }); - } - @Test @DisplayName("get batchDictionaryEntries results with minimal parameters") void batchDictionaryEntriesTest0() { @@ -647,36 +635,110 @@ void batchRulesTest0() { } @Test - @DisplayName("restoreApiKey") - void restoreApiKeyTest0() { - String key0 = "myApiKey"; + @DisplayName("get browse results with minimal parameters") + void browseTest0() { + String indexName0 = "indexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.restoreApiKey(key0); + return client.browse(indexName0); } ); - assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); + assertEquals(req.getPath(), "/1/indexes/indexName/browse"); assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("allow post method for a custom path with minimal parameters") - void postTest0() { + @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.post(path0); + return client.del(path0); } ); assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("allow post method for a custom path with all parameters") - void postTest1() { + @DisplayName("allow del method for a custom path with all parameters") + void delTest1() { String path0 = "/test/all"; Map parameters0 = new HashMap<>(); @@ -686,28 +748,13 @@ void postTest1() { 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); + return client.del(path0, parameters0); } ); assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "POST"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"body\":\"parameters\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getMethod(), "DELETE"); Map expectedQuery = JSON.deserialize( "{\"query\":\"parameters\"}", @@ -732,51 +779,65 @@ void postTest1() { } @Test - @DisplayName("multipleBatch") - void multipleBatchTest0() { - BatchParams batchParams0 = new BatchParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleBatchOperation requests_02 = new MultipleBatchOperation(); - { - Action action3 = Action.fromValue("addObject"); + @DisplayName("deleteApiKey") + void deleteApiKeyTest0() { + String key0 = "myTestApiKey"; - requests_02.setAction(action3); + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.deleteApiKey(key0); + } + ); - Map body3 = new HashMap<>(); - { - String key4 = "value"; + assertEquals(req.getPath(), "/1/keys/myTestApiKey"); + assertEquals(req.getMethod(), "DELETE"); + } - body3.put("key", key4); - } - requests_02.setBody(body3); - String indexName3 = "theIndexName"; + @Test + @DisplayName("deleteBy") + void deleteByTest0() { + String indexName0 = "theIndexName"; - requests_02.setIndexName(indexName3); - } - requests1.add(requests_02); - } - batchParams0.setRequests(requests1); + SearchParamsObject searchParams0 = new SearchParamsObject(); + { + String query1 = "testQuery"; + + searchParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.multipleBatch(batchParams0); + return client.deleteBy( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); } ); - assertEquals(req.getPath(), "/1/indexes/*/batch"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", + "{\"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() { @@ -794,118 +855,87 @@ void deleteObjectTest0() { } @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; + @DisplayName("deleteRule") + void deleteRuleTest0() { + String indexName0 = "indexName"; - searchUserIdsParams0.setHitsPerPage(hitsPerPage1); - } + String objectID0 = "id1"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchUserIds(searchUserIdsParams0); + return client.deleteRule(indexName0, objectID0); } ); - assertEquals(req.getPath(), "/1/clusters/mapping/search"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "DELETE"); + } - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + @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("replaceSources") - void replaceSourcesTest0() { - List source0 = new ArrayList<>(); - { - Source source_01 = new Source(); - { - String source2 = "theSource"; - - source_01.setSource(source2); - String description2 = "theDescription"; + @DisplayName("deleteSynonym") + void deleteSynonymTest0() { + String indexName0 = "indexName"; - source_01.setDescription(description2); - } - source0.add(source_01); - } + String objectID0 = "id1"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.replaceSources(source0); + return client.deleteSynonym(indexName0, objectID0); } ); - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "PUT"); - - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "DELETE"); } @Test - @DisplayName("removeUserId") - void removeUserIdTest0() { - String userID0 = "uniqueID"; + @DisplayName("allow get method for a custom path with minimal parameters") + void getTest0() { + String path0 = "/test/minimal"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.removeUserId(userID0); + return client.get(path0); } ); - assertEquals(req.getPath(), "/1/clusters/mapping/uniqueID"); - assertEquals(req.getMethod(), "DELETE"); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("getObject") - void getObjectTest0() { - String indexName0 = "theIndexName"; - - String objectID0 = "uniqueID"; + @DisplayName("allow get method for a custom path with all parameters") + void getTest1() { + String path0 = "/test/all"; - List attributesToRetrieve0 = new ArrayList<>(); + Map parameters0 = new HashMap<>(); { - String attributesToRetrieve_01 = "attr1"; - - attributesToRetrieve0.add(attributesToRetrieve_01); - String attributesToRetrieve_11 = "attr2"; + String query1 = "parameters"; - attributesToRetrieve0.add(attributesToRetrieve_11); + parameters0.put("query", query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObject(indexName0, objectID0, attributesToRetrieve0); + return client.get(path0, parameters0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); + assertEquals(req.getPath(), "/1/test/all"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"attributesToRetrieve\":\"attr1,attr2\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -941,35 +971,50 @@ void getApiKeyTest0() { } @Test - @DisplayName("assignUserId") - void assignUserIdTest0() { - String xAlgoliaUserID0 = "userID"; - - AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); - { - String cluster1 = "theCluster"; + @DisplayName("get getDictionaryLanguages") + void getDictionaryLanguagesTest0() { + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getDictionaryLanguages(); + } + ); - assignUserIdParams0.setCluster(cluster1); - } + assertEquals(req.getPath(), "/1/dictionaries/*/languages"); + assertEquals(req.getMethod(), "GET"); + } + @Test + @DisplayName("get getDictionarySettings results") + void getDictionarySettingsTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.assignUserId(xAlgoliaUserID0, assignUserIdParams0); + return client.getDictionarySettings(); } ); - assertEquals(req.getPath(), "/1/clusters/mapping"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "GET"); + } - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"cluster\":\"theCluster\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + @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( - "{\"X-Algolia-User-ID\":\"userID\"}", + "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -991,56 +1036,32 @@ void assignUserIdTest0() { } @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("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"); - } + @DisplayName("getObject") + void getObjectTest0() { + String indexName0 = "theIndexName"; - @Test - @DisplayName("getLogs") - void getLogsTest0() { - int offset0 = 5; + String objectID0 = "uniqueID"; - int length0 = 10; + List attributesToRetrieve0 = new ArrayList<>(); + { + String attributesToRetrieve_01 = "attr1"; - String indexName0 = "theIndexName"; + attributesToRetrieve0.add(attributesToRetrieve_01); + String attributesToRetrieve_11 = "attr2"; - LogType type0 = LogType.fromValue("all"); + attributesToRetrieve0.add(attributesToRetrieve_11); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogs(offset0, length0, indexName0, type0); + return client.getObject(indexName0, objectID0, attributesToRetrieve0); } ); - assertEquals(req.getPath(), "/1/logs"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); assertEquals(req.getMethod(), "GET"); Map expectedQuery = JSON.deserialize( - "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", + "{\"attributesToRetrieve\":\"attr1,attr2\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1062,44 +1083,47 @@ void getLogsTest0() { } @Test - @DisplayName("batch") - void batchTest0() { - String indexName0 = "theIndexName"; - - BatchWriteParams batchWriteParams0 = new BatchWriteParams(); + @DisplayName("getObjects") + void getObjectsTest0() { + GetObjectsParams getObjectsParams0 = new GetObjectsParams(); { - List requests1 = new ArrayList<>(); + List requests1 = new ArrayList<>(); { - BatchOperation requests_02 = new BatchOperation(); + MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); { - Action action3 = Action.fromValue("delete"); - - requests_02.setAction(action3); - - Map body3 = new HashMap<>(); + List attributesToRetrieve3 = new ArrayList<>(); { - String key4 = "value"; + String attributesToRetrieve_04 = "attr1"; - body3.put("key", key4); + attributesToRetrieve3.add(attributesToRetrieve_04); + String attributesToRetrieve_14 = "attr2"; + + attributesToRetrieve3.add(attributesToRetrieve_14); } - requests_02.setBody(body3); + requests_02.setAttributesToRetrieve(attributesToRetrieve3); + String objectID3 = "uniqueID"; + + requests_02.setObjectID(objectID3); + String indexName3 = "theIndexName"; + + requests_02.setIndexName(indexName3); } requests1.add(requests_02); } - batchWriteParams0.setRequests(requests1); + getObjectsParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batch(indexName0, batchWriteParams0); + return client.getObjects(getObjectsParams0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/batch"); + assertEquals(req.getPath(), "/1/indexes/*/objects"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", + "{\"requests\":[{\"attributesToRetrieve\":[\"attr1\",\"attr2\"],\"objectID\":\"uniqueID\",\"indexName\":\"theIndexName\"}]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1107,86 +1131,120 @@ void batchTest0() { } @Test - @DisplayName("addOrUpdateObject") - void addOrUpdateObjectTest0() { + @DisplayName("getRule") + void getRuleTest0() { String indexName0 = "indexName"; - String objectID0 = "uniqueID"; - - Map body0 = new HashMap<>(); - { - String key1 = "value"; - - body0.put("key", key1); - } + String objectID0 = "id1"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addOrUpdateObject(indexName0, objectID0, body0); + return client.getRule(indexName0, objectID0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/uniqueID"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); + assertEquals(req.getMethod(), "GET"); + } - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"key\":\"value\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + @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("clearObjects") - void clearObjectsTest0() { - String indexName0 = "theIndexName"; + @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.clearObjects(indexName0); + return client.getSynonym(indexName0, objectID0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/clear"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("setSettings") - void setSettingsTest0() { + @DisplayName("getTask") + void getTaskTest0() { String indexName0 = "theIndexName"; - IndexSettings indexSettings0 = new IndexSettings(); - { - int paginationLimitedTo1 = 10; + int taskID0 = 123; - indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); - } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.getTask(indexName0, taskID0); + } + ); - boolean forwardToReplicas0 = true; + assertEquals(req.getPath(), "/1/indexes/theIndexName/task/123"); + assertEquals(req.getMethod(), "GET"); + } + @Test + @DisplayName("getTopUserIds") + void getTopUserIdsTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setSettings( - indexName0, - indexSettings0, - forwardToReplicas0 - ); + return client.getTopUserIds(); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/clusters/mapping/top"); + assertEquals(req.getMethod(), "GET"); + } - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"paginationLimitedTo\":10}", - req.getBody(), - JSONCompareMode.STRICT_ORDER - ); - }); + @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( - "{\"forwardToReplicas\":\"true\"}", + "{\"getClusters\":\"true\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1208,65 +1266,62 @@ void setSettingsTest0() { } @Test - @DisplayName("clearRules") - void clearRulesTest0() { - String indexName0 = "indexName"; - + @DisplayName("listApiKeys") + void listApiKeysTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearRules(indexName0); + return client.listApiKeys(); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/clear"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/keys"); + assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("getSynonym") - void getSynonymTest0() { - String indexName0 = "indexName"; - - String objectID0 = "id1"; - + @DisplayName("listClusters") + void listClustersTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSynonym(indexName0, objectID0); + return client.listClusters(); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); + assertEquals(req.getPath(), "/1/clusters"); assertEquals(req.getMethod(), "GET"); } @Test - @DisplayName("deleteBy") - void deleteByTest0() { - String indexName0 = "theIndexName"; - - SearchParamsObject searchParams0 = new SearchParamsObject(); - { - String query1 = "testQuery"; - - searchParams0.setQuery(query1); - } + @DisplayName("listIndices") + void listIndicesTest0() { + int page0 = 8; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteBy( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); + return client.listIndices(page0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/deleteByQuery"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/indexes"); + assertEquals(req.getMethod(), "GET"); - assertDoesNotThrow(() -> { - JSONAssert.assertEquals( - "{\"query\":\"testQuery\"}", - req.getBody(), - JSONCompareMode.STRICT_ORDER + 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 @@ -1307,45 +1362,45 @@ void listUserIdsTest0() { } @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"); - } + @DisplayName("multipleBatch") + void multipleBatchTest0() { + BatchParams batchParams0 = new BatchParams(); + { + List requests1 = new ArrayList<>(); + { + MultipleBatchOperation requests_02 = new MultipleBatchOperation(); + { + Action action3 = Action.fromValue("addObject"); - @Test - @DisplayName("get browse results with all parameters") - void browseTest1() { - String indexName0 = "indexName"; + requests_02.setAction(action3); - BrowseRequest browseRequest0 = new BrowseRequest(); - { - String params1 = "query=foo&facetFilters=['bar']"; + Map body3 = new HashMap<>(); + { + String key4 = "value"; - browseRequest0.setParams(params1); - String cursor1 = "cts"; + body3.put("key", key4); + } + requests_02.setBody(body3); + String indexName3 = "theIndexName"; - browseRequest0.setCursor(cursor1); + requests_02.setIndexName(indexName3); + } + requests1.add(requests_02); + } + batchParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.browse(indexName0, browseRequest0); + return client.multipleBatch(batchParams0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/browse"); + assertEquals(req.getPath(), "/1/indexes/*/batch"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}", + "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1353,151 +1408,21 @@ void browseTest1() { } @Test - @DisplayName("getObjects") - void getObjectsTest0() { - GetObjectsParams getObjectsParams0 = new GetObjectsParams(); + @DisplayName("multipleQueries for a single request with minimal parameters") + void multipleQueriesTest0() { + MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); { - List requests1 = new ArrayList<>(); + List requests1 = new ArrayList<>(); { - MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); + MultipleQueries requests_02 = new MultipleQueries(); { - 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("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("multipleQueries for a single request with minimal parameters") - void multipleQueriesTest0() { - MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); - { - List requests1 = new ArrayList<>(); - { - MultipleQueries requests_02 = new MultipleQueries(); - { - String indexName3 = "theIndexName"; - - requests_02.setIndexName(indexName3); - } - requests1.add(requests_02); - } - multipleQueriesParams0.setRequests(requests1); + multipleQueriesParams0.setRequests(requests1); MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue( "stopIfEnoughMatches" @@ -1596,57 +1521,43 @@ void multipleQueriesTest1() { } @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"); - } + @DisplayName("operationIndex") + void operationIndexTest0() { + String indexName0 = "theIndexName"; - @Test - @DisplayName("get searchForFacetValues results with all parameters") - void searchForFacetValuesTest1() { - String indexName0 = "indexName"; + OperationIndexParams operationIndexParams0 = new OperationIndexParams(); + { + OperationType operation1 = OperationType.fromValue("copy"); - String facetName0 = "facetName"; + operationIndexParams0.setOperation(operation1); + String destination1 = "dest"; - SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); - { - String params1 = "query=foo&facetFilters=['bar']"; + operationIndexParams0.setDestination(destination1); - searchForFacetValuesRequest0.setParams(params1); - String facetQuery1 = "foo"; + List scope1 = new ArrayList<>(); + { + ScopeType scope_02 = ScopeType.fromValue("rules"); - searchForFacetValuesRequest0.setFacetQuery(facetQuery1); + scope1.add(scope_02); - int maxFacetHits1 = 42; + ScopeType scope_12 = ScopeType.fromValue("settings"); - searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); + scope1.add(scope_12); + } + operationIndexParams0.setScope(scope1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchForFacetValues( - indexName0, - facetName0, - searchForFacetValuesRequest0 - ); + return client.operationIndex(indexName0, operationIndexParams0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); + assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", + "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1654,34 +1565,67 @@ void searchForFacetValuesTest1() { } @Test - @DisplayName("getSettings") - void getSettingsTest0() { + @DisplayName("partialUpdateObject") + void partialUpdateObjectTest0() { String indexName0 = "theIndexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSettings(indexName0); - } - ); + String objectID0 = "uniqueID"; - assertEquals(req.getPath(), "/1/indexes/theIndexName/settings"); - assertEquals(req.getMethod(), "GET"); - } + List> attributeOrBuiltInOperation0 = new ArrayList<>(); + { + Map attributeOrBuiltInOperation_01 = new HashMap<>(); + { + String id12 = "test"; - @Test - @DisplayName("listIndices") - void listIndicesTest0() { - int page0 = 8; + 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.listIndices(page0); + return client.partialUpdateObject( + indexName0, + objectID0, + attributeOrBuiltInOperation0, + createIfNotExists0 + ); } ); - assertEquals(req.getPath(), "/1/indexes"); - assertEquals(req.getMethod(), "GET"); + 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( - "{\"page\":\"8\"}", + "{\"createIfNotExists\":\"true\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1703,171 +1647,127 @@ void listIndicesTest0() { } @Test - @DisplayName("get getDictionarySettings results") - void getDictionarySettingsTest0() { + @DisplayName("allow post method for a custom path with minimal parameters") + void postTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getDictionarySettings(); + return client.post(path0); } ); - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("deleteSource") - void deleteSourceTest0() { - String source0 = "theSource"; + @DisplayName("allow post method for a custom path with all parameters") + void postTest1() { + String path0 = "/test/all"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSource(source0); - } - ); + Map parameters0 = new HashMap<>(); + { + String query1 = "parameters"; - assertEquals(req.getPath(), "/1/security/sources/theSource"); - assertEquals(req.getMethod(), "DELETE"); - } + parameters0.put("query", query1); + } - @Test - @DisplayName("getSources") - void getSourcesTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSources(); - } - ); + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; - assertEquals(req.getPath(), "/1/security/sources"); - assertEquals(req.getMethod(), "GET"); - } + body0.put("body", body1); + } - @Test - @DisplayName("get getDictionaryLanguages") - void getDictionaryLanguagesTest0() { EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getDictionaryLanguages(); + return client.post(path0, parameters0, body0); } ); - assertEquals(req.getPath(), "/1/dictionaries/*/languages"); - assertEquals(req.getMethod(), "GET"); - } + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "POST"); - @Test - @DisplayName("deleteApiKey") - void deleteApiKeyTest0() { - String key0 = "myTestApiKey"; + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"body\":\"parameters\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteApiKey(key0); - } + Map expectedQuery = JSON.deserialize( + "{\"query\":\"parameters\"}", + new TypeToken>() {}.getType() ); - - assertEquals(req.getPath(), "/1/keys/myTestApiKey"); - assertEquals(req.getMethod(), "DELETE"); + 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() { + @DisplayName("allow put method for a custom path with minimal parameters") + void putTest0() { + String path0 = "/test/minimal"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listApiKeys(); + return client.put(path0); } ); - assertEquals(req.getPath(), "/1/keys"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/test/minimal"); + assertEquals(req.getMethod(), "PUT"); } @Test - @DisplayName("saveSynonyms") - void saveSynonymsTest0() { - String indexName0 = "indexName"; + @DisplayName("allow put method for a custom path with all parameters") + void putTest1() { + String path0 = "/test/all"; - List synonymHit0 = new ArrayList<>(); + Map parameters0 = new HashMap<>(); { - 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"; + String query1 = "parameters"; - synonyms2.add(synonyms_23); - } - synonymHit_11.setSynonyms(synonyms2); - } - synonymHit0.add(synonymHit_11); + parameters0.put("query", query1); } - boolean forwardToReplicas0 = true; + Map body0 = new HashMap<>(); + { + String body1 = "parameters"; - boolean replaceExistingSynonyms0 = false; + body0.put("body", body1); + } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonyms( - indexName0, - synonymHit0, - forwardToReplicas0, - replaceExistingSynonyms0 - ); + return client.put(path0, parameters0, body0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/test/all"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]", + "{\"body\":\"parameters\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); Map expectedQuery = JSON.deserialize( - "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", + "{\"query\":\"parameters\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -1889,31 +1789,47 @@ void saveSynonymsTest0() { } @Test - @DisplayName("search with minimal parameters") - void searchTest0() { - String indexName0 = "indexName"; + @DisplayName("removeUserId") + void removeUserIdTest0() { + String userID0 = "uniqueID"; - SearchParamsObject searchParams0 = new SearchParamsObject(); + 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<>(); { - String query1 = "myQuery"; + Source source_01 = new Source(); + { + String source2 = "theSource"; - searchParams0.setQuery(query1); + source_01.setSource(source2); + String description2 = "theDescription"; + + source_01.setDescription(description2); + } + source0.add(source_01); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); + return client.replaceSources(source0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/query"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/security/sources"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"myQuery\"}", + "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1921,39 +1837,45 @@ void searchTest0() { } @Test - @DisplayName("search with facetFilters") - void searchTest1() { - String indexName0 = "indexName"; + @DisplayName("restoreApiKey") + void restoreApiKeyTest0() { + String key0 = "myApiKey"; - SearchParamsObject searchParams0 = new SearchParamsObject(); - { - String query1 = "myQuery"; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { + return client.restoreApiKey(key0); + } + ); - searchParams0.setQuery(query1); + assertEquals(req.getPath(), "/1/keys/myApiKey/restore"); + assertEquals(req.getMethod(), "POST"); + } - List facetFilters1 = new ArrayList<>(); - { - String facetFilters_02 = "tags:algolia"; + @Test + @DisplayName("saveObject") + void saveObjectTest0() { + String indexName0 = "theIndexName"; - facetFilters1.add(facetFilters_02); - } - searchParams0.setFacetFilters(FacetFilters.ofListString(facetFilters1)); + Map body0 = new HashMap<>(); + { + String objectID1 = "id"; + + body0.put("objectID", objectID1); + String test1 = "val"; + + body0.put("test", test1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search( - indexName0, - SearchParams.ofSearchParamsObject(searchParams0) - ); + return client.saveObject(indexName0, body0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getPath(), "/1/indexes/theIndexName"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}", + "{\"objectID\":\"id\",\"test\":\"val\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -1961,76 +1883,72 @@ void searchTest1() { } @Test - @DisplayName("allow get method for a custom path with minimal parameters") - void getTest0() { - String path0 = "/test/minimal"; + @DisplayName("saveRule") + void saveRuleTest0() { + String indexName0 = "indexName"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0); - } - ); + String objectID0 = "id1"; - assertEquals(req.getPath(), "/1/test/minimal"); - assertEquals(req.getMethod(), "GET"); - } + Rule rule0 = new Rule(); + { + String objectID1 = "id1"; - @Test - @DisplayName("allow get method for a custom path with all parameters") - void getTest1() { - String path0 = "/test/all"; + rule0.setObjectID(objectID1); - Map parameters0 = new HashMap<>(); - { - String query1 = "parameters"; + List conditions1 = new ArrayList<>(); + { + Condition conditions_02 = new Condition(); + { + String pattern3 = "apple"; - parameters0.put("query", query1); - } + conditions_02.setPattern(pattern3); - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.get(path0, parameters0); + Anchoring anchoring3 = Anchoring.fromValue("contains"); + + conditions_02.setAnchoring(anchoring3); + } + conditions1.add(conditions_02); } - ); + rule0.setConditions(conditions1); - assertEquals(req.getPath(), "/1/test/all"); - assertEquals(req.getMethod(), "GET"); + Consequence consequence1 = new Consequence(); + { + ConsequenceParams params2 = new ConsequenceParams(); + { + String filters3 = "brand:apple"; - 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; + params2.setFilters(filters3); } + consequence1.setParams(params2); } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" - ); + rule0.setConsequence(consequence1); } - } - @Test - @DisplayName("hasPendingMappings") - void hasPendingMappingsTest0() { - boolean getClusters0 = true; + boolean forwardToReplicas0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.hasPendingMappings(getClusters0); + return client.saveRule( + indexName0, + objectID0, + rule0, + forwardToReplicas0 + ); } ); - assertEquals(req.getPath(), "/1/clusters/mapping/pending"); - assertEquals(req.getMethod(), "GET"); + 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( - "{\"getClusters\":\"true\"}", + "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -2052,206 +1970,172 @@ void hasPendingMappingsTest0() { } @Test - @DisplayName("getTopUserIds") - void getTopUserIdsTest0() { - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTopUserIds(); - } - ); + @DisplayName("saveSynonym") + void saveSynonymTest0() { + String indexName0 = "indexName"; - assertEquals(req.getPath(), "/1/clusters/mapping/top"); - assertEquals(req.getMethod(), "GET"); - } + String objectID0 = "id1"; - @Test - @DisplayName("get setDictionarySettings results with minimal parameters") - void setDictionarySettingsTest0() { - DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); + SynonymHit synonymHit0 = new SynonymHit(); { - StandardEntries disableStandardEntries1 = new StandardEntries(); - { - Map plurals2 = new HashMap<>(); - { - boolean fr3 = false; + String objectID1 = "id1"; - plurals2.put("fr", fr3); + synonymHit0.setObjectID(objectID1); - boolean en3 = false; + SynonymType type1 = SynonymType.fromValue("synonym"); - plurals2.put("en", en3); + synonymHit0.setType(type1); - boolean ru3 = true; + List synonyms1 = new ArrayList<>(); + { + String synonyms_02 = "car"; - plurals2.put("ru", ru3); - } - disableStandardEntries1.setPlurals(plurals2); + synonyms1.add(synonyms_02); + String synonyms_12 = "vehicule"; + + synonyms1.add(synonyms_12); + String synonyms_22 = "auto"; + + synonyms1.add(synonyms_22); } - dictionarySettingsParams0.setDisableStandardEntries( - disableStandardEntries1 - ); + synonymHit0.setSynonyms(synonyms1); } + boolean forwardToReplicas0 = true; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(dictionarySettingsParams0); + return client.saveSynonym( + indexName0, + objectID0, + synonymHit0, + forwardToReplicas0 + ); } ); - assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", + "{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", 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); + 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; } - disableStandardEntries1.setCompounds(compounds2); } - dictionarySettingsParams0.setDisableStandardEntries( - disableStandardEntries1 + assertTrue( + found, + "Query parameter " + entry.getKey() + " not found in the actual query" ); } - - 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("deleteRule") - void deleteRuleTest0() { + @DisplayName("saveSynonyms") + void saveSynonymsTest0() { String indexName0 = "indexName"; - String objectID0 = "id1"; + List synonymHit0 = new ArrayList<>(); + { + SynonymHit synonymHit_01 = new SynonymHit(); + { + String objectID2 = "id1"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteRule(indexName0, objectID0); - } - ); + synonymHit_01.setObjectID(objectID2); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "DELETE"); - } + SynonymType type2 = SynonymType.fromValue("synonym"); - @Test - @DisplayName("saveRule") - void saveRuleTest0() { - String indexName0 = "indexName"; + synonymHit_01.setType(type2); - String objectID0 = "id1"; + List synonyms2 = new ArrayList<>(); + { + String synonyms_03 = "car"; - Rule rule0 = new Rule(); - { - String objectID1 = "id1"; + synonyms2.add(synonyms_03); + String synonyms_13 = "vehicule"; - rule0.setObjectID(objectID1); + synonyms2.add(synonyms_13); + String synonyms_23 = "auto"; - List conditions1 = new ArrayList<>(); + synonyms2.add(synonyms_23); + } + synonymHit_01.setSynonyms(synonyms2); + } + synonymHit0.add(synonymHit_01); + + SynonymHit synonymHit_11 = new SynonymHit(); { - Condition conditions_02 = new Condition(); - { - String pattern3 = "apple"; + String objectID2 = "id2"; - conditions_02.setPattern(pattern3); + synonymHit_11.setObjectID(objectID2); - Anchoring anchoring3 = Anchoring.fromValue("contains"); + SynonymType type2 = SynonymType.fromValue("onewaysynonym"); - conditions_02.setAnchoring(anchoring3); - } - conditions1.add(conditions_02); - } - rule0.setConditions(conditions1); + synonymHit_11.setType(type2); + String input2 = "iphone"; - Consequence consequence1 = new Consequence(); - { - ConsequenceParams params2 = new ConsequenceParams(); + synonymHit_11.setInput(input2); + + List synonyms2 = new ArrayList<>(); { - String filters3 = "brand:apple"; + String synonyms_03 = "ephone"; - params2.setFilters(filters3); + synonyms2.add(synonyms_03); + String synonyms_13 = "aphone"; + + synonyms2.add(synonyms_13); + String synonyms_23 = "yphone"; + + synonyms2.add(synonyms_23); } - consequence1.setParams(params2); + synonymHit_11.setSynonyms(synonyms2); } - rule0.setConsequence(consequence1); + synonymHit0.add(synonymHit_11); } boolean forwardToReplicas0 = true; + boolean replaceExistingSynonyms0 = false; + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveRule( + return client.saveSynonyms( indexName0, - objectID0, - rule0, - forwardToReplicas0 + synonymHit0, + forwardToReplicas0, + replaceExistingSynonyms0 ); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/batch"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"objectID\":\"id1\",\"conditions\":[{\"pattern\":\"apple\",\"anchoring\":\"contains\"}],\"consequence\":{\"params\":{\"filters\":\"brand:apple\"}}}", + "[{\"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\"}", + "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", new TypeToken>() {}.getType() ); List actualQuery = req.getQueryParams(); @@ -2273,31 +2157,31 @@ void saveRuleTest0() { } @Test - @DisplayName("saveObject") - void saveObjectTest0() { - String indexName0 = "theIndexName"; + @DisplayName("search with minimal parameters") + void searchTest0() { + String indexName0 = "indexName"; - Map body0 = new HashMap<>(); + SearchParamsObject searchParams0 = new SearchParamsObject(); { - String objectID1 = "id"; - - body0.put("objectID", objectID1); - String test1 = "val"; + String query1 = "myQuery"; - body0.put("test", test1); + searchParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveObject(indexName0, body0); + return client.search( + indexName0, + SearchParams.ofSearchParamsObject(searchParams0) + ); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName"); + assertEquals(req.getPath(), "/1/indexes/indexName/query"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"objectID\":\"id\",\"test\":\"val\"}", + "{\"query\":\"myQuery\"}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2305,106 +2189,172 @@ void saveObjectTest0() { } @Test - @DisplayName("saveSynonym") - void saveSynonymTest0() { + @DisplayName("search with facetFilters") + void searchTest1() { String indexName0 = "indexName"; - String objectID0 = "id1"; - - SynonymHit synonymHit0 = new SynonymHit(); + SearchParamsObject searchParams0 = new SearchParamsObject(); { - String objectID1 = "id1"; - - synonymHit0.setObjectID(objectID1); - - SynonymType type1 = SynonymType.fromValue("synonym"); + String query1 = "myQuery"; - synonymHit0.setType(type1); + searchParams0.setQuery(query1); - List synonyms1 = new ArrayList<>(); + List facetFilters1 = new ArrayList<>(); { - String synonyms_02 = "car"; - - synonyms1.add(synonyms_02); - String synonyms_12 = "vehicule"; - - synonyms1.add(synonyms_12); - String synonyms_22 = "auto"; + String facetFilters_02 = "tags:algolia"; - synonyms1.add(synonyms_22); + facetFilters1.add(facetFilters_02); } - synonymHit0.setSynonyms(synonyms1); + searchParams0.setFacetFilters(FacetFilters.ofListString(facetFilters1)); } - boolean forwardToReplicas0 = true; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveSynonym( + return client.search( indexName0, - objectID0, - synonymHit0, - forwardToReplicas0 + SearchParams.ofSearchParamsObject(searchParams0) ); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/id1"); - assertEquals(req.getMethod(), "PUT"); + assertEquals(req.getPath(), "/1/indexes/indexName/query"); + assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]}", + "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}", 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; - } + @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 + ); } - assertTrue( - found, - "Query parameter " + entry.getKey() + " not found in the actual query" + ); + + 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("appendSource") - void appendSourceTest0() { - Source source0 = new Source(); + @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 source1 = "theSource"; + String params1 = "query=foo&facetFilters=['bar']"; - source0.setSource(source1); - String description1 = "theDescription"; + searchForFacetValuesRequest0.setParams(params1); + String facetQuery1 = "foo"; - source0.setDescription(description1); + searchForFacetValuesRequest0.setFacetQuery(facetQuery1); + + int maxFacetHits1 = 42; + + searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.appendSource(source0); + return client.searchForFacetValues( + indexName0, + facetName0, + searchForFacetValuesRequest0 + ); } ); - assertEquals(req.getPath(), "/1/security/sources/append"); + assertEquals(req.getPath(), "/1/indexes/indexName/facets/facetName/query"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"source\":\"theSource\",\"description\":\"theDescription\"}", + "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2412,73 +2362,80 @@ void appendSourceTest0() { } @Test - @DisplayName("clearAllSynonyms") - void clearAllSynonymsTest0() { + @DisplayName("searchRules") + void searchRulesTest0() { String indexName0 = "indexName"; + SearchRulesParams searchRulesParams0 = new SearchRulesParams(); + { + String query1 = "something"; + + searchRulesParams0.setQuery(query1); + } + EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearAllSynonyms(indexName0); + return client.searchRules(indexName0, searchRulesParams0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/clear"); + assertEquals(req.getPath(), "/1/indexes/indexName/rules/search"); assertEquals(req.getMethod(), "POST"); + + assertDoesNotThrow(() -> { + JSONAssert.assertEquals( + "{\"query\":\"something\"}", + req.getBody(), + JSONCompareMode.STRICT_ORDER + ); + }); } @Test - @DisplayName("getRule") - void getRuleTest0() { + @DisplayName("searchSynonyms") + void searchSynonymsTest0() { String indexName0 = "indexName"; - String objectID0 = "id1"; - EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRule(indexName0, objectID0); + return client.searchSynonyms(indexName0); } ); - assertEquals(req.getPath(), "/1/indexes/indexName/rules/id1"); - assertEquals(req.getMethod(), "GET"); + assertEquals(req.getPath(), "/1/indexes/indexName/synonyms/search"); + assertEquals(req.getMethod(), "POST"); } @Test - @DisplayName("operationIndex") - void operationIndexTest0() { - String indexName0 = "theIndexName"; - - OperationIndexParams operationIndexParams0 = new OperationIndexParams(); + @DisplayName("searchUserIds") + void searchUserIdsTest0() { + SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); { - OperationType operation1 = OperationType.fromValue("copy"); + String query1 = "test"; - operationIndexParams0.setOperation(operation1); - String destination1 = "dest"; + searchUserIdsParams0.setQuery(query1); + String clusterName1 = "theClusterName"; - operationIndexParams0.setDestination(destination1); + searchUserIdsParams0.setClusterName(clusterName1); - List scope1 = new ArrayList<>(); - { - ScopeType scope_02 = ScopeType.fromValue("rules"); + int page1 = 5; - scope1.add(scope_02); + searchUserIdsParams0.setPage(page1); - ScopeType scope_12 = ScopeType.fromValue("settings"); + int hitsPerPage1 = 10; - scope1.add(scope_12); - } - operationIndexParams0.setScope(scope1); + searchUserIdsParams0.setHitsPerPage(hitsPerPage1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.operationIndex(indexName0, operationIndexParams0); + return client.searchUserIds(searchUserIdsParams0); } ); - assertEquals(req.getPath(), "/1/indexes/theIndexName/operation"); + assertEquals(req.getPath(), "/1/clusters/mapping/search"); assertEquals(req.getMethod(), "POST"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}", + "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2486,31 +2443,44 @@ void operationIndexTest0() { } @Test - @DisplayName("get searchDictionaryEntries results with minimal parameters") - void searchDictionaryEntriesTest0() { - DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); + @DisplayName("get setDictionarySettings results with minimal parameters") + void setDictionarySettingsTest0() { + DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); { - String query1 = "foo"; + StandardEntries disableStandardEntries1 = new StandardEntries(); + { + Map plurals2 = new HashMap<>(); + { + boolean fr3 = false; - searchDictionaryEntriesParams0.setQuery(query1); + 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.searchDictionaryEntries( - dictionaryName0, - searchDictionaryEntriesParams0 - ); + return client.setDictionarySettings(dictionarySettingsParams0); } ); - assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"foo\"}", + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2518,42 +2488,60 @@ void searchDictionaryEntriesTest0() { } @Test - @DisplayName("get searchDictionaryEntries results with all parameters") - void searchDictionaryEntriesTest1() { - DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - - SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); + @DisplayName("get setDictionarySettings results with all parameters") + void setDictionarySettingsTest1() { + DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); { - String query1 = "foo"; + StandardEntries disableStandardEntries1 = new StandardEntries(); + { + Map plurals2 = new HashMap<>(); + { + boolean fr3 = false; - searchDictionaryEntriesParams0.setQuery(query1); + plurals2.put("fr", fr3); - int page1 = 4; + boolean en3 = false; - searchDictionaryEntriesParams0.setPage(page1); + plurals2.put("en", en3); - int hitsPerPage1 = 2; + boolean ru3 = true; - searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); - String language1 = "fr"; + plurals2.put("ru", ru3); + } + disableStandardEntries1.setPlurals(plurals2); - searchDictionaryEntriesParams0.setLanguage(language1); + 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.searchDictionaryEntries( - dictionaryName0, - searchDictionaryEntriesParams0 - ); + return client.setDictionarySettings(dictionarySettingsParams0); } ); - assertEquals(req.getPath(), "/1/dictionaries/compounds/search"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/dictionaries/*/settings"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"query\":\"foo\",\"page\":4,\"hitsPerPage\":2,\"language\":\"fr\"}", + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -2561,20 +2549,66 @@ void searchDictionaryEntriesTest1() { } @Test - @DisplayName("listClusters") - void listClustersTest0() { + @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.listClusters(); + return client.setSettings( + indexName0, + indexSettings0, + forwardToReplicas0 + ); } ); - assertEquals(req.getPath(), "/1/clusters"); - assertEquals(req.getMethod(), "GET"); + 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("addApiKey") - void addApiKeyTest0() { + @DisplayName("updateApiKey") + void updateApiKeyTest0() { + String key0 = "myApiKey"; + ApiKey apiKey0 = new ApiKey(); { List acl1 = new ArrayList<>(); @@ -2588,9 +2622,6 @@ void addApiKeyTest0() { acl1.add(acl_12); } apiKey0.setAcl(acl1); - String description1 = "my new api key"; - - apiKey0.setDescription(description1); int validity1 = 300; @@ -2606,50 +2637,19 @@ void addApiKeyTest0() { } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addApiKey(apiKey0); + return client.updateApiKey(key0, apiKey0); } ); - assertEquals(req.getPath(), "/1/keys"); - assertEquals(req.getMethod(), "POST"); + assertEquals(req.getPath(), "/1/keys/myApiKey"); + assertEquals(req.getMethod(), "PUT"); assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api" + - " key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", + "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}", req.getBody(), JSONCompareMode.STRICT_ORDER ); }); } - - @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("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"); - } } diff --git a/tests/output/javascript/src/methods/requests/abtesting.test.ts b/tests/output/javascript/src/methods/requests/abtesting.test.ts index 6a77429916..6ae5e9153e 100644 --- a/tests/output/javascript/src/methods/requests/abtesting.test.ts +++ b/tests/output/javascript/src/methods/requests/abtesting.test.ts @@ -9,83 +9,69 @@ const client = abtestingClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('deleteABTest', () => { - test('deleteABTest', async () => { - const req = (await client.deleteABTest({ - id: 42, +describe('addABTests', () => { + test('addABTests with minimal parameters', async () => { + const req = (await client.addABTests({ + endAt: '2022-12-31T00:00:00.000Z', + name: 'myABTest', + variant: [ + { index: 'AB_TEST_1', trafficPercentage: 30 }, + { index: 'AB_TEST_2', trafficPercentage: 50 }, + ], })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/abtests/42'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/2/abtests'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + endAt: '2022-12-31T00:00:00.000Z', + name: 'myABTest', + variant: [ + { index: 'AB_TEST_1', trafficPercentage: 30 }, + { index: 'AB_TEST_2', trafficPercentage: 50 }, + ], + }); expect(req.searchParams).toEqual(undefined); }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('stopABTest', () => { - test('stopABTest', async () => { - const req = (await client.stopABTest({ +describe('deleteABTest', () => { + test('deleteABTest', async () => { + const req = (await client.deleteABTest({ id: 42, })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/abtests/42/stop'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/2/abtests/42'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('addABTests', () => { - test('addABTests with minimal parameters', async () => { - const req = (await client.addABTests({ - endAt: '2022-12-31T00:00:00.000Z', - name: 'myABTest', - variant: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/abtests'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - endAt: '2022-12-31T00:00:00.000Z', - name: 'myABTest', - variant: [ - { index: 'AB_TEST_1', trafficPercentage: 30 }, - { index: 'AB_TEST_2', trafficPercentage: 50 }, - ], - }); - expect(req.searchParams).toEqual(undefined); - }); -}); - describe('get', () => { test('allow get method for a custom path with minimal parameters', async () => { const req = (await client.get({ @@ -111,6 +97,17 @@ describe('get', () => { }); }); +describe('getABTest', () => { + test('getABTest', async () => { + const req = (await client.getABTest({ id: 42 })) as unknown as EchoResponse; + + expect(req.path).toEqual('/2/abtests/42'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + describe('listABTests', () => { test('listABTests with minimal parameters', async () => { const req = (await client.listABTests({ @@ -125,27 +122,28 @@ describe('listABTests', () => { }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ path: '/test/all', parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -176,12 +174,14 @@ describe('put', () => { }); }); -describe('getABTest', () => { - test('getABTest', async () => { - const req = (await client.getABTest({ id: 42 })) as unknown as EchoResponse; +describe('stopABTest', () => { + test('stopABTest', async () => { + const req = (await client.stopABTest({ + id: 42, + })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/abtests/42'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/2/abtests/42/stop'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); diff --git a/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts index 0602286c71..ff245af428 100644 --- a/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts +++ b/tests/output/javascript/src/methods/requests/algoliasearch-lite.test.ts @@ -69,6 +69,32 @@ describe('multipleQueries', () => { }); }); +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + describe('search', () => { test('search with minimal parameters', async () => { const req = (await client.search({ @@ -132,29 +158,3 @@ describe('searchForFacetValues', () => { expect(req.searchParams).toEqual(undefined); }); }); - -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ 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 0996fba98f..93f2e3dacc 100644 --- a/tests/output/javascript/src/methods/requests/analytics.test.ts +++ b/tests/output/javascript/src/methods/requests/analytics.test.ts @@ -9,221 +9,141 @@ const client = analyticsClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('getTopSearches', () => { - test('get getTopSearches with minimal parameters', async () => { - const req = (await client.getTopSearches({ - index: 'index', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); - }); - - test('get getTopSearches with all parameters', async () => { - const req = (await client.getTopSearches({ - index: 'index', - clickAnalytics: true, - startDate: '1999-09-19', - endDate: '2001-01-01', - orderBy: 'searchCount', - direction: 'asc', - limit: 21, - offset: 42, - tags: 'tag', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/searches'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ - index: 'index', - clickAnalytics: 'true', - startDate: '1999-09-19', - endDate: '2001-01-01', - orderBy: 'searchCount', - direction: 'asc', - limit: '21', - offset: '42', - tags: 'tag', - }); - }); -}); - -describe('getTopHits', () => { - test('get getTopHits with minimal parameters', async () => { - const req = (await client.getTopHits({ - index: 'index', +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/hits'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); + expect(req.searchParams).toEqual(undefined); }); - test('get getTopHits with all parameters', async () => { - const req = (await client.getTopHits({ - index: 'index', - search: 'mySearch', - clickAnalytics: true, - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: 21, - offset: 42, - tags: 'tag', + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ + path: '/test/all', + parameters: { query: 'parameters' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/hits'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ - index: 'index', - search: 'mySearch', - clickAnalytics: 'true', - startDate: '1999-09-19', - endDate: '2001-01-01', - limit: '21', - offset: '42', - tags: 'tag', - }); + expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('get', () => { + test('allow get method for a custom path with minimal parameters', async () => { + const req = (await client.get({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow get method for a custom path with all parameters', async () => { + const req = (await client.get({ path: '/test/all', parameters: { query: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('getTopFiltersNoResults', () => { - test('get getTopFiltersNoResults with minimal parameters', async () => { - const req = (await client.getTopFiltersNoResults({ +describe('getAverageClickPosition', () => { + test('get getAverageClickPosition with minimal parameters', async () => { + const req = (await client.getAverageClickPosition({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/noResults'); + expect(req.path).toEqual('/2/clicks/averageClickPosition'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopFiltersNoResults with all parameters', async () => { - const req = (await client.getTopFiltersNoResults({ + test('get getAverageClickPosition with all parameters', async () => { + const req = (await client.getAverageClickPosition({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/noResults'); + expect(req.path).toEqual('/2/clicks/averageClickPosition'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getSearchesNoResults', () => { - test('get getSearchesNoResults with minimal parameters', async () => { - const req = (await client.getSearchesNoResults({ +describe('getClickPositions', () => { + test('get getClickPositions with minimal parameters', async () => { + const req = (await client.getClickPositions({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noResults'); + expect(req.path).toEqual('/2/clicks/positions'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getSearchesNoResults with all parameters', async () => { - const req = (await client.getSearchesNoResults({ + test('get getClickPositions with all parameters', async () => { + const req = (await client.getClickPositions({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noResults'); + expect(req.path).toEqual('/2/clicks/positions'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getStatus', () => { - test('get getStatus with minimal parameters', async () => { - const req = (await client.getStatus({ - index: 'index', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/2/status'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ index: 'index' }); - }); -}); - -describe('getClickPositions', () => { - test('get getClickPositions with minimal parameters', async () => { - const req = (await client.getClickPositions({ +describe('getClickThroughRate', () => { + test('get getClickThroughRate with minimal parameters', async () => { + const req = (await client.getClickThroughRate({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/positions'); + expect(req.path).toEqual('/2/clicks/clickThroughRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getClickPositions with all parameters', async () => { - const req = (await client.getClickPositions({ + test('get getClickThroughRate with all parameters', async () => { + const req = (await client.getClickThroughRate({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/positions'); + expect(req.path).toEqual('/2/clicks/clickThroughRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -235,131 +155,123 @@ describe('getClickPositions', () => { }); }); -describe('put', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.put({ - path: '/test/minimal', +describe('getConversationRate', () => { + test('get getConversationRate with minimal parameters', async () => { + const req = (await client.getConversationRate({ + index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('PUT'); + expect(req.path).toEqual('/2/conversions/conversionRate'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.put({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - 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).toEqual({ index: 'index' }); }); -}); -describe('getTopFilterForAttribute', () => { - test('get getTopFilterForAttribute with minimal parameters', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute', + test('get getConversationRate with all parameters', async () => { + const req = (await client.getConversationRate({ index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute'); + 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).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', + }); }); +}); - test('get getTopFilterForAttribute with minimal parameters and multiple attributes', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute1,myAttribute2', +describe('getNoClickRate', () => { + test('get getNoClickRate with minimal parameters', async () => { + const req = (await client.getNoClickRate({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); + expect(req.path).toEqual('/2/searches/noClickRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopFilterForAttribute with all parameters', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute', + test('get getNoClickRate with all parameters', async () => { + const req = (await client.getNoClickRate({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute'); + expect(req.path).toEqual('/2/searches/noClickRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); +}); - test('get getTopFilterForAttribute with all parameters and multiple attributes', async () => { - const req = (await client.getTopFilterForAttribute({ - attribute: 'myAttribute1,myAttribute2', +describe('getNoResultsRate', () => { + test('get getNoResultsRate with minimal parameters', async () => { + const req = (await client.getNoResultsRate({ + index: 'index', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/2/searches/noResultRate'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ index: 'index' }); + }); + + test('get getNoResultsRate with all parameters', async () => { + const req = (await client.getNoResultsRate({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: 21, - offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); + expect(req.path).toEqual('/2/searches/noResultRate'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', - search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', - limit: '21', - offset: '42', tags: 'tag', }); }); }); -describe('getNoClickRate', () => { - test('get getNoClickRate with minimal parameters', async () => { - const req = (await client.getNoClickRate({ +describe('getSearchesCount', () => { + test('get getSearchesCount with minimal parameters', async () => { + const req = (await client.getSearchesCount({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClickRate'); + expect(req.path).toEqual('/2/searches/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getNoClickRate with all parameters', async () => { - const req = (await client.getNoClickRate({ + test('get getSearchesCount with all parameters', async () => { + const req = (await client.getSearchesCount({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClickRate'); + expect(req.path).toEqual('/2/searches/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -371,52 +283,56 @@ describe('getNoClickRate', () => { }); }); -describe('getUsersCount', () => { - test('get getUsersCount with minimal parameters', async () => { - const req = (await client.getUsersCount({ +describe('getSearchesNoClicks', () => { + test('get getSearchesNoClicks with minimal parameters', async () => { + const req = (await client.getSearchesNoClicks({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/users/count'); + expect(req.path).toEqual('/2/searches/noClicks'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getUsersCount with all parameters', async () => { - const req = (await client.getUsersCount({ + test('get getSearchesNoClicks with all parameters', async () => { + const req = (await client.getSearchesNoClicks({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/users/count'); + expect(req.path).toEqual('/2/searches/noClicks'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('getSearchesNoClicks', () => { - test('get getSearchesNoClicks with minimal parameters', async () => { - const req = (await client.getSearchesNoClicks({ +describe('getSearchesNoResults', () => { + test('get getSearchesNoResults with minimal parameters', async () => { + const req = (await client.getSearchesNoResults({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClicks'); + expect(req.path).toEqual('/2/searches/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getSearchesNoClicks with all parameters', async () => { - const req = (await client.getSearchesNoClicks({ + test('get getSearchesNoResults with all parameters', async () => { + const req = (await client.getSearchesNoResults({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', @@ -425,7 +341,7 @@ describe('getSearchesNoClicks', () => { tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noClicks'); + expect(req.path).toEqual('/2/searches/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -439,135 +355,147 @@ describe('getSearchesNoClicks', () => { }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', +describe('getStatus', () => { + test('get getStatus with minimal parameters', async () => { + const req = (await client.getStatus({ + index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/2/status'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - 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).toEqual({ index: 'index' }); }); }); -describe('getAverageClickPosition', () => { - test('get getAverageClickPosition with minimal parameters', async () => { - const req = (await client.getAverageClickPosition({ +describe('getTopCountries', () => { + test('get getTopCountries with minimal parameters', async () => { + const req = (await client.getTopCountries({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/averageClickPosition'); + expect(req.path).toEqual('/2/countries'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getAverageClickPosition with all parameters', async () => { - const req = (await client.getAverageClickPosition({ + test('get getTopCountries with all parameters', async () => { + const req = (await client.getTopCountries({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/averageClickPosition'); + expect(req.path).toEqual('/2/countries'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('getSearchesCount', () => { - test('get getSearchesCount with minimal parameters', async () => { - const req = (await client.getSearchesCount({ +describe('getTopFilterAttributes', () => { + test('get getTopFilterAttributes with minimal parameters', async () => { + const req = (await client.getTopFilterAttributes({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/count'); + expect(req.path).toEqual('/2/filters'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getSearchesCount with all parameters', async () => { - const req = (await client.getSearchesCount({ + test('get getTopFilterAttributes with all parameters', async () => { + const req = (await client.getTopFilterAttributes({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/count'); + expect(req.path).toEqual('/2/filters'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('get', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.get({ - path: '/test/minimal', +describe('getTopFilterForAttribute', () => { + test('get getTopFilterForAttribute with minimal parameters', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute', + index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); + expect(req.path).toEqual('/2/filters/myAttribute'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toEqual({ index: 'index' }); }); - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.get({ - path: '/test/all', - parameters: { query: 'parameters' }, + test('get getTopFilterForAttribute with minimal parameters and multiple attributes', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute1,myAttribute2', + index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/all'); + expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); + expect(req.searchParams).toEqual({ index: 'index' }); }); -}); -describe('getTopFilterAttributes', () => { - test('get getTopFilterAttributes with minimal parameters', async () => { - const req = (await client.getTopFilterAttributes({ + test('get getTopFilterForAttribute with all parameters', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute', index: 'index', + search: 'mySearch', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: 21, + offset: 42, + tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters'); + 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).toEqual({ + index: 'index', + search: 'mySearch', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', + tags: 'tag', + }); }); - test('get getTopFilterAttributes with all parameters', async () => { - const req = (await client.getTopFilterAttributes({ + test('get getTopFilterForAttribute with all parameters and multiple attributes', async () => { + const req = (await client.getTopFilterForAttribute({ + attribute: 'myAttribute1,myAttribute2', index: 'index', search: 'mySearch', startDate: '1999-09-19', @@ -577,7 +505,7 @@ describe('getTopFilterAttributes', () => { tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/filters'); + expect(req.path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -592,21 +520,22 @@ describe('getTopFilterAttributes', () => { }); }); -describe('getTopCountries', () => { - test('get getTopCountries with minimal parameters', async () => { - const req = (await client.getTopCountries({ +describe('getTopFiltersNoResults', () => { + test('get getTopFiltersNoResults with minimal parameters', async () => { + const req = (await client.getTopFiltersNoResults({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/countries'); + expect(req.path).toEqual('/2/filters/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getTopCountries with all parameters', async () => { - const req = (await client.getTopCountries({ + test('get getTopFiltersNoResults with all parameters', async () => { + const req = (await client.getTopFiltersNoResults({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', limit: 21, @@ -614,11 +543,12 @@ describe('getTopCountries', () => { tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/countries'); + expect(req.path).toEqual('/2/filters/noResults'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', + search: 'mySearch', startDate: '1999-09-19', endDate: '2001-01-01', limit: '21', @@ -628,91 +558,109 @@ describe('getTopCountries', () => { }); }); -describe('getConversationRate', () => { - test('get getConversationRate with minimal parameters', async () => { - const req = (await client.getConversationRate({ +describe('getTopHits', () => { + test('get getTopHits with minimal parameters', async () => { + const req = (await client.getTopHits({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/conversions/conversionRate'); + expect(req.path).toEqual('/2/hits'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getConversationRate with all parameters', async () => { - const req = (await client.getConversationRate({ + test('get getTopHits with all parameters', async () => { + const req = (await client.getTopHits({ index: 'index', + search: 'mySearch', + clickAnalytics: true, startDate: '1999-09-19', endDate: '2001-01-01', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/conversions/conversionRate'); + expect(req.path).toEqual('/2/hits'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', + search: 'mySearch', + clickAnalytics: 'true', startDate: '1999-09-19', endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('getNoResultsRate', () => { - test('get getNoResultsRate with minimal parameters', async () => { - const req = (await client.getNoResultsRate({ +describe('getTopSearches', () => { + test('get getTopSearches with minimal parameters', async () => { + const req = (await client.getTopSearches({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noResultRate'); + expect(req.path).toEqual('/2/searches'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getNoResultsRate with all parameters', async () => { - const req = (await client.getNoResultsRate({ + test('get getTopSearches with all parameters', async () => { + const req = (await client.getTopSearches({ index: 'index', + clickAnalytics: true, startDate: '1999-09-19', endDate: '2001-01-01', + orderBy: 'searchCount', + direction: 'asc', + limit: 21, + offset: 42, tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/searches/noResultRate'); + expect(req.path).toEqual('/2/searches'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index', + clickAnalytics: 'true', startDate: '1999-09-19', endDate: '2001-01-01', + orderBy: 'searchCount', + direction: 'asc', + limit: '21', + offset: '42', tags: 'tag', }); }); }); -describe('getClickThroughRate', () => { - test('get getClickThroughRate with minimal parameters', async () => { - const req = (await client.getClickThroughRate({ +describe('getUsersCount', () => { + test('get getUsersCount with minimal parameters', async () => { + const req = (await client.getUsersCount({ index: 'index', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/clickThroughRate'); + expect(req.path).toEqual('/2/users/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ index: 'index' }); }); - test('get getClickThroughRate with all parameters', async () => { - const req = (await client.getClickThroughRate({ + test('get getUsersCount with all parameters', async () => { + const req = (await client.getUsersCount({ index: 'index', startDate: '1999-09-19', endDate: '2001-01-01', tags: 'tag', })) as unknown as EchoResponse; - expect(req.path).toEqual('/2/clicks/clickThroughRate'); + expect(req.path).toEqual('/2/users/count'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ @@ -723,3 +671,55 @@ describe('getClickThroughRate', () => { }); }); }); + +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + +describe('put', () => { + test('allow put method for a custom path with minimal parameters', async () => { + const req = (await client.put({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow put method for a custom path with all parameters', async () => { + const req = (await client.put({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ 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 784994ac0c..a2a8e57792 100644 --- a/tests/output/javascript/src/methods/requests/insights.test.ts +++ b/tests/output/javascript/src/methods/requests/insights.test.ts @@ -9,28 +9,27 @@ const client = insightsClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -60,6 +59,32 @@ describe('get', () => { }); }); +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + describe('pushEvents', () => { test('pushEvents', async () => { const req = (await client.pushEvents({ @@ -131,31 +156,6 @@ describe('pushEvents', () => { }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - describe('put', () => { test('allow put method for a custom path with minimal parameters', async () => { const req = (await client.put({ diff --git a/tests/output/javascript/src/methods/requests/personalization.test.ts b/tests/output/javascript/src/methods/requests/personalization.test.ts index c48ede72b8..3f97eefec3 100644 --- a/tests/output/javascript/src/methods/requests/personalization.test.ts +++ b/tests/output/javascript/src/methods/requests/personalization.test.ts @@ -9,45 +9,44 @@ const client = personalizationClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('deleteUserProfile', () => { - test('delete deleteUserProfile', async () => { - const req = (await client.deleteUserProfile({ - userToken: 'UserToken', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/profiles/UserToken'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); +describe('deleteUserProfile', () => { + test('delete deleteUserProfile', async () => { + const req = (await client.deleteUserProfile({ + userToken: 'UserToken', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/profiles/UserToken'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + describe('get', () => { test('allow get method for a custom path with minimal parameters', async () => { const req = (await client.get({ @@ -85,31 +84,6 @@ describe('getPersonalizationStrategy', () => { }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - describe('getUserTokenProfile', () => { test('get getUserTokenProfile', async () => { const req = (await client.getUserTokenProfile({ @@ -123,23 +97,30 @@ describe('getUserTokenProfile', () => { }); }); -describe('setPersonalizationStrategy', () => { - test('set setPersonalizationStrategy', async () => { - const req = (await client.setPersonalizationStrategy({ - eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], - facetScoring: [{ score: 42, facetName: 'Event' }], - personalizationImpact: 42, +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/strategies/personalization'); + expect(req.path).toEqual('/1/test/minimal'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], - facetScoring: [{ score: 42, facetName: 'Event' }], - personalizationImpact: 42, - }); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); }); describe('put', () => { @@ -167,3 +148,22 @@ describe('put', () => { expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); + +describe('setPersonalizationStrategy', () => { + test('set setPersonalizationStrategy', async () => { + const req = (await client.setPersonalizationStrategy({ + eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], + facetScoring: [{ score: 42, facetName: 'Event' }], + personalizationImpact: 42, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/strategies/personalization'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], + facetScoring: [{ score: 42, facetName: 'Event' }], + personalizationImpact: 42, + }); + expect(req.searchParams).toEqual(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 805d5d29d6..acfc470f2a 100644 --- a/tests/output/javascript/src/methods/requests/query-suggestions.test.ts +++ b/tests/output/javascript/src/methods/requests/query-suggestions.test.ts @@ -9,75 +9,73 @@ const client = querySuggestionsClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('deleteConfig', () => { - test('deleteConfig', async () => { - const req = (await client.deleteConfig({ +describe('createConfig', () => { + test('createConfig', async () => { + const req = (await client.createConfig({ indexName: 'theIndexName', + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/1/configs'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + indexName: 'theIndexName', + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], + }); expect(req.searchParams).toEqual(undefined); }); }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('updateConfig', () => { - test('updateConfig', async () => { - const req = (await client.updateConfig({ +describe('deleteConfig', () => { + test('deleteConfig', async () => { + const req = (await client.deleteConfig({ indexName: 'theIndexName', - querySuggestionsIndexParam: { - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], - }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], - }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); @@ -107,62 +105,28 @@ describe('get', () => { }); }); -describe('createConfig', () => { - test('createConfig', async () => { - const req = (await client.createConfig({ - indexName: 'theIndexName', - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], - })) as unknown as EchoResponse; +describe('getAllConfigs', () => { + test('getAllConfigs', async () => { + const req = (await client.getAllConfigs()) as unknown as EchoResponse; expect(req.path).toEqual('/1/configs'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - indexName: 'theIndexName', - sourceIndices: [ - { - indexName: 'testIndex', - facets: [{ attributes: 'test' }], - generate: [['facetA', 'facetB'], ['facetC']], - }, - ], - languages: ['french'], - exclude: ['test'], - }); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', +describe('getConfig', () => { + test('getConfig', async () => { + const req = (await client.getConfig({ + indexName: 'theIndexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/1/configs/theIndexName'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); }); describe('getConfigStatus', () => { @@ -178,28 +142,43 @@ describe('getConfigStatus', () => { }); }); -describe('getAllConfigs', () => { - test('getAllConfigs', async () => { - const req = (await client.getAllConfigs()) as unknown as EchoResponse; +describe('getLogFile', () => { + test('getLogFile', async () => { + const req = (await client.getLogFile({ + indexName: 'theIndexName', + })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/configs'); + expect(req.path).toEqual('/1/logs/theIndexName'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('getConfig', () => { - test('getConfig', async () => { - const req = (await client.getConfig({ - indexName: 'theIndexName', +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/configs/theIndexName'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); }); describe('put', () => { @@ -228,15 +207,36 @@ describe('put', () => { }); }); -describe('getLogFile', () => { - test('getLogFile', async () => { - const req = (await client.getLogFile({ +describe('updateConfig', () => { + test('updateConfig', async () => { + const req = (await client.updateConfig({ indexName: 'theIndexName', + querySuggestionsIndexParam: { + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], + }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/logs/theIndexName'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/1/configs/theIndexName'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ + sourceIndices: [ + { + indexName: 'testIndex', + facets: [{ attributes: 'test' }], + generate: [['facetA', 'facetB'], ['facetC']], + }, + ], + languages: ['french'], + exclude: ['test'], + }); expect(req.searchParams).toEqual(undefined); }); }); diff --git a/tests/output/javascript/src/methods/requests/recommend.test.ts b/tests/output/javascript/src/methods/requests/recommend.test.ts index e2d87bf55c..5476120514 100644 --- a/tests/output/javascript/src/methods/requests/recommend.test.ts +++ b/tests/output/javascript/src/methods/requests/recommend.test.ts @@ -7,28 +7,27 @@ const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; const client = recommendClient(appId, apiKey, { requester: echoRequester() }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -58,31 +57,6 @@ describe('get', () => { }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - describe('getRecommendations', () => { test('get recommendations for recommend model with minimal parameters', async () => { const req = (await client.getRecommendations({ @@ -314,6 +288,32 @@ describe('getRecommendations', () => { }); }); +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + describe('put', () => { test('allow put method for a custom path with minimal parameters', async () => { const req = (await client.put({ diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index 20b6008421..4415b2938d 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -7,125 +7,110 @@ const apiKey = process.env.ALGOLIA_SEARCH_KEY || 'test_api_key'; const client = searchClient(appId, apiKey, { requester: echoRequester() }); -describe('batchAssignUserIds', () => { - test('batchAssignUserIds', async () => { - const req = (await client.batchAssignUserIds({ - xAlgoliaUserID: 'userID', - batchAssignUserIdsParams: { - cluster: 'theCluster', - users: ['user1', 'user2'], - }, +describe('addApiKey', () => { + test('addApiKey', async () => { + const req = (await client.addApiKey({ + acl: ['search', 'addObject'], + description: 'my new api key', + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/batch'); + expect(req.path).toEqual('/1/keys'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - cluster: 'theCluster', - users: ['user1', 'user2'], + acl: ['search', 'addObject'], + description: 'my new api key', + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, }); - expect(req.searchParams).toEqual({ 'X-Algolia-User-ID': 'userID' }); + expect(req.searchParams).toEqual(undefined); }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ - path: '/test/minimal', +describe('addOrUpdateObject', () => { + test('addOrUpdateObject', async () => { + const req = (await client.addOrUpdateObject({ + indexName: 'indexName', + objectID: 'uniqueID', + body: { key: 'value' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/1/indexes/indexName/uniqueID'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ key: 'value' }); expect(req.searchParams).toEqual(undefined); }); - - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); }); -describe('searchRules', () => { - test('searchRules', async () => { - const req = (await client.searchRules({ - indexName: 'indexName', - searchRulesParams: { query: 'something' }, +describe('appendSource', () => { + test('appendSource', async () => { + const req = (await client.appendSource({ + source: 'theSource', + description: 'theDescription', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/rules/search'); + expect(req.path).toEqual('/1/security/sources/append'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'something' }); + expect(req.data).toEqual({ + source: 'theSource', + description: 'theDescription', + }); expect(req.searchParams).toEqual(undefined); }); }); -describe('deleteIndex', () => { - test('deleteIndex', async () => { - const req = (await client.deleteIndex({ - indexName: 'theIndexName', +describe('assignUserId', () => { + test('assignUserId', async () => { + const req = (await client.assignUserId({ + xAlgoliaUserID: 'userID', + assignUserIdParams: { cluster: 'theCluster' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + 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' }); }); }); -describe('put', () => { - test('allow put method for a custom path with minimal parameters', async () => { - const req = (await client.put({ - path: '/test/minimal', +describe('batch', () => { + test('batch', async () => { + const req = (await client.batch({ + indexName: 'theIndexName', + batchWriteParams: { + requests: [{ action: 'delete', body: { key: 'value' } }], + }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/1/indexes/theIndexName/batch'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [{ action: 'delete', body: { key: 'value' } }], + }); expect(req.searchParams).toEqual(undefined); }); - - test('allow put method for a custom path with all parameters', async () => { - const req = (await client.put({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); }); -describe('updateApiKey', () => { - test('updateApiKey', async () => { - const req = (await client.updateApiKey({ - key: 'myApiKey', - apiKey: { - acl: ['search', 'addObject'], - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, +describe('batchAssignUserIds', () => { + test('batchAssignUserIds', async () => { + const req = (await client.batchAssignUserIds({ + xAlgoliaUserID: 'userID', + batchAssignUserIdsParams: { + cluster: 'theCluster', + users: ['user1', 'user2'], }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys/myApiKey'); - expect(req.method).toEqual('PUT'); + expect(req.path).toEqual('/1/clusters/mapping/batch'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - acl: ['search', 'addObject'], - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, + cluster: 'theCluster', + users: ['user1', 'user2'], }); - expect(req.searchParams).toEqual(undefined); + expect(req.searchParams).toEqual({ 'X-Algolia-User-ID': 'userID' }); }); }); @@ -258,174 +243,179 @@ describe('batchRules', () => { }); }); -describe('restoreApiKey', () => { - test('restoreApiKey', async () => { - const req = (await client.restoreApiKey({ - key: 'myApiKey', +describe('browse', () => { + test('get browse results with minimal parameters', async () => { + const req = (await client.browse({ + indexName: 'indexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys/myApiKey/restore'); + expect(req.path).toEqual('/1/indexes/indexName/browse'); expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); -}); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ - path: '/test/minimal', + test('get browse results with all parameters', async () => { + const req = (await client.browse({ + indexName: 'indexName', + browseRequest: { + params: "query=foo&facetFilters=['bar']", + cursor: 'cts', + }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/test/minimal'); + expect(req.path).toEqual('/1/indexes/indexName/browse'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); + expect(req.data).toEqual({ + params: "query=foo&facetFilters=['bar']", + cursor: 'cts', + }); expect(req.searchParams).toEqual(undefined); }); - - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ - path: '/test/all', - parameters: { query: 'parameters' }, - body: { body: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); }); -describe('multipleBatch', () => { - test('multipleBatch', async () => { - const req = (await client.multipleBatch({ - requests: [ - { - action: 'addObject', - body: { key: 'value' }, - indexName: 'theIndexName', - }, - ], +describe('clearAllSynonyms', () => { + test('clearAllSynonyms', async () => { + const req = (await client.clearAllSynonyms({ + indexName: 'indexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/*/batch'); + expect(req.path).toEqual('/1/indexes/indexName/synonyms/clear'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [ - { - action: 'addObject', - body: { key: 'value' }, - indexName: 'theIndexName', - }, - ], - }); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('deleteObject', () => { - test('deleteObject', async () => { - const req = (await client.deleteObject({ +describe('clearObjects', () => { + test('clearObjects', async () => { + const req = (await client.clearObjects({ indexName: 'theIndexName', - objectID: 'uniqueID', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/1/indexes/theIndexName/clear'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('searchUserIds', () => { - test('searchUserIds', async () => { - const req = (await client.searchUserIds({ - query: 'test', - clusterName: 'theClusterName', - page: 5, - hitsPerPage: 10, +describe('clearRules', () => { + test('clearRules', async () => { + const req = (await client.clearRules({ + indexName: 'indexName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/search'); + expect(req.path).toEqual('/1/indexes/indexName/rules/clear'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - query: 'test', - clusterName: 'theClusterName', - page: 5, - hitsPerPage: 10, - }); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('replaceSources', () => { - test('replaceSources', async () => { - const req = (await client.replaceSources({ - source: [{ source: 'theSource', description: 'theDescription' }], +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/security/sources'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual([ - { source: 'theSource', description: 'theDescription' }, - ]); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); + + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); }); -describe('removeUserId', () => { - test('removeUserId', async () => { - const req = (await client.removeUserId({ - userID: 'uniqueID', +describe('deleteApiKey', () => { + test('deleteApiKey', async () => { + const req = (await client.deleteApiKey({ + key: 'myTestApiKey', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); + expect(req.path).toEqual('/1/keys/myTestApiKey'); expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('getObject', () => { - test('getObject', async () => { - const req = (await client.getObject({ +describe('deleteBy', () => { + test('deleteBy', async () => { + const req = (await client.deleteBy({ + indexName: 'theIndexName', + searchParams: { query: 'testQuery' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/theIndexName/deleteByQuery'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ query: 'testQuery' }); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('deleteIndex', () => { + test('deleteIndex', async () => { + const req = (await client.deleteIndex({ + indexName: 'theIndexName', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/theIndexName'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('deleteObject', () => { + test('deleteObject', async () => { + const req = (await client.deleteObject({ indexName: 'theIndexName', objectID: 'uniqueID', - attributesToRetrieve: ['attr1', 'attr2'], })) as unknown as EchoResponse; expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID'); - expect(req.method).toEqual('GET'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ attributesToRetrieve: 'attr1,attr2' }); + expect(req.searchParams).toEqual(undefined); }); }); -describe('getApiKey', () => { - test('getApiKey', async () => { - const req = (await client.getApiKey({ - key: 'myTestApiKey', +describe('deleteRule', () => { + test('deleteRule', async () => { + const req = (await client.deleteRule({ + indexName: 'indexName', + objectID: 'id1', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys/myTestApiKey'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('assignUserId', () => { - test('assignUserId', async () => { - const req = (await client.assignUserId({ - xAlgoliaUserID: 'userID', - assignUserIdParams: { cluster: 'theCluster' }, +describe('deleteSource', () => { + test('deleteSource', async () => { + const req = (await client.deleteSource({ + source: 'theSource', })) as unknown as EchoResponse; - 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.path).toEqual('/1/security/sources/theSource'); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); }); }); @@ -443,14 +433,63 @@ describe('deleteSynonym', () => { }); }); -describe('searchSynonyms', () => { - test('searchSynonyms', async () => { - const req = (await client.searchSynonyms({ - indexName: 'indexName', +describe('get', () => { + test('allow get method for a custom path with minimal parameters', async () => { + const req = (await client.get({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/synonyms/search'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); + + test('allow get method for a custom path with all parameters', async () => { + const req = (await client.get({ + path: '/test/all', + parameters: { query: 'parameters' }, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ query: 'parameters' }); + }); +}); + +describe('getApiKey', () => { + test('getApiKey', async () => { + const req = (await client.getApiKey({ + key: 'myTestApiKey', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/keys/myTestApiKey'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('getDictionaryLanguages', () => { + test('get getDictionaryLanguages', async () => { + const req = + (await client.getDictionaryLanguages()) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/dictionaries/*/languages'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('getDictionarySettings', () => { + test('get getDictionarySettings results', async () => { + const req = + (await client.getDictionarySettings()) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/dictionaries/*/settings'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); @@ -477,75 +516,81 @@ describe('getLogs', () => { }); }); -describe('batch', () => { - test('batch', async () => { - const req = (await client.batch({ +describe('getObject', () => { + test('getObject', async () => { + const req = (await client.getObject({ indexName: 'theIndexName', - batchWriteParams: { - requests: [{ action: 'delete', body: { key: 'value' } }], - }, + objectID: 'uniqueID', + attributesToRetrieve: ['attr1', 'attr2'], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/batch'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - requests: [{ action: 'delete', body: { key: 'value' } }], - }); - expect(req.searchParams).toEqual(undefined); + 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' }); }); }); -describe('addOrUpdateObject', () => { - test('addOrUpdateObject', async () => { - const req = (await client.addOrUpdateObject({ - indexName: 'indexName', - objectID: 'uniqueID', - body: { key: 'value' }, +describe('getObjects', () => { + test('getObjects', async () => { + const req = (await client.getObjects({ + requests: [ + { + attributesToRetrieve: ['attr1', 'attr2'], + objectID: 'uniqueID', + indexName: 'theIndexName', + }, + ], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/uniqueID'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ key: 'value' }); + expect(req.path).toEqual('/1/indexes/*/objects'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ + requests: [ + { + attributesToRetrieve: ['attr1', 'attr2'], + objectID: 'uniqueID', + indexName: 'theIndexName', + }, + ], + }); expect(req.searchParams).toEqual(undefined); }); }); -describe('clearObjects', () => { - test('clearObjects', async () => { - const req = (await client.clearObjects({ - indexName: 'theIndexName', +describe('getRule', () => { + test('getRule', async () => { + const req = (await client.getRule({ + indexName: 'indexName', + objectID: 'id1', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/clear'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('setSettings', () => { - test('setSettings', async () => { - const req = (await client.setSettings({ +describe('getSettings', () => { + test('getSettings', async () => { + const req = (await client.getSettings({ indexName: 'theIndexName', - indexSettings: { paginationLimitedTo: 10 }, - forwardToReplicas: true, })) as unknown as EchoResponse; 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.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); }); }); -describe('clearRules', () => { - test('clearRules', async () => { - const req = (await client.clearRules({ - indexName: 'indexName', - })) as unknown as EchoResponse; +describe('getSources', () => { + test('getSources', async () => { + const req = (await client.getSources()) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/rules/clear'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/security/sources'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); @@ -565,84 +610,125 @@ describe('getSynonym', () => { }); }); -describe('deleteBy', () => { - test('deleteBy', async () => { - const req = (await client.deleteBy({ +describe('getTask', () => { + test('getTask', async () => { + const req = (await client.getTask({ indexName: 'theIndexName', - searchParams: { query: 'testQuery' }, + taskID: 123, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/deleteByQuery'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'testQuery' }); + expect(req.path).toEqual('/1/indexes/theIndexName/task/123'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('listUserIds', () => { - test('listUserIds', async () => { - const req = (await client.listUserIds({ - page: 8, - hitsPerPage: 100, - })) as unknown as EchoResponse; +describe('getTopUserIds', () => { + test('getTopUserIds', async () => { + const req = (await client.getTopUserIds()) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters/mapping'); + expect(req.path).toEqual('/1/clusters/mapping/top'); expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ page: '8', hitsPerPage: '100' }); + expect(req.searchParams).toEqual(undefined); }); }); -describe('browse', () => { - test('get browse results with minimal parameters', async () => { - const req = (await client.browse({ - indexName: 'indexName', +describe('getUserId', () => { + test('getUserId', async () => { + const req = (await client.getUserId({ + userID: 'uniqueID', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/browse'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); + expect(req.method).toEqual('GET'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); +}); - test('get browse results with all parameters', async () => { - const req = (await client.browse({ - indexName: 'indexName', - browseRequest: { - params: "query=foo&facetFilters=['bar']", - cursor: 'cts', - }, +describe('hasPendingMappings', () => { + test('hasPendingMappings', async () => { + const req = (await client.hasPendingMappings({ + getClusters: true, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/browse'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - params: "query=foo&facetFilters=['bar']", - cursor: 'cts', - }); + expect(req.path).toEqual('/1/clusters/mapping/pending'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ getClusters: 'true' }); + }); +}); + +describe('listApiKeys', () => { + test('listApiKeys', async () => { + const req = (await client.listApiKeys()) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/keys'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('getObjects', () => { - test('getObjects', async () => { - const req = (await client.getObjects({ +describe('listClusters', () => { + test('listClusters', async () => { + const req = (await client.listClusters()) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/clusters'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual(undefined); + }); +}); + +describe('listIndices', () => { + test('listIndices', async () => { + const req = (await client.listIndices({ + page: 8, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes'); + expect(req.method).toEqual('GET'); + expect(req.data).toEqual(undefined); + expect(req.searchParams).toEqual({ page: '8' }); + }); +}); + +describe('listUserIds', () => { + test('listUserIds', async () => { + const req = (await client.listUserIds({ + page: 8, + hitsPerPage: 100, + })) as unknown as EchoResponse; + + 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' }); + }); +}); + +describe('multipleBatch', () => { + test('multipleBatch', async () => { + const req = (await client.multipleBatch({ requests: [ { - attributesToRetrieve: ['attr1', 'attr2'], - objectID: 'uniqueID', + action: 'addObject', + body: { key: 'value' }, indexName: 'theIndexName', }, ], })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/*/objects'); + expect(req.path).toEqual('/1/indexes/*/batch'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ requests: [ { - attributesToRetrieve: ['attr1', 'attr2'], - objectID: 'uniqueID', + action: 'addObject', + body: { key: 'value' }, indexName: 'theIndexName', }, ], @@ -651,26 +737,6 @@ describe('getObjects', () => { }); }); -describe('partialUpdateObject', () => { - test('partialUpdateObject', async () => { - const req = (await client.partialUpdateObject({ - indexName: 'theIndexName', - objectID: 'uniqueID', - attributeOrBuiltInOperation: [ - { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, - ], - createIfNotExists: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual([ - { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, - ]); - expect(req.searchParams).toEqual({ createIfNotExists: 'true' }); - }); -}); - describe('multipleQueries', () => { test('multipleQueries for a single request with minimal parameters', async () => { const req = (await client.multipleQueries({ @@ -731,139 +797,203 @@ describe('multipleQueries', () => { }); }); -describe('searchForFacetValues', () => { - test('get searchForFacetValues results with minimal parameters', async () => { - const req = (await client.searchForFacetValues({ - indexName: 'indexName', - facetName: 'facetName', +describe('operationIndex', () => { + test('operationIndex', async () => { + const req = (await client.operationIndex({ + indexName: 'theIndexName', + operationIndexParams: { + operation: 'copy', + destination: 'dest', + scope: ['rules', 'settings'], + }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); + expect(req.path).toEqual('/1/indexes/theIndexName/operation'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); + expect(req.data).toEqual({ + operation: 'copy', + destination: 'dest', + scope: ['rules', 'settings'], + }); expect(req.searchParams).toEqual(undefined); }); +}); - test('get searchForFacetValues results with all parameters', async () => { - const req = (await client.searchForFacetValues({ - indexName: 'indexName', - facetName: 'facetName', - searchForFacetValuesRequest: { - params: "query=foo&facetFilters=['bar']", - facetQuery: 'foo', - maxFacetHits: 42, - }, +describe('partialUpdateObject', () => { + test('partialUpdateObject', async () => { + const req = (await client.partialUpdateObject({ + indexName: 'theIndexName', + objectID: 'uniqueID', + attributeOrBuiltInOperation: [ + { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, + ], + createIfNotExists: true, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); + expect(req.path).toEqual('/1/indexes/theIndexName/uniqueID/partial'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ - params: "query=foo&facetFilters=['bar']", - facetQuery: 'foo', - maxFacetHits: 42, - }); - expect(req.searchParams).toEqual(undefined); + expect(req.data).toEqual([ + { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, + ]); + expect(req.searchParams).toEqual({ createIfNotExists: 'true' }); }); }); -describe('getSettings', () => { - test('getSettings', async () => { - const req = (await client.getSettings({ - indexName: 'theIndexName', +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ + path: '/test/minimal', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/settings'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); -}); -describe('listIndices', () => { - test('listIndices', async () => { - const req = (await client.listIndices({ - page: 8, + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ page: '8' }); + expect(req.path).toEqual('/1/test/all'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('getDictionarySettings', () => { - test('get getDictionarySettings results', async () => { - const req = - (await client.getDictionarySettings()) as unknown as EchoResponse; +describe('put', () => { + test('allow put method for a custom path with minimal parameters', async () => { + const req = (await client.put({ + path: '/test/minimal', + })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/test/minimal'); + expect(req.method).toEqual('PUT'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); -}); -describe('deleteSource', () => { - test('deleteSource', async () => { - const req = (await client.deleteSource({ - source: 'theSource', + test('allow put method for a custom path with all parameters', async () => { + const req = (await client.put({ + path: '/test/all', + parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; - 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.path).toEqual('/1/test/all'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ body: 'parameters' }); + expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); -describe('getSources', () => { - test('getSources', async () => { - const req = (await client.getSources()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/security/sources'); - expect(req.method).toEqual('GET'); +describe('removeUserId', () => { + test('removeUserId', async () => { + const req = (await client.removeUserId({ + userID: 'uniqueID', + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('getDictionaryLanguages', () => { - test('get getDictionaryLanguages', async () => { - const req = - (await client.getDictionaryLanguages()) as unknown as EchoResponse; +describe('replaceSources', () => { + test('replaceSources', async () => { + const req = (await client.replaceSources({ + source: [{ source: 'theSource', description: 'theDescription' }], + })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/*/languages'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); + expect(req.path).toEqual('/1/security/sources'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual([ + { source: 'theSource', description: 'theDescription' }, + ]); expect(req.searchParams).toEqual(undefined); }); }); -describe('deleteApiKey', () => { - test('deleteApiKey', async () => { - const req = (await client.deleteApiKey({ - key: 'myTestApiKey', +describe('restoreApiKey', () => { + test('restoreApiKey', async () => { + const req = (await client.restoreApiKey({ + key: 'myApiKey', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys/myTestApiKey'); - expect(req.method).toEqual('DELETE'); + expect(req.path).toEqual('/1/keys/myApiKey/restore'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('listApiKeys', () => { - test('listApiKeys', async () => { - const req = (await client.listApiKeys()) as unknown as EchoResponse; +describe('saveObject', () => { + test('saveObject', async () => { + const req = (await client.saveObject({ + indexName: 'theIndexName', + body: { objectID: 'id', test: 'val' }, + })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); + 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); }); }); +describe('saveRule', () => { + test('saveRule', async () => { + const req = (await client.saveRule({ + indexName: 'indexName', + objectID: 'id1', + rule: { + objectID: 'id1', + conditions: [{ pattern: 'apple', anchoring: 'contains' }], + consequence: { params: { filters: 'brand:apple' } }, + }, + forwardToReplicas: true, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ + objectID: 'id1', + conditions: [{ pattern: 'apple', anchoring: 'contains' }], + consequence: { params: { filters: 'brand:apple' } }, + }); + expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + }); +}); + +describe('saveSynonym', () => { + test('saveSynonym', async () => { + const req = (await client.saveSynonym({ + indexName: 'indexName', + objectID: 'id1', + synonymHit: { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + forwardToReplicas: true, + })) as unknown as EchoResponse; + + expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }); + expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); + }); +}); + describe('saveSynonyms', () => { test('saveSynonyms', async () => { const req = (await client.saveSynonyms({ @@ -936,295 +1066,192 @@ describe('search', () => { }); }); -describe('get', () => { - test('allow get method for a custom path with minimal parameters', async () => { - const req = (await client.get({ - path: '/test/minimal', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); - - test('allow get method for a custom path with all parameters', async () => { - const req = (await client.get({ - path: '/test/all', - parameters: { query: 'parameters' }, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ query: 'parameters' }); - }); -}); - -describe('hasPendingMappings', () => { - test('hasPendingMappings', async () => { - const req = (await client.hasPendingMappings({ - getClusters: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/pending'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual({ getClusters: 'true' }); - }); -}); - -describe('getTopUserIds', () => { - test('getTopUserIds', async () => { - const req = (await client.getTopUserIds()) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/top'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('setDictionarySettings', () => { - test('get setDictionarySettings results with minimal parameters', async () => { - const req = (await client.setDictionarySettings({ - disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, +describe('searchDictionaryEntries', () => { + test('get searchDictionaryEntries results with minimal parameters', async () => { + const req = (await client.searchDictionaryEntries({ + dictionaryName: 'compounds', + searchDictionaryEntriesParams: { query: 'foo' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, - }); + expect(req.path).toEqual('/1/dictionaries/compounds/search'); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ query: 'foo' }); expect(req.searchParams).toEqual(undefined); }); - test('get setDictionarySettings results with all parameters', async () => { - const req = (await client.setDictionarySettings({ - disableStandardEntries: { - plurals: { fr: false, en: false, ru: true }, - stopwords: { fr: false }, - compounds: { ru: true }, + test('get searchDictionaryEntries results with all parameters', async () => { + const req = (await client.searchDictionaryEntries({ + dictionaryName: 'compounds', + searchDictionaryEntriesParams: { + query: 'foo', + page: 4, + hitsPerPage: 2, + language: 'fr', }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/*/settings'); - expect(req.method).toEqual('PUT'); + expect(req.path).toEqual('/1/dictionaries/compounds/search'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - disableStandardEntries: { - plurals: { fr: false, en: false, ru: true }, - stopwords: { fr: false }, - compounds: { ru: true }, - }, + query: 'foo', + page: 4, + hitsPerPage: 2, + language: 'fr', }); expect(req.searchParams).toEqual(undefined); }); }); -describe('deleteRule', () => { - test('deleteRule', async () => { - const req = (await client.deleteRule({ - indexName: 'indexName', - objectID: 'id1', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('saveRule', () => { - test('saveRule', async () => { - const req = (await client.saveRule({ +describe('searchForFacetValues', () => { + test('get searchForFacetValues results with minimal parameters', async () => { + const req = (await client.searchForFacetValues({ indexName: 'indexName', - objectID: 'id1', - rule: { - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains' }], - consequence: { params: { filters: 'brand:apple' } }, - }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains' }], - consequence: { params: { filters: 'brand:apple' } }, - }); - expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); - }); -}); - -describe('saveObject', () => { - test('saveObject', async () => { - const req = (await client.saveObject({ - indexName: 'theIndexName', - body: { objectID: 'id', test: 'val' }, + facetName: 'facetName', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName'); + expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ objectID: 'id', test: 'val' }); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); -}); -describe('saveSynonym', () => { - test('saveSynonym', async () => { - const req = (await client.saveSynonym({ + test('get searchForFacetValues results with all parameters', async () => { + const req = (await client.searchForFacetValues({ indexName: 'indexName', - objectID: 'id1', - synonymHit: { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], + facetName: 'facetName', + searchForFacetValuesRequest: { + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, }, - forwardToReplicas: true, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/indexName/synonyms/id1'); - expect(req.method).toEqual('PUT'); - expect(req.data).toEqual({ - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }); - expect(req.searchParams).toEqual({ forwardToReplicas: 'true' }); - }); -}); - -describe('appendSource', () => { - test('appendSource', async () => { - const req = (await client.appendSource({ - source: 'theSource', - description: 'theDescription', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/security/sources/append'); + expect(req.path).toEqual('/1/indexes/indexName/facets/facetName/query'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - source: 'theSource', - description: 'theDescription', + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, }); expect(req.searchParams).toEqual(undefined); }); }); -describe('clearAllSynonyms', () => { - test('clearAllSynonyms', async () => { - const req = (await client.clearAllSynonyms({ +describe('searchRules', () => { + test('searchRules', async () => { + const req = (await client.searchRules({ indexName: 'indexName', + searchRulesParams: { query: 'something' }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/synonyms/clear'); + expect(req.path).toEqual('/1/indexes/indexName/rules/search'); expect(req.method).toEqual('POST'); - expect(req.data).toEqual(undefined); + expect(req.data).toEqual({ query: 'something' }); expect(req.searchParams).toEqual(undefined); }); }); -describe('getRule', () => { - test('getRule', async () => { - const req = (await client.getRule({ +describe('searchSynonyms', () => { + test('searchSynonyms', async () => { + const req = (await client.searchSynonyms({ indexName: 'indexName', - objectID: 'id1', })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/indexName/rules/id1'); - expect(req.method).toEqual('GET'); + expect(req.path).toEqual('/1/indexes/indexName/synonyms/search'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); }); -describe('operationIndex', () => { - test('operationIndex', async () => { - const req = (await client.operationIndex({ - indexName: 'theIndexName', - operationIndexParams: { - operation: 'copy', - destination: 'dest', - scope: ['rules', 'settings'], - }, +describe('searchUserIds', () => { + test('searchUserIds', async () => { + const req = (await client.searchUserIds({ + query: 'test', + clusterName: 'theClusterName', + page: 5, + hitsPerPage: 10, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/indexes/theIndexName/operation'); + expect(req.path).toEqual('/1/clusters/mapping/search'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - operation: 'copy', - destination: 'dest', - scope: ['rules', 'settings'], + query: 'test', + clusterName: 'theClusterName', + page: 5, + hitsPerPage: 10, }); expect(req.searchParams).toEqual(undefined); }); }); -describe('searchDictionaryEntries', () => { - test('get searchDictionaryEntries results with minimal parameters', async () => { - const req = (await client.searchDictionaryEntries({ - dictionaryName: 'compounds', - searchDictionaryEntriesParams: { query: 'foo' }, +describe('setDictionarySettings', () => { + test('get setDictionarySettings results with minimal parameters', async () => { + const req = (await client.setDictionarySettings({ + disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/compounds/search'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ query: 'foo' }); + expect(req.path).toEqual('/1/dictionaries/*/settings'); + expect(req.method).toEqual('PUT'); + expect(req.data).toEqual({ + disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, + }); expect(req.searchParams).toEqual(undefined); }); - test('get searchDictionaryEntries results with all parameters', async () => { - const req = (await client.searchDictionaryEntries({ - dictionaryName: 'compounds', - searchDictionaryEntriesParams: { - query: 'foo', - page: 4, - hitsPerPage: 2, - language: 'fr', + test('get setDictionarySettings results with all parameters', async () => { + const req = (await client.setDictionarySettings({ + disableStandardEntries: { + plurals: { fr: false, en: false, ru: true }, + stopwords: { fr: false }, + compounds: { ru: true }, }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/dictionaries/compounds/search'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/dictionaries/*/settings'); + expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ - query: 'foo', - page: 4, - hitsPerPage: 2, - language: 'fr', + disableStandardEntries: { + plurals: { fr: false, en: false, ru: true }, + stopwords: { fr: false }, + compounds: { ru: true }, + }, }); expect(req.searchParams).toEqual(undefined); }); }); -describe('listClusters', () => { - test('listClusters', async () => { - const req = (await client.listClusters()) as unknown as EchoResponse; +describe('setSettings', () => { + test('setSettings', async () => { + const req = (await client.setSettings({ + indexName: 'theIndexName', + indexSettings: { paginationLimitedTo: 10 }, + forwardToReplicas: true, + })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/clusters'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); + 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' }); }); }); -describe('addApiKey', () => { - test('addApiKey', async () => { - const req = (await client.addApiKey({ - acl: ['search', 'addObject'], - description: 'my new api key', - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, +describe('updateApiKey', () => { + test('updateApiKey', async () => { + const req = (await client.updateApiKey({ + key: 'myApiKey', + apiKey: { + acl: ['search', 'addObject'], + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, + }, })) as unknown as EchoResponse; - expect(req.path).toEqual('/1/keys'); - expect(req.method).toEqual('POST'); + expect(req.path).toEqual('/1/keys/myApiKey'); + expect(req.method).toEqual('PUT'); expect(req.data).toEqual({ acl: ['search', 'addObject'], - description: 'my new api key', validity: 300, maxQueriesPerIPPerHour: 100, maxHitsPerQuery: 20, @@ -1232,30 +1259,3 @@ describe('addApiKey', () => { expect(req.searchParams).toEqual(undefined); }); }); - -describe('getTask', () => { - test('getTask', async () => { - const req = (await client.getTask({ - indexName: 'theIndexName', - taskID: 123, - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/indexes/theIndexName/task/123'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); - -describe('getUserId', () => { - test('getUserId', async () => { - const req = (await client.getUserId({ - userID: 'uniqueID', - })) as unknown as EchoResponse; - - expect(req.path).toEqual('/1/clusters/mapping/uniqueID'); - expect(req.method).toEqual('GET'); - expect(req.data).toEqual(undefined); - expect(req.searchParams).toEqual(undefined); - }); -}); diff --git a/tests/output/javascript/src/methods/requests/sources.test.ts b/tests/output/javascript/src/methods/requests/sources.test.ts index 1a3b852e22..e5d2af95fc 100644 --- a/tests/output/javascript/src/methods/requests/sources.test.ts +++ b/tests/output/javascript/src/methods/requests/sources.test.ts @@ -9,28 +9,27 @@ const client = sourcesClient(appId, apiKey, 'us', { requester: echoRequester(), }); -describe('post', () => { - test('allow post method for a custom path with minimal parameters', async () => { - const req = (await client.post({ +describe('del', () => { + test('allow del method for a custom path with minimal parameters', async () => { + const req = (await client.del({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('POST'); + expect(req.method).toEqual('DELETE'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow post method for a custom path with all parameters', async () => { - const req = (await client.post({ + test('allow del method for a custom path with all parameters', async () => { + const req = (await client.del({ path: '/test/all', parameters: { query: 'parameters' }, - body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('POST'); - expect(req.data).toEqual({ body: 'parameters' }); + expect(req.method).toEqual('DELETE'); + expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); @@ -60,27 +59,28 @@ describe('get', () => { }); }); -describe('del', () => { - test('allow del method for a custom path with minimal parameters', async () => { - const req = (await client.del({ +describe('post', () => { + test('allow post method for a custom path with minimal parameters', async () => { + const req = (await client.post({ path: '/test/minimal', })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/minimal'); - expect(req.method).toEqual('DELETE'); + expect(req.method).toEqual('POST'); expect(req.data).toEqual(undefined); expect(req.searchParams).toEqual(undefined); }); - test('allow del method for a custom path with all parameters', async () => { - const req = (await client.del({ + test('allow post method for a custom path with all parameters', async () => { + const req = (await client.post({ path: '/test/all', parameters: { query: 'parameters' }, + body: { body: 'parameters' }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/test/all'); - expect(req.method).toEqual('DELETE'); - expect(req.data).toEqual(undefined); + expect(req.method).toEqual('POST'); + expect(req.data).toEqual({ body: 'parameters' }); expect(req.searchParams).toEqual({ query: 'parameters' }); }); }); diff --git a/tests/output/php/src/methods/requests/AbtestingTest.php b/tests/output/php/src/methods/requests/AbtestingTest.php index e5a517cd27..255937ad9b 100644 --- a/tests/output/php/src/methods/requests/AbtestingTest.php +++ b/tests/output/php/src/methods/requests/AbtestingTest.php @@ -77,110 +77,90 @@ protected function getClient() } /** - * Test case for DeleteABTest - * deleteABTest + * Test case for AddABTests + * addABTests with minimal parameters */ - public function testDeleteABTest0() + public function testAddABTests0() { $client = $this->getClient(); - $client->deleteABTest(42); + $client->addABTests([ + 'endAt' => '2022-12-31T00:00:00.000Z', + + 'name' => 'myABTest', + + 'variant' => [ + ['index' => 'AB_TEST_1', 'trafficPercentage' => 30], + + ['index' => 'AB_TEST_2', 'trafficPercentage' => 50], + ], + ]); $this->assertRequests([ [ - 'path' => '/2/abtests/42', - 'method' => 'DELETE', + 'path' => '/2/abtests', + 'method' => 'POST', + 'body' => json_decode( + "{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}" + ), ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testPost0() + public function testDel0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->del('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'POST', + 'method' => 'DELETE', ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testPost1() + public function testDel1() { $client = $this->getClient(); - $client->post( + $client->del( '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + ['query' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), + 'method' => 'DELETE', 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for StopABTest - * stopABTest - */ - public function testStopABTest0() - { - $client = $this->getClient(); - - $client->stopABTest(42); - - $this->assertRequests([ - [ - 'path' => '/2/abtests/42/stop', - 'method' => 'POST', - ], - ]); - } - - /** - * Test case for AddABTests - * addABTests with minimal parameters + * Test case for DeleteABTest + * deleteABTest */ - public function testAddABTests0() + public function testDeleteABTest0() { $client = $this->getClient(); - $client->addABTests([ - 'endAt' => '2022-12-31T00:00:00.000Z', - - 'name' => 'myABTest', - - 'variant' => [ - ['index' => 'AB_TEST_1', 'trafficPercentage' => 30], - - ['index' => 'AB_TEST_2', 'trafficPercentage' => 50], - ], - ]); + $client->deleteABTest(42); $this->assertRequests([ [ - 'path' => '/2/abtests', - 'method' => 'POST', - 'body' => json_decode( - "{\"endAt\":\"2022-12-31T00:00:00.000Z\",\"name\":\"myABTest\",\"variant\":[{\"index\":\"AB_TEST_1\",\"trafficPercentage\":30},{\"index\":\"AB_TEST_2\",\"trafficPercentage\":50}]}" - ), + 'path' => '/2/abtests/42', + 'method' => 'DELETE', ], ]); } @@ -225,6 +205,24 @@ public function testGet1() ]); } + /** + * Test case for GetABTest + * getABTest + */ + public function testGetABTest0() + { + $client = $this->getClient(); + + $client->getABTest(42); + + $this->assertRequests([ + [ + 'path' => '/2/abtests/42', + 'method' => 'GET', + ], + ]); + } + /** * Test case for ListABTests * listABTests with minimal parameters @@ -250,40 +248,42 @@ public function testListABTests0() } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testDel0() + public function testPost0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->post('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'method' => 'POST', ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testDel1() + public function testPost1() { $client = $this->getClient(); - $client->del( + $client->post( '/test/all', - ['query' => 'parameters'] + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'DELETE', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); @@ -332,19 +332,19 @@ public function testPut1() } /** - * Test case for GetABTest - * getABTest + * Test case for StopABTest + * stopABTest */ - public function testGetABTest0() + public function testStopABTest0() { $client = $this->getClient(); - $client->getABTest(42); + $client->stopABTest(42); $this->assertRequests([ [ - 'path' => '/2/abtests/42', - 'method' => 'GET', + 'path' => '/2/abtests/42/stop', + 'method' => 'POST', ], ]); } diff --git a/tests/output/php/src/methods/requests/AnalyticsTest.php b/tests/output/php/src/methods/requests/AnalyticsTest.php index f6bb2c51cf..a64a4ff459 100644 --- a/tests/output/php/src/methods/requests/AnalyticsTest.php +++ b/tests/output/php/src/methods/requests/AnalyticsTest.php @@ -77,157 +77,143 @@ protected function getClient() } /** - * Test case for GetTopSearches - * get getTopSearches with minimal parameters + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testGetTopSearches0() + public function testDel0() { $client = $this->getClient(); - $client->getTopSearches('index'); + $client->del('/test/minimal'); $this->assertRequests([ [ - 'path' => '/2/searches', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'path' => '/1/test/minimal', + 'method' => 'DELETE', ], ]); } /** - * Test case for GetTopSearches - * get getTopSearches with all parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testGetTopSearches1() + public function testDel1() { $client = $this->getClient(); - $client->getTopSearches( - 'index', - true, - '1999-09-19', - '2001-01-01', - 'searchCount', - 'asc', - 21, - 42, - 'tag' + $client->del( + '/test/all', + ['query' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/searches', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" - ), + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for GetTopHits - * get getTopHits with minimal parameters + * Test case for Get + * allow get method for a custom path with minimal parameters */ - public function testGetTopHits0() + public function testGet0() { $client = $this->getClient(); - $client->getTopHits('index'); + $client->get('/test/minimal'); $this->assertRequests([ [ - 'path' => '/2/hits', + 'path' => '/1/test/minimal', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for GetTopHits - * get getTopHits with all parameters + * Test case for Get + * allow get method for a custom path with all parameters */ - public function testGetTopHits1() + public function testGet1() { $client = $this->getClient(); - $client->getTopHits( - 'index', - 'mySearch', - true, - '1999-09-19', - '2001-01-01', - 21, - 42, - 'tag' + $client->get( + '/test/all', + ['query' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/hits', + 'path' => '/1/test/all', 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" - ), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for GetAverageClickPosition + * get getAverageClickPosition with minimal parameters */ - public function testDel0() + public function testGetAverageClickPosition0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->getAverageClickPosition('index'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'path' => '/2/clicks/averageClickPosition', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for GetAverageClickPosition + * get getAverageClickPosition with all parameters */ - public function testDel1() + public function testGetAverageClickPosition1() { $client = $this->getClient(); - $client->del( - '/test/all', - ['query' => 'parameters'] + $client->getAverageClickPosition( + 'index', + '1999-09-19', + '2001-01-01', + 'tag' ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/2/clicks/averageClickPosition', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for GetTopFiltersNoResults - * get getTopFiltersNoResults with minimal parameters + * Test case for GetClickPositions + * get getClickPositions with minimal parameters */ - public function testGetTopFiltersNoResults0() + public function testGetClickPositions0() { $client = $this->getClient(); - $client->getTopFiltersNoResults('index'); + $client->getClickPositions('index'); $this->assertRequests([ [ - 'path' => '/2/filters/noResults', + 'path' => '/2/clicks/positions', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -235,47 +221,44 @@ public function testGetTopFiltersNoResults0() } /** - * Test case for GetTopFiltersNoResults - * get getTopFiltersNoResults with all parameters + * Test case for GetClickPositions + * get getClickPositions with all parameters */ - public function testGetTopFiltersNoResults1() + public function testGetClickPositions1() { $client = $this->getClient(); - $client->getTopFiltersNoResults( + $client->getClickPositions( 'index', - 'mySearch', '1999-09-19', '2001-01-01', - 21, - 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/filters/noResults', + 'path' => '/2/clicks/positions', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetSearchesNoResults - * get getSearchesNoResults with minimal parameters + * Test case for GetClickThroughRate + * get getClickThroughRate with minimal parameters */ - public function testGetSearchesNoResults0() + public function testGetClickThroughRate0() { $client = $this->getClient(); - $client->getSearchesNoResults('index'); + $client->getClickThroughRate('index'); $this->assertRequests([ [ - 'path' => '/2/searches/noResults', + 'path' => '/2/clicks/clickThroughRate', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -283,46 +266,44 @@ public function testGetSearchesNoResults0() } /** - * Test case for GetSearchesNoResults - * get getSearchesNoResults with all parameters + * Test case for GetClickThroughRate + * get getClickThroughRate with all parameters */ - public function testGetSearchesNoResults1() + public function testGetClickThroughRate1() { $client = $this->getClient(); - $client->getSearchesNoResults( + $client->getClickThroughRate( 'index', '1999-09-19', '2001-01-01', - 21, - 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/searches/noResults', + 'path' => '/2/clicks/clickThroughRate', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetStatus - * get getStatus with minimal parameters + * Test case for GetConversationRate + * get getConversationRate with minimal parameters */ - public function testGetStatus0() + public function testGetConversationRate0() { $client = $this->getClient(); - $client->getStatus('index'); + $client->getConversationRate('index'); $this->assertRequests([ [ - 'path' => '/2/status', + 'path' => '/2/conversions/conversionRate', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -330,18 +311,44 @@ public function testGetStatus0() } /** - * Test case for GetClickPositions - * get getClickPositions with minimal parameters + * Test case for GetConversationRate + * get getConversationRate with all parameters */ - public function testGetClickPositions0() + public function testGetConversationRate1() { $client = $this->getClient(); - $client->getClickPositions('index'); + $client->getConversationRate( + 'index', + '1999-09-19', + '2001-01-01', + 'tag' + ); $this->assertRequests([ [ - 'path' => '/2/clicks/positions', + 'path' => '/2/conversions/conversionRate', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + ), + ], + ]); + } + + /** + * Test case for GetNoClickRate + * get getNoClickRate with minimal parameters + */ + public function testGetNoClickRate0() + { + $client = $this->getClient(); + + $client->getNoClickRate('index'); + + $this->assertRequests([ + [ + 'path' => '/2/searches/noClickRate', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -349,14 +356,14 @@ public function testGetClickPositions0() } /** - * Test case for GetClickPositions - * get getClickPositions with all parameters + * Test case for GetNoClickRate + * get getNoClickRate with all parameters */ - public function testGetClickPositions1() + public function testGetNoClickRate1() { $client = $this->getClient(); - $client->getClickPositions( + $client->getNoClickRate( 'index', '1999-09-19', '2001-01-01', @@ -365,7 +372,7 @@ public function testGetClickPositions1() $this->assertRequests([ [ - 'path' => '/2/clicks/positions', + 'path' => '/2/searches/noClickRate', 'method' => 'GET', 'searchParams' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" @@ -375,63 +382,63 @@ public function testGetClickPositions1() } /** - * Test case for Put - * allow put method for a custom path with minimal parameters + * Test case for GetNoResultsRate + * get getNoResultsRate with minimal parameters */ - public function testPut0() + public function testGetNoResultsRate0() { $client = $this->getClient(); - $client->put('/test/minimal'); + $client->getNoResultsRate('index'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'PUT', + 'path' => '/2/searches/noResultRate', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for Put - * allow put method for a custom path with all parameters + * Test case for GetNoResultsRate + * get getNoResultsRate with all parameters */ - public function testPut1() + public function testGetNoResultsRate1() { $client = $this->getClient(); - $client->put( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + $client->getNoResultsRate( + 'index', + '1999-09-19', + '2001-01-01', + 'tag' ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'PUT', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/2/searches/noResultRate', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with minimal parameters + * Test case for GetSearchesCount + * get getSearchesCount with minimal parameters */ - public function testGetTopFilterForAttribute0() + public function testGetSearchesCount0() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute', - 'index' - ); + $client->getSearchesCount('index'); $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute', + 'path' => '/2/searches/count', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -439,69 +446,60 @@ public function testGetTopFilterForAttribute0() } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with minimal parameters and multiple attributes + * Test case for GetSearchesCount + * get getSearchesCount with all parameters */ - public function testGetTopFilterForAttribute1() + public function testGetSearchesCount1() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute1,myAttribute2', - 'index' + $client->getSearchesCount( + 'index', + '1999-09-19', + '2001-01-01', + 'tag' ); $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute1%2CmyAttribute2', + 'path' => '/2/searches/count', 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'searchParams' => json_decode( + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with all parameters + * Test case for GetSearchesNoClicks + * get getSearchesNoClicks with minimal parameters */ - public function testGetTopFilterForAttribute2() + public function testGetSearchesNoClicks0() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute', - 'index', - 'mySearch', - '1999-09-19', - '2001-01-01', - 21, - 42, - 'tag' - ); + $client->getSearchesNoClicks('index'); $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute', + 'path' => '/2/searches/noClicks', 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" - ), + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for GetTopFilterForAttribute - * get getTopFilterForAttribute with all parameters and multiple attributes + * Test case for GetSearchesNoClicks + * get getSearchesNoClicks with all parameters */ - public function testGetTopFilterForAttribute3() + public function testGetSearchesNoClicks1() { $client = $this->getClient(); - $client->getTopFilterForAttribute( - 'myAttribute1,myAttribute2', + $client->getSearchesNoClicks( 'index', - 'mySearch', '1999-09-19', '2001-01-01', 21, @@ -511,28 +509,28 @@ public function testGetTopFilterForAttribute3() $this->assertRequests([ [ - 'path' => '/2/filters/myAttribute1%2CmyAttribute2', + 'path' => '/2/searches/noClicks', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetNoClickRate - * get getNoClickRate with minimal parameters + * Test case for GetSearchesNoResults + * get getSearchesNoResults with minimal parameters */ - public function testGetNoClickRate0() + public function testGetSearchesNoResults0() { $client = $this->getClient(); - $client->getNoClickRate('index'); + $client->getSearchesNoResults('index'); $this->assertRequests([ [ - 'path' => '/2/searches/noClickRate', + 'path' => '/2/searches/noResults', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -540,44 +538,46 @@ public function testGetNoClickRate0() } /** - * Test case for GetNoClickRate - * get getNoClickRate with all parameters + * Test case for GetSearchesNoResults + * get getSearchesNoResults with all parameters */ - public function testGetNoClickRate1() + public function testGetSearchesNoResults1() { $client = $this->getClient(); - $client->getNoClickRate( + $client->getSearchesNoResults( 'index', '1999-09-19', '2001-01-01', + 21, + 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/searches/noClickRate', + 'path' => '/2/searches/noResults', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetUsersCount - * get getUsersCount with minimal parameters + * Test case for GetStatus + * get getStatus with minimal parameters */ - public function testGetUsersCount0() + public function testGetStatus0() { $client = $this->getClient(); - $client->getUsersCount('index'); + $client->getStatus('index'); $this->assertRequests([ [ - 'path' => '/2/users/count', + 'path' => '/2/status', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -585,44 +585,65 @@ public function testGetUsersCount0() } /** - * Test case for GetUsersCount - * get getUsersCount with all parameters + * Test case for GetTopCountries + * get getTopCountries with minimal parameters */ - public function testGetUsersCount1() + public function testGetTopCountries0() { $client = $this->getClient(); - $client->getUsersCount( + $client->getTopCountries('index'); + + $this->assertRequests([ + [ + 'path' => '/2/countries', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), + ], + ]); + } + + /** + * Test case for GetTopCountries + * get getTopCountries with all parameters + */ + public function testGetTopCountries1() + { + $client = $this->getClient(); + + $client->getTopCountries( 'index', '1999-09-19', '2001-01-01', + 21, + 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/users/count', + 'path' => '/2/countries', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetSearchesNoClicks - * get getSearchesNoClicks with minimal parameters + * Test case for GetTopFilterAttributes + * get getTopFilterAttributes with minimal parameters */ - public function testGetSearchesNoClicks0() + public function testGetTopFilterAttributes0() { $client = $this->getClient(); - $client->getSearchesNoClicks('index'); + $client->getTopFilterAttributes('index'); $this->assertRequests([ [ - 'path' => '/2/searches/noClicks', + 'path' => '/2/filters', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -630,15 +651,16 @@ public function testGetSearchesNoClicks0() } /** - * Test case for GetSearchesNoClicks - * get getSearchesNoClicks with all parameters + * Test case for GetTopFilterAttributes + * get getTopFilterAttributes with all parameters */ - public function testGetSearchesNoClicks1() + public function testGetTopFilterAttributes1() { $client = $this->getClient(); - $client->getSearchesNoClicks( + $client->getTopFilterAttributes( 'index', + 'mySearch', '1999-09-19', '2001-01-01', 21, @@ -648,70 +670,53 @@ public function testGetSearchesNoClicks1() $this->assertRequests([ [ - 'path' => '/2/searches/noClicks', + 'path' => '/2/filters', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters - */ - public function testPost0() - { - $client = $this->getClient(); - - $client->post('/test/minimal'); - - $this->assertRequests([ - [ - 'path' => '/1/test/minimal', - 'method' => 'POST', - ], - ]); - } - - /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with minimal parameters */ - public function testPost1() + public function testGetTopFilterForAttribute0() { $client = $this->getClient(); - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + $client->getTopFilterForAttribute( + 'myAttribute', + 'index' ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/2/filters/myAttribute', + 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for GetAverageClickPosition - * get getAverageClickPosition with minimal parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with minimal parameters and multiple attributes */ - public function testGetAverageClickPosition0() + public function testGetTopFilterForAttribute1() { $client = $this->getClient(); - $client->getAverageClickPosition('index'); + $client->getTopFilterForAttribute( + 'myAttribute1,myAttribute2', + 'index' + ); $this->assertRequests([ [ - 'path' => '/2/clicks/averageClickPosition', + 'path' => '/2/filters/myAttribute1%2CmyAttribute2', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -719,129 +724,126 @@ public function testGetAverageClickPosition0() } /** - * Test case for GetAverageClickPosition - * get getAverageClickPosition with all parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with all parameters */ - public function testGetAverageClickPosition1() + public function testGetTopFilterForAttribute2() { $client = $this->getClient(); - $client->getAverageClickPosition( + $client->getTopFilterForAttribute( + 'myAttribute', 'index', + 'mySearch', '1999-09-19', '2001-01-01', + 21, + 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/clicks/averageClickPosition', + 'path' => '/2/filters/myAttribute', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetSearchesCount - * get getSearchesCount with minimal parameters - */ - public function testGetSearchesCount0() - { - $client = $this->getClient(); - - $client->getSearchesCount('index'); - - $this->assertRequests([ - [ - 'path' => '/2/searches/count', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), - ], - ]); - } - - /** - * Test case for GetSearchesCount - * get getSearchesCount with all parameters + * Test case for GetTopFilterForAttribute + * get getTopFilterForAttribute with all parameters and multiple attributes */ - public function testGetSearchesCount1() + public function testGetTopFilterForAttribute3() { $client = $this->getClient(); - $client->getSearchesCount( + $client->getTopFilterForAttribute( + 'myAttribute1,myAttribute2', 'index', + 'mySearch', '1999-09-19', '2001-01-01', + 21, + 42, 'tag' ); $this->assertRequests([ [ - 'path' => '/2/searches/count', + 'path' => '/2/filters/myAttribute1%2CmyAttribute2', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for Get - * allow get method for a custom path with minimal parameters + * Test case for GetTopFiltersNoResults + * get getTopFiltersNoResults with minimal parameters */ - public function testGet0() + public function testGetTopFiltersNoResults0() { $client = $this->getClient(); - $client->get('/test/minimal'); + $client->getTopFiltersNoResults('index'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', + 'path' => '/2/filters/noResults', 'method' => 'GET', + 'searchParams' => json_decode("{\"index\":\"index\"}"), ], ]); } /** - * Test case for Get - * allow get method for a custom path with all parameters + * Test case for GetTopFiltersNoResults + * get getTopFiltersNoResults with all parameters */ - public function testGet1() + public function testGetTopFiltersNoResults1() { $client = $this->getClient(); - $client->get( - '/test/all', - ['query' => 'parameters'] + $client->getTopFiltersNoResults( + 'index', + 'mySearch', + '1999-09-19', + '2001-01-01', + 21, + 42, + 'tag' ); $this->assertRequests([ [ - 'path' => '/1/test/all', + 'path' => '/2/filters/noResults', 'method' => 'GET', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'searchParams' => json_decode( + "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + ), ], ]); } /** - * Test case for GetTopFilterAttributes - * get getTopFilterAttributes with minimal parameters + * Test case for GetTopHits + * get getTopHits with minimal parameters */ - public function testGetTopFilterAttributes0() + public function testGetTopHits0() { $client = $this->getClient(); - $client->getTopFilterAttributes('index'); + $client->getTopHits('index'); $this->assertRequests([ [ - 'path' => '/2/filters', + 'path' => '/2/hits', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -849,16 +851,17 @@ public function testGetTopFilterAttributes0() } /** - * Test case for GetTopFilterAttributes - * get getTopFilterAttributes with all parameters + * Test case for GetTopHits + * get getTopHits with all parameters */ - public function testGetTopFilterAttributes1() + public function testGetTopHits1() { $client = $this->getClient(); - $client->getTopFilterAttributes( + $client->getTopHits( 'index', 'mySearch', + true, '1999-09-19', '2001-01-01', 21, @@ -868,28 +871,28 @@ public function testGetTopFilterAttributes1() $this->assertRequests([ [ - 'path' => '/2/filters', + 'path' => '/2/hits', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"search\":\"mySearch\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"search\":\"mySearch\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetTopCountries - * get getTopCountries with minimal parameters + * Test case for GetTopSearches + * get getTopSearches with minimal parameters */ - public function testGetTopCountries0() + public function testGetTopSearches0() { $client = $this->getClient(); - $client->getTopCountries('index'); + $client->getTopSearches('index'); $this->assertRequests([ [ - 'path' => '/2/countries', + 'path' => '/2/searches', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -897,17 +900,20 @@ public function testGetTopCountries0() } /** - * Test case for GetTopCountries - * get getTopCountries with all parameters + * Test case for GetTopSearches + * get getTopSearches with all parameters */ - public function testGetTopCountries1() + public function testGetTopSearches1() { $client = $this->getClient(); - $client->getTopCountries( + $client->getTopSearches( 'index', + true, '1999-09-19', '2001-01-01', + 'searchCount', + 'asc', 21, 42, 'tag' @@ -915,28 +921,28 @@ public function testGetTopCountries1() $this->assertRequests([ [ - 'path' => '/2/countries', + 'path' => '/2/searches', 'method' => 'GET', 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" + "{\"index\":\"index\",\"clickAnalytics\":\"true\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"orderBy\":\"searchCount\",\"direction\":\"asc\",\"limit\":\"21\",\"offset\":\"42\",\"tags\":\"tag\"}" ), ], ]); } /** - * Test case for GetConversationRate - * get getConversationRate with minimal parameters + * Test case for GetUsersCount + * get getUsersCount with minimal parameters */ - public function testGetConversationRate0() + public function testGetUsersCount0() { $client = $this->getClient(); - $client->getConversationRate('index'); + $client->getUsersCount('index'); $this->assertRequests([ [ - 'path' => '/2/conversions/conversionRate', + 'path' => '/2/users/count', 'method' => 'GET', 'searchParams' => json_decode("{\"index\":\"index\"}"), ], @@ -944,14 +950,14 @@ public function testGetConversationRate0() } /** - * Test case for GetConversationRate - * get getConversationRate with all parameters + * Test case for GetUsersCount + * get getUsersCount with all parameters */ - public function testGetConversationRate1() + public function testGetUsersCount1() { $client = $this->getClient(); - $client->getConversationRate( + $client->getUsersCount( 'index', '1999-09-19', '2001-01-01', @@ -960,7 +966,7 @@ public function testGetConversationRate1() $this->assertRequests([ [ - 'path' => '/2/conversions/conversionRate', + 'path' => '/2/users/count', 'method' => 'GET', 'searchParams' => json_decode( "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" @@ -970,91 +976,85 @@ public function testGetConversationRate1() } /** - * Test case for GetNoResultsRate - * get getNoResultsRate with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testGetNoResultsRate0() + public function testPost0() { $client = $this->getClient(); - $client->getNoResultsRate('index'); + $client->post('/test/minimal'); $this->assertRequests([ [ - 'path' => '/2/searches/noResultRate', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'path' => '/1/test/minimal', + 'method' => 'POST', ], ]); } /** - * Test case for GetNoResultsRate - * get getNoResultsRate with all parameters + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testGetNoResultsRate1() + public function testPost1() { $client = $this->getClient(); - $client->getNoResultsRate( - 'index', - '1999-09-19', - '2001-01-01', - 'tag' + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/searches/noResultRate', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" - ), + 'path' => '/1/test/all', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for GetClickThroughRate - * get getClickThroughRate with minimal parameters + * Test case for Put + * allow put method for a custom path with minimal parameters */ - public function testGetClickThroughRate0() + public function testPut0() { $client = $this->getClient(); - $client->getClickThroughRate('index'); + $client->put('/test/minimal'); $this->assertRequests([ [ - 'path' => '/2/clicks/clickThroughRate', - 'method' => 'GET', - 'searchParams' => json_decode("{\"index\":\"index\"}"), + 'path' => '/1/test/minimal', + 'method' => 'PUT', ], ]); } /** - * Test case for GetClickThroughRate - * get getClickThroughRate with all parameters + * Test case for Put + * allow put method for a custom path with all parameters */ - public function testGetClickThroughRate1() + public function testPut1() { $client = $this->getClient(); - $client->getClickThroughRate( - 'index', - '1999-09-19', - '2001-01-01', - 'tag' + $client->put( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/2/clicks/clickThroughRate', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"index\":\"index\",\"startDate\":\"1999-09-19\",\"endDate\":\"2001-01-01\",\"tags\":\"tag\"}" - ), + 'path' => '/1/test/all', + 'method' => 'PUT', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => 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 c65d851e8e..3c091e364d 100644 --- a/tests/output/php/src/methods/requests/InsightsTest.php +++ b/tests/output/php/src/methods/requests/InsightsTest.php @@ -77,42 +77,40 @@ protected function getClient() } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testPost0() + public function testDel0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->del('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'POST', + 'method' => 'DELETE', ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testPost1() + public function testDel1() { $client = $this->getClient(); - $client->post( + $client->del( '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + ['query' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), + 'method' => 'DELETE', 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); @@ -158,6 +156,48 @@ public function testGet1() ]); } + /** + * Test case for Post + * allow post method for a custom path with minimal parameters + */ + public function testPost0() + { + $client = $this->getClient(); + + $client->post('/test/minimal'); + + $this->assertRequests([ + [ + 'path' => '/1/test/minimal', + 'method' => 'POST', + ], + ]); + } + + /** + * Test case for Post + * allow post method for a custom path with all parameters + */ + public function testPost1() + { + $client = $this->getClient(); + + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/test/all', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + ], + ]); + } + /** * Test case for PushEvents * pushEvents @@ -229,46 +269,6 @@ public function testPushEvents0() ]); } - /** - * Test case for Del - * allow del method for a custom path with minimal parameters - */ - public function testDel0() - { - $client = $this->getClient(); - - $client->del('/test/minimal'); - - $this->assertRequests([ - [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', - ], - ]); - } - - /** - * Test case for Del - * allow del method for a custom path with all parameters - */ - public function testDel1() - { - $client = $this->getClient(); - - $client->del( - '/test/all', - ['query' => 'parameters'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), - ], - ]); - } - /** * Test case for Put * allow put method for a custom path with minimal parameters diff --git a/tests/output/php/src/methods/requests/PersonalizationTest.php b/tests/output/php/src/methods/requests/PersonalizationTest.php index c0f2b34acf..01795adbdc 100644 --- a/tests/output/php/src/methods/requests/PersonalizationTest.php +++ b/tests/output/php/src/methods/requests/PersonalizationTest.php @@ -77,61 +77,59 @@ protected function getClient() } /** - * Test case for DeleteUserProfile - * delete deleteUserProfile + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testDeleteUserProfile0() + public function testDel0() { $client = $this->getClient(); - $client->deleteUserProfile('UserToken'); + $client->del('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/profiles/UserToken', + 'path' => '/1/test/minimal', 'method' => 'DELETE', ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testPost0() + public function testDel1() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->del( + '/test/all', + ['query' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'POST', + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for DeleteUserProfile + * delete deleteUserProfile */ - public function testPost1() + public function testDeleteUserProfile0() { $client = $this->getClient(); - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] - ); + $client->deleteUserProfile('UserToken'); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/profiles/UserToken', + 'method' => 'DELETE', ], ]); } @@ -195,94 +193,61 @@ public function testGetPersonalizationStrategy0() } /** - * Test case for Del - * allow del method for a custom path with minimal parameters - */ - public function testDel0() - { - $client = $this->getClient(); - - $client->del('/test/minimal'); - - $this->assertRequests([ - [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', - ], - ]); - } - - /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for GetUserTokenProfile + * get getUserTokenProfile */ - public function testDel1() + public function testGetUserTokenProfile0() { $client = $this->getClient(); - $client->del( - '/test/all', - ['query' => 'parameters'] - ); + $client->getUserTokenProfile('UserToken'); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/profiles/personalization/UserToken', + 'method' => 'GET', ], ]); } /** - * Test case for GetUserTokenProfile - * get getUserTokenProfile + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testGetUserTokenProfile0() + public function testPost0() { $client = $this->getClient(); - $client->getUserTokenProfile('UserToken'); + $client->post('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/profiles/personalization/UserToken', - 'method' => 'GET', + 'path' => '/1/test/minimal', + 'method' => 'POST', ], ]); } /** - * Test case for SetPersonalizationStrategy - * set setPersonalizationStrategy + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testSetPersonalizationStrategy0() + public function testPost1() { $client = $this->getClient(); - $client->setPersonalizationStrategy([ - 'eventScoring' => [ - [ - 'score' => 42, - - 'eventName' => 'Algolia', - - 'eventType' => 'Event', - ], - ], - - 'facetScoring' => [['score' => 42, 'facetName' => 'Event']], - - 'personalizationImpact' => 42, - ]); + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/strategies/personalization', + 'path' => '/1/test/all', 'method' => 'POST', - 'body' => json_decode( - "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}" - ), + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -328,4 +293,39 @@ public function testPut1() ], ]); } + + /** + * Test case for SetPersonalizationStrategy + * set setPersonalizationStrategy + */ + public function testSetPersonalizationStrategy0() + { + $client = $this->getClient(); + + $client->setPersonalizationStrategy([ + 'eventScoring' => [ + [ + 'score' => 42, + + 'eventName' => 'Algolia', + + 'eventType' => 'Event', + ], + ], + + 'facetScoring' => [['score' => 42, 'facetName' => 'Event']], + + 'personalizationImpact' => 42, + ]); + + $this->assertRequests([ + [ + 'path' => '/1/strategies/personalization', + 'method' => 'POST', + 'body' => json_decode( + "{\"eventScoring\":[{\"score\":42,\"eventName\":\"Algolia\",\"eventType\":\"Event\"}],\"facetScoring\":[{\"score\":42,\"facetName\":\"Event\"}],\"personalizationImpact\":42}" + ), + ], + ]); + } } diff --git a/tests/output/php/src/methods/requests/QuerySuggestionsTest.php b/tests/output/php/src/methods/requests/QuerySuggestionsTest.php index 0e0a1e685b..16d7d2ed13 100644 --- a/tests/output/php/src/methods/requests/QuerySuggestionsTest.php +++ b/tests/output/php/src/methods/requests/QuerySuggestionsTest.php @@ -77,99 +77,96 @@ protected function getClient() } /** - * Test case for DeleteConfig - * deleteConfig + * Test case for CreateConfig + * createConfig */ - public function testDeleteConfig0() + public function testCreateConfig0() { $client = $this->getClient(); - $client->deleteConfig('theIndexName'); + $client->createConfig([ + 'indexName' => 'theIndexName', + + 'sourceIndices' => [ + [ + 'indexName' => 'testIndex', + + 'facets' => [['attributes' => 'test']], + + 'generate' => [['facetA', 'facetB'], ['facetC']], + ], + ], + + 'languages' => ['french'], + + 'exclude' => ['test'], + ]); $this->assertRequests([ [ - 'path' => '/1/configs/theIndexName', - 'method' => 'DELETE', + 'path' => '/1/configs', + 'method' => 'POST', + 'body' => json_decode( + "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" + ), ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testPost0() + public function testDel0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->del('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'POST', + 'method' => 'DELETE', ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testPost1() + public function testDel1() { $client = $this->getClient(); - $client->post( + $client->del( '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + ['query' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), + 'method' => 'DELETE', 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for UpdateConfig - * updateConfig + * Test case for DeleteConfig + * deleteConfig */ - public function testUpdateConfig0() + public function testDeleteConfig0() { $client = $this->getClient(); - $client->updateConfig( - 'theIndexName', - [ - 'sourceIndices' => [ - [ - 'indexName' => 'testIndex', - - 'facets' => [['attributes' => 'test']], - - 'generate' => [['facetA', 'facetB'], ['facetC']], - ], - ], - - 'languages' => ['french'], - - 'exclude' => ['test'], - ] - ); + $client->deleteConfig('theIndexName'); $this->assertRequests([ [ 'path' => '/1/configs/theIndexName', - 'method' => 'PUT', - 'body' => json_decode( - "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" - ), + 'method' => 'DELETE', ], ]); } @@ -215,132 +212,115 @@ public function testGet1() } /** - * Test case for CreateConfig - * createConfig + * Test case for GetAllConfigs + * getAllConfigs */ - public function testCreateConfig0() + public function testGetAllConfigs0() { $client = $this->getClient(); - $client->createConfig([ - 'indexName' => 'theIndexName', - - 'sourceIndices' => [ - [ - 'indexName' => 'testIndex', - - 'facets' => [['attributes' => 'test']], - - 'generate' => [['facetA', 'facetB'], ['facetC']], - ], - ], - - 'languages' => ['french'], - - 'exclude' => ['test'], - ]); + $client->getAllConfigs(); $this->assertRequests([ [ 'path' => '/1/configs', - 'method' => 'POST', - 'body' => json_decode( - "{\"indexName\":\"theIndexName\",\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" - ), + 'method' => 'GET', ], ]); } /** - * Test case for Del - * allow del method for a custom path with minimal parameters + * Test case for GetConfig + * getConfig */ - public function testDel0() + public function testGetConfig0() { $client = $this->getClient(); - $client->del('/test/minimal'); + $client->getConfig('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', + 'path' => '/1/configs/theIndexName', + 'method' => 'GET', ], ]); } /** - * Test case for Del - * allow del method for a custom path with all parameters + * Test case for GetConfigStatus + * getConfigStatus */ - public function testDel1() + public function testGetConfigStatus0() { $client = $this->getClient(); - $client->del( - '/test/all', - ['query' => 'parameters'] - ); + $client->getConfigStatus('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/configs/theIndexName/status', + 'method' => 'GET', ], ]); } /** - * Test case for GetConfigStatus - * getConfigStatus + * Test case for GetLogFile + * getLogFile */ - public function testGetConfigStatus0() + public function testGetLogFile0() { $client = $this->getClient(); - $client->getConfigStatus('theIndexName'); + $client->getLogFile('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/configs/theIndexName/status', + 'path' => '/1/logs/theIndexName', 'method' => 'GET', ], ]); } /** - * Test case for GetAllConfigs - * getAllConfigs + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testGetAllConfigs0() + public function testPost0() { $client = $this->getClient(); - $client->getAllConfigs(); + $client->post('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/configs', - 'method' => 'GET', + 'path' => '/1/test/minimal', + 'method' => 'POST', ], ]); } /** - * Test case for GetConfig - * getConfig + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testGetConfig0() + public function testPost1() { $client = $this->getClient(); - $client->getConfig('theIndexName'); + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/configs/theIndexName', - 'method' => 'GET', + 'path' => '/1/test/all', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } @@ -388,19 +368,39 @@ public function testPut1() } /** - * Test case for GetLogFile - * getLogFile + * Test case for UpdateConfig + * updateConfig */ - public function testGetLogFile0() + public function testUpdateConfig0() { $client = $this->getClient(); - $client->getLogFile('theIndexName'); + $client->updateConfig( + 'theIndexName', + [ + 'sourceIndices' => [ + [ + 'indexName' => 'testIndex', + + 'facets' => [['attributes' => 'test']], + + 'generate' => [['facetA', 'facetB'], ['facetC']], + ], + ], + + 'languages' => ['french'], + + 'exclude' => ['test'], + ] + ); $this->assertRequests([ [ - 'path' => '/1/logs/theIndexName', - 'method' => 'GET', + 'path' => '/1/configs/theIndexName', + 'method' => 'PUT', + 'body' => json_decode( + "{\"sourceIndices\":[{\"indexName\":\"testIndex\",\"facets\":[{\"attributes\":\"test\"}],\"generate\":[[\"facetA\",\"facetB\"],[\"facetC\"]]}],\"languages\":[\"french\"],\"exclude\":[\"test\"]}" + ), ], ]); } diff --git a/tests/output/php/src/methods/requests/RecommendTest.php b/tests/output/php/src/methods/requests/RecommendTest.php index c8b7caa371..70b6fe932d 100644 --- a/tests/output/php/src/methods/requests/RecommendTest.php +++ b/tests/output/php/src/methods/requests/RecommendTest.php @@ -77,42 +77,40 @@ protected function getClient() } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Del + * allow del method for a custom path with minimal parameters */ - public function testPost0() + public function testDel0() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->del('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'POST', + 'method' => 'DELETE', ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testPost1() + public function testDel1() { $client = $this->getClient(); - $client->post( + $client->del( '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + ['query' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), + 'method' => 'DELETE', 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); @@ -158,46 +156,6 @@ public function testGet1() ]); } - /** - * Test case for Del - * allow del method for a custom path with minimal parameters - */ - public function testDel0() - { - $client = $this->getClient(); - - $client->del('/test/minimal'); - - $this->assertRequests([ - [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', - ], - ]); - } - - /** - * Test case for Del - * allow del method for a custom path with all parameters - */ - public function testDel1() - { - $client = $this->getClient(); - - $client->del( - '/test/all', - ['query' => 'parameters'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), - ], - ]); - } - /** * Test case for GetRecommendations * get recommendations for recommend model with minimal parameters @@ -505,6 +463,48 @@ public function testGetRecommendations6() ]); } + /** + * Test case for Post + * allow post method for a custom path with minimal parameters + */ + public function testPost0() + { + $client = $this->getClient(); + + $client->post('/test/minimal'); + + $this->assertRequests([ + [ + 'path' => '/1/test/minimal', + 'method' => 'POST', + ], + ]); + } + + /** + * Test case for Post + * allow post method for a custom path with all parameters + */ + public function testPost1() + { + $client = $this->getClient(); + + $client->post( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/test/all', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + ], + ]); + } + /** * Test case for Put * allow put method for a custom path with minimal parameters diff --git a/tests/output/php/src/methods/requests/SearchTest.php b/tests/output/php/src/methods/requests/SearchTest.php index 4313f47940..dcb0de13c9 100644 --- a/tests/output/php/src/methods/requests/SearchTest.php +++ b/tests/output/php/src/methods/requests/SearchTest.php @@ -77,181 +77,159 @@ protected function getClient() } /** - * Test case for BatchAssignUserIds - * batchAssignUserIds + * Test case for AddApiKey + * addApiKey */ - public function testBatchAssignUserIds0() + public function testAddApiKey0() { $client = $this->getClient(); - $client->batchAssignUserIds( - 'userID', - ['cluster' => 'theCluster', 'users' => ['user1', 'user2']] - ); + $client->addApiKey([ + 'acl' => ['search', 'addObject'], - $this->assertRequests([ - [ - 'path' => '/1/clusters/mapping/batch', - 'method' => 'POST', - 'body' => json_decode( - "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}" - ), - 'searchParams' => json_decode( - "{\"X-Algolia-User-ID\":\"userID\"}" - ), - ], - ]); - } + 'description' => 'my new api key', - /** - * Test case for Del - * allow del method for a custom path with minimal parameters - */ - public function testDel0() - { - $client = $this->getClient(); + 'validity' => 300, - $client->del('/test/minimal'); + 'maxQueriesPerIPPerHour' => 100, - $this->assertRequests([ - [ - 'path' => '/1/test/minimal', - 'method' => 'DELETE', - ], + 'maxHitsPerQuery' => 20, ]); - } - - /** - * Test case for Del - * allow del method for a custom path with all parameters - */ - public function testDel1() - { - $client = $this->getClient(); - - $client->del( - '/test/all', - ['query' => 'parameters'] - ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'DELETE', - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/keys', + 'method' => 'POST', + 'body' => json_decode( + "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" + ), ], ]); } /** - * Test case for SearchRules - * searchRules + * Test case for AddOrUpdateObject + * addOrUpdateObject */ - public function testSearchRules0() + public function testAddOrUpdateObject0() { $client = $this->getClient(); - $client->searchRules( + $client->addOrUpdateObject( 'indexName', - ['query' => 'something'] + 'uniqueID', + ['key' => 'value'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/search', - 'method' => 'POST', - 'body' => json_decode("{\"query\":\"something\"}"), + 'path' => '/1/indexes/indexName/uniqueID', + 'method' => 'PUT', + 'body' => json_decode("{\"key\":\"value\"}"), ], ]); } /** - * Test case for DeleteIndex - * deleteIndex + * Test case for AppendSource + * appendSource */ - public function testDeleteIndex0() + public function testAppendSource0() { $client = $this->getClient(); - $client->deleteIndex('theIndexName'); + $client->appendSource([ + 'source' => 'theSource', + + 'description' => 'theDescription', + ]); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName', - 'method' => 'DELETE', + 'path' => '/1/security/sources/append', + 'method' => 'POST', + 'body' => json_decode( + "{\"source\":\"theSource\",\"description\":\"theDescription\"}" + ), ], ]); } /** - * Test case for Put - * allow put method for a custom path with minimal parameters + * Test case for AssignUserId + * assignUserId */ - public function testPut0() + public function testAssignUserId0() { $client = $this->getClient(); - $client->put('/test/minimal'); + $client->assignUserId( + 'userID', + ['cluster' => 'theCluster'] + ); $this->assertRequests([ [ - 'path' => '/1/test/minimal', - 'method' => 'PUT', + 'path' => '/1/clusters/mapping', + 'method' => 'POST', + 'body' => json_decode("{\"cluster\":\"theCluster\"}"), + 'searchParams' => json_decode( + "{\"X-Algolia-User-ID\":\"userID\"}" + ), ], ]); } /** - * Test case for Put - * allow put method for a custom path with all parameters + * Test case for Batch + * batch */ - public function testPut1() + public function testBatch0() { $client = $this->getClient(); - $client->put( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] + $client->batch( + 'theIndexName', + [ + 'requests' => [ + ['action' => 'delete', 'body' => ['key' => 'value']], + ], + ] ); $this->assertRequests([ [ - 'path' => '/1/test/all', - 'method' => 'PUT', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), + 'path' => '/1/indexes/theIndexName/batch', + 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}" + ), ], ]); } /** - * Test case for UpdateApiKey - * updateApiKey + * Test case for BatchAssignUserIds + * batchAssignUserIds */ - public function testUpdateApiKey0() + public function testBatchAssignUserIds0() { $client = $this->getClient(); - $client->updateApiKey( - 'myApiKey', - [ - 'acl' => ['search', 'addObject'], - - 'validity' => 300, - - 'maxQueriesPerIPPerHour' => 100, - - 'maxHitsPerQuery' => 20, - ] + $client->batchAssignUserIds( + 'userID', + ['cluster' => 'theCluster', 'users' => ['user1', 'user2']] ); $this->assertRequests([ [ - 'path' => '/1/keys/myApiKey', - 'method' => 'PUT', + 'path' => '/1/clusters/mapping/batch', + 'method' => 'POST', 'body' => json_decode( - "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" + "{\"cluster\":\"theCluster\",\"users\":[\"user1\",\"user2\"]}" + ), + 'searchParams' => json_decode( + "{\"X-Algolia-User-ID\":\"userID\"}" ), ], ]); @@ -411,536 +389,420 @@ public function testBatchRules0() } /** - * Test case for RestoreApiKey - * restoreApiKey + * Test case for Browse + * get browse results with minimal parameters */ - public function testRestoreApiKey0() + public function testBrowse0() { $client = $this->getClient(); - $client->restoreApiKey('myApiKey'); + $client->browse('indexName'); $this->assertRequests([ [ - 'path' => '/1/keys/myApiKey/restore', + 'path' => '/1/indexes/indexName/browse', 'method' => 'POST', ], ]); } /** - * Test case for Post - * allow post method for a custom path with minimal parameters + * Test case for Browse + * get browse results with all parameters */ - public function testPost0() + public function testBrowse1() { $client = $this->getClient(); - $client->post('/test/minimal'); + $client->browse( + 'indexName', + ['params' => "query=foo&facetFilters=['bar']", 'cursor' => 'cts'] + ); $this->assertRequests([ [ - 'path' => '/1/test/minimal', + 'path' => '/1/indexes/indexName/browse', 'method' => 'POST', + 'body' => json_decode( + "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}" + ), ], ]); } /** - * Test case for Post - * allow post method for a custom path with all parameters + * Test case for ClearAllSynonyms + * clearAllSynonyms */ - public function testPost1() + public function testClearAllSynonyms0() { $client = $this->getClient(); - $client->post( - '/test/all', - ['query' => 'parameters'], - ['body' => 'parameters'] - ); + $client->clearAllSynonyms('indexName'); $this->assertRequests([ [ - 'path' => '/1/test/all', + 'path' => '/1/indexes/indexName/synonyms/clear', 'method' => 'POST', - 'body' => json_decode("{\"body\":\"parameters\"}"), - 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for MultipleBatch - * multipleBatch + * Test case for ClearObjects + * clearObjects */ - public function testMultipleBatch0() + public function testClearObjects0() { $client = $this->getClient(); - $client->multipleBatch([ - 'requests' => [ - [ - 'action' => 'addObject', - - 'body' => ['key' => 'value'], - 'indexName' => 'theIndexName', - ], - ], - ]); + $client->clearObjects('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/indexes/*/batch', + 'path' => '/1/indexes/theIndexName/clear', 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}" - ), ], ]); } /** - * Test case for DeleteObject - * deleteObject + * Test case for ClearRules + * clearRules */ - public function testDeleteObject0() + public function testClearRules0() { $client = $this->getClient(); - $client->deleteObject( - 'theIndexName', - 'uniqueID' - ); + $client->clearRules('indexName'); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/uniqueID', - 'method' => 'DELETE', + 'path' => '/1/indexes/indexName/rules/clear', + 'method' => 'POST', ], ]); } /** - * Test case for SearchUserIds - * searchUserIds - */ - public function testSearchUserIds0() + * Test case for Del + * allow del method for a custom path with minimal parameters + */ + public function testDel0() { $client = $this->getClient(); - $client->searchUserIds([ - 'query' => 'test', - - 'clusterName' => 'theClusterName', - - 'page' => 5, - - 'hitsPerPage' => 10, - ]); + $client->del('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/search', - 'method' => 'POST', - 'body' => json_decode( - "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}" - ), + 'path' => '/1/test/minimal', + 'method' => 'DELETE', ], ]); } /** - * Test case for ReplaceSources - * replaceSources + * Test case for Del + * allow del method for a custom path with all parameters */ - public function testReplaceSources0() + public function testDel1() { $client = $this->getClient(); - $client->replaceSources([ - ['source' => 'theSource', 'description' => 'theDescription'], - ]); + $client->del( + '/test/all', + ['query' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/security/sources', - 'method' => 'PUT', - 'body' => json_decode( - "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]" - ), + 'path' => '/1/test/all', + 'method' => 'DELETE', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for RemoveUserId - * removeUserId + * Test case for DeleteApiKey + * deleteApiKey */ - public function testRemoveUserId0() + public function testDeleteApiKey0() { $client = $this->getClient(); - $client->removeUserId('uniqueID'); + $client->deleteApiKey('myTestApiKey'); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/uniqueID', + 'path' => '/1/keys/myTestApiKey', 'method' => 'DELETE', ], ]); } /** - * Test case for GetObject - * getObject + * Test case for DeleteBy + * deleteBy */ - public function testGetObject0() + public function testDeleteBy0() { $client = $this->getClient(); - $client->getObject( + $client->deleteBy( 'theIndexName', - 'uniqueID', - ['attr1', 'attr2'] + ['query' => 'testQuery'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/uniqueID', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"attributesToRetrieve\":\"attr1,attr2\"}" - ), + 'path' => '/1/indexes/theIndexName/deleteByQuery', + 'method' => 'POST', + 'body' => json_decode("{\"query\":\"testQuery\"}"), ], ]); } /** - * Test case for GetApiKey - * getApiKey + * Test case for DeleteIndex + * deleteIndex */ - public function testGetApiKey0() + public function testDeleteIndex0() { $client = $this->getClient(); - $client->getApiKey('myTestApiKey'); + $client->deleteIndex('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/keys/myTestApiKey', - 'method' => 'GET', + 'path' => '/1/indexes/theIndexName', + 'method' => 'DELETE', ], ]); } /** - * Test case for AssignUserId - * assignUserId + * Test case for DeleteObject + * deleteObject */ - public function testAssignUserId0() + public function testDeleteObject0() { $client = $this->getClient(); - $client->assignUserId( - 'userID', - ['cluster' => 'theCluster'] + $client->deleteObject( + 'theIndexName', + 'uniqueID' ); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping', - 'method' => 'POST', - 'body' => json_decode("{\"cluster\":\"theCluster\"}"), - 'searchParams' => json_decode( - "{\"X-Algolia-User-ID\":\"userID\"}" - ), + 'path' => '/1/indexes/theIndexName/uniqueID', + 'method' => 'DELETE', ], ]); } /** - * Test case for DeleteSynonym - * deleteSynonym + * Test case for DeleteRule + * deleteRule */ - public function testDeleteSynonym0() + public function testDeleteRule0() { $client = $this->getClient(); - $client->deleteSynonym( + $client->deleteRule( 'indexName', 'id1' ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/id1', + 'path' => '/1/indexes/indexName/rules/id1', 'method' => 'DELETE', ], ]); } /** - * Test case for SearchSynonyms - * searchSynonyms + * Test case for DeleteSource + * deleteSource */ - public function testSearchSynonyms0() + public function testDeleteSource0() { $client = $this->getClient(); - $client->searchSynonyms('indexName'); + $client->deleteSource('theSource'); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/search', - 'method' => 'POST', + 'path' => '/1/security/sources/theSource', + 'method' => 'DELETE', ], ]); } /** - * Test case for GetLogs - * getLogs + * Test case for DeleteSynonym + * deleteSynonym */ - public function testGetLogs0() + public function testDeleteSynonym0() { $client = $this->getClient(); - $client->getLogs( - 5, - 10, - 'theIndexName', - 'all' + $client->deleteSynonym( + 'indexName', + 'id1' ); $this->assertRequests([ [ - 'path' => '/1/logs', - 'method' => 'GET', - 'searchParams' => json_decode( - "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}" - ), + 'path' => '/1/indexes/indexName/synonyms/id1', + 'method' => 'DELETE', ], ]); } /** - * Test case for Batch - * batch + * Test case for Get + * allow get method for a custom path with minimal parameters */ - public function testBatch0() + public function testGet0() { $client = $this->getClient(); - $client->batch( - 'theIndexName', - [ - 'requests' => [ - ['action' => 'delete', 'body' => ['key' => 'value']], - ], - ] - ); + $client->get('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/batch', - 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}" - ), + 'path' => '/1/test/minimal', + 'method' => 'GET', ], ]); } /** - * Test case for AddOrUpdateObject - * addOrUpdateObject + * Test case for Get + * allow get method for a custom path with all parameters */ - public function testAddOrUpdateObject0() + public function testGet1() { $client = $this->getClient(); - $client->addOrUpdateObject( - 'indexName', - 'uniqueID', - ['key' => 'value'] + $client->get( + '/test/all', + ['query' => 'parameters'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/uniqueID', - 'method' => 'PUT', - 'body' => json_decode("{\"key\":\"value\"}"), + 'path' => '/1/test/all', + 'method' => 'GET', + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for ClearObjects - * clearObjects + * Test case for GetApiKey + * getApiKey */ - public function testClearObjects0() + public function testGetApiKey0() { $client = $this->getClient(); - $client->clearObjects('theIndexName'); + $client->getApiKey('myTestApiKey'); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/clear', - 'method' => 'POST', + 'path' => '/1/keys/myTestApiKey', + 'method' => 'GET', ], ]); } /** - * Test case for SetSettings - * setSettings + * Test case for GetDictionaryLanguages + * get getDictionaryLanguages */ - public function testSetSettings0() + public function testGetDictionaryLanguages0() { $client = $this->getClient(); - $client->setSettings( - 'theIndexName', - ['paginationLimitedTo' => 10], - true - ); + $client->getDictionaryLanguages(); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/settings', - 'method' => 'PUT', - 'body' => json_decode("{\"paginationLimitedTo\":10}"), - 'searchParams' => json_decode( - "{\"forwardToReplicas\":\"true\"}" - ), + 'path' => '/1/dictionaries/*/languages', + 'method' => 'GET', ], ]); } /** - * Test case for ClearRules - * clearRules + * Test case for GetDictionarySettings + * get getDictionarySettings results */ - public function testClearRules0() + public function testGetDictionarySettings0() { $client = $this->getClient(); - $client->clearRules('indexName'); + $client->getDictionarySettings(); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/clear', - 'method' => 'POST', + 'path' => '/1/dictionaries/*/settings', + 'method' => 'GET', ], ]); } /** - * Test case for GetSynonym - * getSynonym + * Test case for GetLogs + * getLogs */ - public function testGetSynonym0() + public function testGetLogs0() { $client = $this->getClient(); - $client->getSynonym( - 'indexName', - 'id1' + $client->getLogs( + 5, + 10, + 'theIndexName', + 'all' ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/id1', + 'path' => '/1/logs', 'method' => 'GET', + 'searchParams' => json_decode( + "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}" + ), ], ]); } /** - * Test case for DeleteBy - * deleteBy + * Test case for GetObject + * getObject */ - public function testDeleteBy0() + public function testGetObject0() { $client = $this->getClient(); - $client->deleteBy( + $client->getObject( 'theIndexName', - ['query' => 'testQuery'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/theIndexName/deleteByQuery', - 'method' => 'POST', - 'body' => json_decode("{\"query\":\"testQuery\"}"), - ], - ]); - } - - /** - * Test case for ListUserIds - * listUserIds - */ - public function testListUserIds0() - { - $client = $this->getClient(); - - $client->listUserIds( - 8, - 100 + 'uniqueID', + ['attr1', 'attr2'] ); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping', + 'path' => '/1/indexes/theIndexName/uniqueID', 'method' => 'GET', 'searchParams' => json_decode( - "{\"page\":\"8\",\"hitsPerPage\":\"100\"}" - ), - ], - ]); - } - - /** - * Test case for Browse - * get browse results with minimal parameters - */ - public function testBrowse0() - { - $client = $this->getClient(); - - $client->browse('indexName'); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/indexName/browse', - 'method' => 'POST', - ], - ]); - } - - /** - * Test case for Browse - * get browse results with all parameters - */ - public function testBrowse1() - { - $client = $this->getClient(); - - $client->browse( - 'indexName', - ['params' => "query=foo&facetFilters=['bar']", 'cursor' => 'cts'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/indexName/browse', - 'method' => 'POST', - 'body' => json_decode( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"cursor\":\"cts\"}" + "{\"attributesToRetrieve\":\"attr1,attr2\"}" ), ], ]); @@ -978,548 +840,566 @@ public function testGetObjects0() } /** - * Test case for PartialUpdateObject - * partialUpdateObject + * Test case for GetRule + * getRule */ - public function testPartialUpdateObject0() + public function testGetRule0() { $client = $this->getClient(); - $client->partialUpdateObject( - 'theIndexName', - 'uniqueID', - [ - [ - 'id1' => 'test', - - 'id2' => ['_operation' => 'AddUnique', 'value' => 'test2'], - ], - ], - true + $client->getRule( + 'indexName', + 'id1' ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/uniqueID/partial', - 'method' => 'POST', - 'body' => json_decode( - "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]" - ), - 'searchParams' => json_decode( - "{\"createIfNotExists\":\"true\"}" - ), + 'path' => '/1/indexes/indexName/rules/id1', + 'method' => 'GET', ], ]); } /** - * Test case for MultipleQueries - * multipleQueries for a single request with minimal parameters + * Test case for GetSettings + * getSettings */ - public function testMultipleQueries0() + public function testGetSettings0() { $client = $this->getClient(); - $client->multipleQueries([ - 'requests' => [['indexName' => 'theIndexName']], - - 'strategy' => 'stopIfEnoughMatches', - ]); + $client->getSettings('theIndexName'); $this->assertRequests([ [ - 'path' => '/1/indexes/*/queries', - 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"indexName\":\"theIndexName\"}],\"strategy\":\"stopIfEnoughMatches\"}" - ), + 'path' => '/1/indexes/theIndexName/settings', + 'method' => 'GET', ], ]); } /** - * Test case for MultipleQueries - * multipleQueries for multiple requests with all parameters + * Test case for GetSources + * getSources */ - public function testMultipleQueries1() + public function testGetSources0() { $client = $this->getClient(); - $client->multipleQueries([ - 'requests' => [ - [ - 'indexName' => 'theIndexName', - - 'query' => 'test', - - 'type' => 'facet', - - 'facet' => 'theFacet', - - 'params' => 'testParam', - ], - - [ - 'indexName' => 'theIndexName', - - 'query' => 'test', - - 'type' => 'default', - - 'params' => 'testParam', - ], - ], - - 'strategy' => 'stopIfEnoughMatches', - ]); + $client->getSources(); $this->assertRequests([ [ - 'path' => '/1/indexes/*/queries', - 'method' => 'POST', - 'body' => json_decode( - "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"},{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"default\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}" - ), + 'path' => '/1/security/sources', + 'method' => 'GET', ], ]); } /** - * Test case for SearchForFacetValues - * get searchForFacetValues results with minimal parameters + * Test case for GetSynonym + * getSynonym */ - public function testSearchForFacetValues0() + public function testGetSynonym0() { $client = $this->getClient(); - $client->searchForFacetValues( + $client->getSynonym( 'indexName', - 'facetName' + 'id1' ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/facets/facetName/query', - 'method' => 'POST', + 'path' => '/1/indexes/indexName/synonyms/id1', + 'method' => 'GET', ], ]); } /** - * Test case for SearchForFacetValues - * get searchForFacetValues results with all parameters + * Test case for GetTask + * getTask */ - public function testSearchForFacetValues1() + public function testGetTask0() { $client = $this->getClient(); - $client->searchForFacetValues( - 'indexName', - 'facetName', - [ - 'params' => "query=foo&facetFilters=['bar']", - - 'facetQuery' => 'foo', - - 'maxFacetHits' => 42, - ] + $client->getTask( + 'theIndexName', + 123 ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/facets/facetName/query', - 'method' => 'POST', - 'body' => json_decode( - "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}" - ), + 'path' => '/1/indexes/theIndexName/task/123', + 'method' => 'GET', ], ]); } /** - * Test case for GetSettings - * getSettings + * Test case for GetTopUserIds + * getTopUserIds */ - public function testGetSettings0() + public function testGetTopUserIds0() { $client = $this->getClient(); - $client->getSettings('theIndexName'); + $client->getTopUserIds(); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/settings', + 'path' => '/1/clusters/mapping/top', 'method' => 'GET', ], ]); } /** - * Test case for ListIndices - * listIndices + * Test case for GetUserId + * getUserId */ - public function testListIndices0() + public function testGetUserId0() { $client = $this->getClient(); - $client->listIndices(8); + $client->getUserId('uniqueID'); $this->assertRequests([ [ - 'path' => '/1/indexes', + 'path' => '/1/clusters/mapping/uniqueID', 'method' => 'GET', - 'searchParams' => json_decode("{\"page\":\"8\"}"), ], ]); } /** - * Test case for GetDictionarySettings - * get getDictionarySettings results + * Test case for HasPendingMappings + * hasPendingMappings */ - public function testGetDictionarySettings0() + public function testHasPendingMappings0() { $client = $this->getClient(); - $client->getDictionarySettings(); + $client->hasPendingMappings(true); $this->assertRequests([ [ - 'path' => '/1/dictionaries/*/settings', + 'path' => '/1/clusters/mapping/pending', 'method' => 'GET', + 'searchParams' => json_decode("{\"getClusters\":\"true\"}"), ], ]); } /** - * Test case for DeleteSource - * deleteSource + * Test case for ListApiKeys + * listApiKeys */ - public function testDeleteSource0() + public function testListApiKeys0() { $client = $this->getClient(); - $client->deleteSource('theSource'); + $client->listApiKeys(); $this->assertRequests([ [ - 'path' => '/1/security/sources/theSource', - 'method' => 'DELETE', + 'path' => '/1/keys', + 'method' => 'GET', ], ]); } /** - * Test case for GetSources - * getSources + * Test case for ListClusters + * listClusters */ - public function testGetSources0() + public function testListClusters0() { $client = $this->getClient(); - $client->getSources(); + $client->listClusters(); $this->assertRequests([ [ - 'path' => '/1/security/sources', + 'path' => '/1/clusters', 'method' => 'GET', ], ]); } /** - * Test case for GetDictionaryLanguages - * get getDictionaryLanguages + * Test case for ListIndices + * listIndices */ - public function testGetDictionaryLanguages0() + public function testListIndices0() { $client = $this->getClient(); - $client->getDictionaryLanguages(); + $client->listIndices(8); $this->assertRequests([ [ - 'path' => '/1/dictionaries/*/languages', + 'path' => '/1/indexes', 'method' => 'GET', + 'searchParams' => json_decode("{\"page\":\"8\"}"), ], ]); } /** - * Test case for DeleteApiKey - * deleteApiKey + * Test case for ListUserIds + * listUserIds */ - public function testDeleteApiKey0() + public function testListUserIds0() { $client = $this->getClient(); - $client->deleteApiKey('myTestApiKey'); + $client->listUserIds( + 8, + 100 + ); $this->assertRequests([ [ - 'path' => '/1/keys/myTestApiKey', - 'method' => 'DELETE', + 'path' => '/1/clusters/mapping', + 'method' => 'GET', + 'searchParams' => json_decode( + "{\"page\":\"8\",\"hitsPerPage\":\"100\"}" + ), ], ]); } /** - * Test case for ListApiKeys - * listApiKeys + * Test case for MultipleBatch + * multipleBatch */ - public function testListApiKeys0() + public function testMultipleBatch0() { $client = $this->getClient(); - $client->listApiKeys(); + $client->multipleBatch([ + 'requests' => [ + [ + 'action' => 'addObject', + + 'body' => ['key' => 'value'], + 'indexName' => 'theIndexName', + ], + ], + ]); $this->assertRequests([ [ - 'path' => '/1/keys', - 'method' => 'GET', + 'path' => '/1/indexes/*/batch', + 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"action\":\"addObject\",\"body\":{\"key\":\"value\"},\"indexName\":\"theIndexName\"}]}" + ), ], ]); } /** - * Test case for SaveSynonyms - * saveSynonyms + * Test case for MultipleQueries + * multipleQueries for a single request with minimal parameters */ - public function testSaveSynonyms0() + public function testMultipleQueries0() { $client = $this->getClient(); - $client->saveSynonyms( - 'indexName', + $client->multipleQueries([ + 'requests' => [['indexName' => 'theIndexName']], + + 'strategy' => 'stopIfEnoughMatches', + ]); + + $this->assertRequests([ [ + 'path' => '/1/indexes/*/queries', + 'method' => 'POST', + 'body' => json_decode( + "{\"requests\":[{\"indexName\":\"theIndexName\"}],\"strategy\":\"stopIfEnoughMatches\"}" + ), + ], + ]); + } + + /** + * Test case for MultipleQueries + * multipleQueries for multiple requests with all parameters + */ + public function testMultipleQueries1() + { + $client = $this->getClient(); + + $client->multipleQueries([ + 'requests' => [ [ - 'objectID' => 'id1', + 'indexName' => 'theIndexName', - 'type' => 'synonym', + 'query' => 'test', - 'synonyms' => ['car', 'vehicule', 'auto'], + 'type' => 'facet', + + 'facet' => 'theFacet', + + 'params' => 'testParam', ], [ - 'objectID' => 'id2', + 'indexName' => 'theIndexName', - 'type' => 'onewaysynonym', + 'query' => 'test', - 'input' => 'iphone', + 'type' => 'default', - 'synonyms' => ['ephone', 'aphone', 'yphone'], + 'params' => 'testParam', ], ], - true, - false - ); + + 'strategy' => 'stopIfEnoughMatches', + ]); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/batch', + 'path' => '/1/indexes/*/queries', 'method' => 'POST', 'body' => json_decode( - "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]" - ), - 'searchParams' => json_decode( - "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}" + "{\"requests\":[{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"facet\",\"facet\":\"theFacet\",\"params\":\"testParam\"},{\"indexName\":\"theIndexName\",\"query\":\"test\",\"type\":\"default\",\"params\":\"testParam\"}],\"strategy\":\"stopIfEnoughMatches\"}" ), ], ]); } /** - * Test case for Search - * search with minimal parameters + * Test case for OperationIndex + * operationIndex */ - public function testSearch0() + public function testOperationIndex0() { $client = $this->getClient(); - $client->search( - 'indexName', - ['query' => 'myQuery'] + $client->operationIndex( + 'theIndexName', + [ + 'operation' => 'copy', + + 'destination' => 'dest', + + 'scope' => ['rules', 'settings'], + ] ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/query', + 'path' => '/1/indexes/theIndexName/operation', 'method' => 'POST', - 'body' => json_decode("{\"query\":\"myQuery\"}"), + 'body' => json_decode( + "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}" + ), ], ]); } /** - * Test case for Search - * search with facetFilters + * Test case for PartialUpdateObject + * partialUpdateObject */ - public function testSearch1() + public function testPartialUpdateObject0() { $client = $this->getClient(); - $client->search( - 'indexName', - ['query' => 'myQuery', 'facetFilters' => ['tags:algolia']] + $client->partialUpdateObject( + 'theIndexName', + 'uniqueID', + [ + [ + 'id1' => 'test', + + 'id2' => ['_operation' => 'AddUnique', 'value' => 'test2'], + ], + ], + true ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/query', + 'path' => '/1/indexes/theIndexName/uniqueID/partial', 'method' => 'POST', 'body' => json_decode( - "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}" + "[{\"id1\":\"test\",\"id2\":{\"_operation\":\"AddUnique\",\"value\":\"test2\"}}]" + ), + 'searchParams' => json_decode( + "{\"createIfNotExists\":\"true\"}" ), ], ]); } /** - * Test case for Get - * allow get method for a custom path with minimal parameters + * Test case for Post + * allow post method for a custom path with minimal parameters */ - public function testGet0() + public function testPost0() { $client = $this->getClient(); - $client->get('/test/minimal'); + $client->post('/test/minimal'); $this->assertRequests([ [ 'path' => '/1/test/minimal', - 'method' => 'GET', + 'method' => 'POST', ], ]); } /** - * Test case for Get - * allow get method for a custom path with all parameters + * Test case for Post + * allow post method for a custom path with all parameters */ - public function testGet1() + public function testPost1() { $client = $this->getClient(); - $client->get( + $client->post( '/test/all', - ['query' => 'parameters'] + ['query' => 'parameters'], + ['body' => 'parameters'] ); $this->assertRequests([ [ 'path' => '/1/test/all', - 'method' => 'GET', + 'method' => 'POST', + 'body' => json_decode("{\"body\":\"parameters\"}"), 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for HasPendingMappings - * hasPendingMappings + * Test case for Put + * allow put method for a custom path with minimal parameters */ - public function testHasPendingMappings0() + public function testPut0() { $client = $this->getClient(); - $client->hasPendingMappings(true); + $client->put('/test/minimal'); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/pending', - 'method' => 'GET', - 'searchParams' => json_decode("{\"getClusters\":\"true\"}"), + 'path' => '/1/test/minimal', + 'method' => 'PUT', ], ]); } /** - * Test case for GetTopUserIds - * getTopUserIds + * Test case for Put + * allow put method for a custom path with all parameters */ - public function testGetTopUserIds0() + public function testPut1() { $client = $this->getClient(); - $client->getTopUserIds(); + $client->put( + '/test/all', + ['query' => 'parameters'], + ['body' => 'parameters'] + ); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/top', - 'method' => 'GET', + 'path' => '/1/test/all', + 'method' => 'PUT', + 'body' => json_decode("{\"body\":\"parameters\"}"), + 'searchParams' => json_decode("{\"query\":\"parameters\"}"), ], ]); } /** - * Test case for SetDictionarySettings - * get setDictionarySettings results with minimal parameters + * Test case for RemoveUserId + * removeUserId */ - public function testSetDictionarySettings0() + public function testRemoveUserId0() { $client = $this->getClient(); - $client->setDictionarySettings([ - 'disableStandardEntries' => [ - 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], - ], - ]); + $client->removeUserId('uniqueID'); $this->assertRequests([ [ - 'path' => '/1/dictionaries/*/settings', - 'method' => 'PUT', - 'body' => json_decode( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}" - ), + 'path' => '/1/clusters/mapping/uniqueID', + 'method' => 'DELETE', ], ]); } /** - * Test case for SetDictionarySettings - * get setDictionarySettings results with all parameters + * Test case for ReplaceSources + * replaceSources */ - public function testSetDictionarySettings1() + public function testReplaceSources0() { $client = $this->getClient(); - $client->setDictionarySettings([ - 'disableStandardEntries' => [ - 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], - 'stopwords' => ['fr' => false], - 'compounds' => ['ru' => true], - ], + $client->replaceSources([ + ['source' => 'theSource', 'description' => 'theDescription'], ]); $this->assertRequests([ [ - 'path' => '/1/dictionaries/*/settings', + 'path' => '/1/security/sources', 'method' => 'PUT', 'body' => json_decode( - "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}" + "[{\"source\":\"theSource\",\"description\":\"theDescription\"}]" ), ], ]); } /** - * Test case for DeleteRule - * deleteRule + * Test case for RestoreApiKey + * restoreApiKey */ - public function testDeleteRule0() + public function testRestoreApiKey0() { $client = $this->getClient(); - $client->deleteRule( - 'indexName', - 'id1' + $client->restoreApiKey('myApiKey'); + + $this->assertRequests([ + [ + 'path' => '/1/keys/myApiKey/restore', + 'method' => 'POST', + ], + ]); + } + + /** + * Test case for SaveObject + * saveObject + */ + public function testSaveObject0() + { + $client = $this->getClient(); + + $client->saveObject( + 'theIndexName', + ['objectID' => 'id', 'test' => 'val'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/id1', - 'method' => 'DELETE', + 'path' => '/1/indexes/theIndexName', + 'method' => 'POST', + 'body' => json_decode("{\"objectID\":\"id\",\"test\":\"val\"}"), ], ]); } @@ -1561,28 +1441,6 @@ public function testSaveRule0() ]); } - /** - * Test case for SaveObject - * saveObject - */ - public function testSaveObject0() - { - $client = $this->getClient(); - - $client->saveObject( - 'theIndexName', - ['objectID' => 'id', 'test' => 'val'] - ); - - $this->assertRequests([ - [ - 'path' => '/1/indexes/theIndexName', - 'method' => 'POST', - 'body' => json_decode("{\"objectID\":\"id\",\"test\":\"val\"}"), - ], - ]); - } - /** * Test case for SaveSynonym * saveSynonym @@ -1619,94 +1477,93 @@ public function testSaveSynonym0() } /** - * Test case for AppendSource - * appendSource + * Test case for SaveSynonyms + * saveSynonyms */ - public function testAppendSource0() + public function testSaveSynonyms0() { $client = $this->getClient(); - $client->appendSource([ - 'source' => 'theSource', + $client->saveSynonyms( + 'indexName', + [ + [ + 'objectID' => 'id1', - 'description' => 'theDescription', - ]); + 'type' => 'synonym', - $this->assertRequests([ - [ - 'path' => '/1/security/sources/append', - 'method' => 'POST', - 'body' => json_decode( - "{\"source\":\"theSource\",\"description\":\"theDescription\"}" - ), - ], - ]); - } + 'synonyms' => ['car', 'vehicule', 'auto'], + ], - /** - * Test case for ClearAllSynonyms - * clearAllSynonyms - */ - public function testClearAllSynonyms0() - { - $client = $this->getClient(); + [ + 'objectID' => 'id2', - $client->clearAllSynonyms('indexName'); + 'type' => 'onewaysynonym', + + 'input' => 'iphone', + + 'synonyms' => ['ephone', 'aphone', 'yphone'], + ], + ], + true, + false + ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/synonyms/clear', + 'path' => '/1/indexes/indexName/synonyms/batch', 'method' => 'POST', + 'body' => json_decode( + "[{\"objectID\":\"id1\",\"type\":\"synonym\",\"synonyms\":[\"car\",\"vehicule\",\"auto\"]},{\"objectID\":\"id2\",\"type\":\"onewaysynonym\",\"input\":\"iphone\",\"synonyms\":[\"ephone\",\"aphone\",\"yphone\"]}]" + ), + 'searchParams' => json_decode( + "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}" + ), ], ]); } /** - * Test case for GetRule - * getRule + * Test case for Search + * search with minimal parameters */ - public function testGetRule0() + public function testSearch0() { $client = $this->getClient(); - $client->getRule( + $client->search( 'indexName', - 'id1' + ['query' => 'myQuery'] ); $this->assertRequests([ [ - 'path' => '/1/indexes/indexName/rules/id1', - 'method' => 'GET', + 'path' => '/1/indexes/indexName/query', + 'method' => 'POST', + 'body' => json_decode("{\"query\":\"myQuery\"}"), ], ]); } /** - * Test case for OperationIndex - * operationIndex + * Test case for Search + * search with facetFilters */ - public function testOperationIndex0() + public function testSearch1() { $client = $this->getClient(); - $client->operationIndex( - 'theIndexName', - [ - 'operation' => 'copy', - - 'destination' => 'dest', - - 'scope' => ['rules', 'settings'], - ] + $client->search( + 'indexName', + ['query' => 'myQuery', 'facetFilters' => ['tags:algolia']] ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/operation', + 'path' => '/1/indexes/indexName/query', 'method' => 'POST', 'body' => json_decode( - "{\"operation\":\"copy\",\"destination\":\"dest\",\"scope\":[\"rules\",\"settings\"]}" + "{\"query\":\"myQuery\",\"facetFilters\":[\"tags:algolia\"]}" ), ], ]); @@ -1767,89 +1624,232 @@ public function testSearchDictionaryEntries1() } /** - * Test case for ListClusters - * listClusters + * Test case for SearchForFacetValues + * get searchForFacetValues results with minimal parameters */ - public function testListClusters0() + public function testSearchForFacetValues0() { $client = $this->getClient(); - $client->listClusters(); + $client->searchForFacetValues( + 'indexName', + 'facetName' + ); $this->assertRequests([ [ - 'path' => '/1/clusters', - 'method' => 'GET', + 'path' => '/1/indexes/indexName/facets/facetName/query', + 'method' => 'POST', ], ]); } /** - * Test case for AddApiKey - * addApiKey + * Test case for SearchForFacetValues + * get searchForFacetValues results with all parameters */ - public function testAddApiKey0() + public function testSearchForFacetValues1() { $client = $this->getClient(); - $client->addApiKey([ - 'acl' => ['search', 'addObject'], + $client->searchForFacetValues( + 'indexName', + 'facetName', + [ + 'params' => "query=foo&facetFilters=['bar']", - 'description' => 'my new api key', + 'facetQuery' => 'foo', - 'validity' => 300, + 'maxFacetHits' => 42, + ] + ); - 'maxQueriesPerIPPerHour' => 100, + $this->assertRequests([ + [ + 'path' => '/1/indexes/indexName/facets/facetName/query', + 'method' => 'POST', + 'body' => json_decode( + "{\"params\":\"query=foo&facetFilters=['bar']\",\"facetQuery\":\"foo\",\"maxFacetHits\":42}" + ), + ], + ]); + } - 'maxHitsPerQuery' => 20, + /** + * Test case for SearchRules + * searchRules + */ + public function testSearchRules0() + { + $client = $this->getClient(); + + $client->searchRules( + 'indexName', + ['query' => 'something'] + ); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/indexName/rules/search', + 'method' => 'POST', + 'body' => json_decode("{\"query\":\"something\"}"), + ], + ]); + } + + /** + * Test case for SearchSynonyms + * searchSynonyms + */ + public function testSearchSynonyms0() + { + $client = $this->getClient(); + + $client->searchSynonyms('indexName'); + + $this->assertRequests([ + [ + 'path' => '/1/indexes/indexName/synonyms/search', + 'method' => 'POST', + ], + ]); + } + + /** + * Test case for SearchUserIds + * searchUserIds + */ + public function testSearchUserIds0() + { + $client = $this->getClient(); + + $client->searchUserIds([ + 'query' => 'test', + + 'clusterName' => 'theClusterName', + + 'page' => 5, + + 'hitsPerPage' => 10, ]); $this->assertRequests([ [ - 'path' => '/1/keys', + 'path' => '/1/clusters/mapping/search', 'method' => 'POST', 'body' => json_decode( - "{\"acl\":[\"search\",\"addObject\"],\"description\":\"my new api key\",\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" + "{\"query\":\"test\",\"clusterName\":\"theClusterName\",\"page\":5,\"hitsPerPage\":10}" ), ], ]); } /** - * Test case for GetTask - * getTask + * Test case for SetDictionarySettings + * get setDictionarySettings results with minimal parameters */ - public function testGetTask0() + public function testSetDictionarySettings0() { $client = $this->getClient(); - $client->getTask( + $client->setDictionarySettings([ + 'disableStandardEntries' => [ + 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], + ], + ]); + + $this->assertRequests([ + [ + 'path' => '/1/dictionaries/*/settings', + 'method' => 'PUT', + 'body' => json_decode( + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true}}}" + ), + ], + ]); + } + + /** + * Test case for SetDictionarySettings + * get setDictionarySettings results with all parameters + */ + public function testSetDictionarySettings1() + { + $client = $this->getClient(); + + $client->setDictionarySettings([ + 'disableStandardEntries' => [ + 'plurals' => ['fr' => false, 'en' => false, 'ru' => true], + 'stopwords' => ['fr' => false], + 'compounds' => ['ru' => true], + ], + ]); + + $this->assertRequests([ + [ + 'path' => '/1/dictionaries/*/settings', + 'method' => 'PUT', + 'body' => json_decode( + "{\"disableStandardEntries\":{\"plurals\":{\"fr\":false,\"en\":false,\"ru\":true},\"stopwords\":{\"fr\":false},\"compounds\":{\"ru\":true}}}" + ), + ], + ]); + } + + /** + * Test case for SetSettings + * setSettings + */ + public function testSetSettings0() + { + $client = $this->getClient(); + + $client->setSettings( 'theIndexName', - 123 + ['paginationLimitedTo' => 10], + true ); $this->assertRequests([ [ - 'path' => '/1/indexes/theIndexName/task/123', - 'method' => 'GET', + 'path' => '/1/indexes/theIndexName/settings', + 'method' => 'PUT', + 'body' => json_decode("{\"paginationLimitedTo\":10}"), + 'searchParams' => json_decode( + "{\"forwardToReplicas\":\"true\"}" + ), ], ]); } /** - * Test case for GetUserId - * getUserId + * Test case for UpdateApiKey + * updateApiKey */ - public function testGetUserId0() + public function testUpdateApiKey0() { $client = $this->getClient(); - $client->getUserId('uniqueID'); + $client->updateApiKey( + 'myApiKey', + [ + 'acl' => ['search', 'addObject'], + + 'validity' => 300, + + 'maxQueriesPerIPPerHour' => 100, + + 'maxHitsPerQuery' => 20, + ] + ); $this->assertRequests([ [ - 'path' => '/1/clusters/mapping/uniqueID', - 'method' => 'GET', + 'path' => '/1/keys/myApiKey', + 'method' => 'PUT', + 'body' => json_decode( + "{\"acl\":[\"search\",\"addObject\"],\"validity\":300,\"maxQueriesPerIPPerHour\":100,\"maxHitsPerQuery\":20}" + ), ], ]); } From c2db9025136a5befd9040602b71744f07666ad5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Wed, 27 Apr 2022 16:32:17 +0200 Subject: [PATCH 6/6] format --- .../main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java | 2 -- 1 file changed, 2 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 e4ea3c5641..98546dc3e2 100644 --- a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -10,10 +10,8 @@ import java.io.File; import java.io.IOException; import java.util.*; -import java.util.Collections; import java.util.Map.Entry; import java.util.TreeMap; -import java.util.stream.Collectors; import org.openapitools.codegen.*; @SuppressWarnings("unchecked")