diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java index 6830e7f3f..26e0b019b 100644 --- a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/Cloudant.java @@ -20,9 +20,11 @@ import com.ibm.cloud.cloudant.v1.model.AllDocsResult; import com.ibm.cloud.cloudant.v1.model.ApiKeysResult; import com.ibm.cloud.cloudant.v1.model.BulkGetResult; +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformation; import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation; import com.ibm.cloud.cloudant.v1.model.ChangesResult; import com.ibm.cloud.cloudant.v1.model.CorsInformation; +import com.ibm.cloud.cloudant.v1.model.CurrentDatabasesInformation; import com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation; import com.ibm.cloud.cloudant.v1.model.DatabaseInformation; import com.ibm.cloud.cloudant.v1.model.DbUpdates; @@ -45,8 +47,10 @@ import com.ibm.cloud.cloudant.v1.model.GetActivityTrackerEventsOptions; import com.ibm.cloud.cloudant.v1.model.GetAllDbsOptions; import com.ibm.cloud.cloudant.v1.model.GetAttachmentOptions; +import com.ibm.cloud.cloudant.v1.model.GetCapacityDatabasesInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCapacityThroughputInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCorsInformationOptions; +import com.ibm.cloud.cloudant.v1.model.GetCurrentDatabasesInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCurrentThroughputInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetDatabaseInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetDbUpdatesOptions; @@ -4418,6 +4422,68 @@ public ServiceCall postActivityTrackerEvents(PostActivityTrackerEventsOption return createServiceCall(builder.build(), responseConverter); } + /** + * Retrieve maximum allowed database count. + * + * Retrieves the maximum number of databases currently allowed in the instance. + * + * @param getCapacityDatabasesInformationOptions the {@link GetCapacityDatabasesInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link CapacityDatabasesInformation} + */ + public ServiceCall getCapacityDatabasesInformation(GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/capacity/databases")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCapacityDatabasesInformation"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve maximum allowed database count. + * + * Retrieves the maximum number of databases currently allowed in the instance. + * + * @return a {@link ServiceCall} with a result of type {@link CapacityDatabasesInformation} + */ + public ServiceCall getCapacityDatabasesInformation() { + return getCapacityDatabasesInformation(null); + } + + /** + * Retrieve current database count. + * + * Retrieves the current number of databases that exist in the instance. + * + * @param getCurrentDatabasesInformationOptions the {@link GetCurrentDatabasesInformationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link CurrentDatabasesInformation} + */ + public ServiceCall getCurrentDatabasesInformation(GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptions) { + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/current/databases")); + Map sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCurrentDatabasesInformation"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Retrieve current database count. + * + * Retrieves the current number of databases that exist in the instance. + * + * @return a {@link ServiceCall} with a result of type {@link CurrentDatabasesInformation} + */ + public ServiceCall getCurrentDatabasesInformation() { + return getCurrentDatabasesInformation(null); + } + /** * Retrieve the current provisioned throughput capacity consumption. * diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformation.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformation.java new file mode 100644 index 000000000..384c68305 --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformation.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Schema for information about maximum total database count. + */ +public class CapacityDatabasesInformation extends GenericModel { + + protected CapacityDatabasesInformationCurrent current; + + protected CapacityDatabasesInformation() { } + + /** + * Gets the current. + * + * Schema for information about the current database capacity. + * + * @return the current + */ + public CapacityDatabasesInformationCurrent getCurrent() { + return current; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationCurrent.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationCurrent.java new file mode 100644 index 000000000..2bab3139f --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationCurrent.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Schema for information about the current database capacity. + */ +public class CapacityDatabasesInformationCurrent extends GenericModel { + + protected DatabasesCountInformation databases; + + protected CapacityDatabasesInformationCurrent() { } + + /** + * Gets the databases. + * + * Schema for databases count. + * + * @return the databases + */ + public DatabasesCountInformation getDatabases() { + return databases; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CurrentDatabasesInformation.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CurrentDatabasesInformation.java new file mode 100644 index 000000000..0ee6c523d --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/CurrentDatabasesInformation.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Schema for information about the current database counts. + */ +public class CurrentDatabasesInformation extends GenericModel { + + protected DatabasesCountInformation databases; + + protected CurrentDatabasesInformation() { } + + /** + * Gets the databases. + * + * Schema for databases count. + * + * @return the databases + */ + public DatabasesCountInformation getDatabases() { + return databases; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/DatabasesCountInformation.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/DatabasesCountInformation.java new file mode 100644 index 000000000..dc533dfca --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/DatabasesCountInformation.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Schema for databases count. + */ +public class DatabasesCountInformation extends GenericModel { + + protected Long total; + + protected DatabasesCountInformation() { } + + /** + * Gets the total. + * + * The total number of databases. + * + * @return the total + */ + public Long getTotal() { + return total; + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/GetCapacityDatabasesInformationOptions.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/GetCapacityDatabasesInformationOptions.java new file mode 100644 index 000000000..ab285142a --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/GetCapacityDatabasesInformationOptions.java @@ -0,0 +1,29 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getCapacityDatabasesInformation options. + */ +public class GetCapacityDatabasesInformationOptions extends GenericModel { + + /** + * Construct a new instance of GetCapacityDatabasesInformationOptions. + */ + public GetCapacityDatabasesInformationOptions() { + } +} + diff --git a/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/GetCurrentDatabasesInformationOptions.java b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/GetCurrentDatabasesInformationOptions.java new file mode 100644 index 000000000..6fd87968d --- /dev/null +++ b/modules/cloudant/src/main/java/com/ibm/cloud/cloudant/v1/model/GetCurrentDatabasesInformationOptions.java @@ -0,0 +1,29 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getCurrentDatabasesInformation options. + */ +public class GetCurrentDatabasesInformationOptions extends GenericModel { + + /** + * Construct a new instance of GetCurrentDatabasesInformationOptions. + */ + public GetCurrentDatabasesInformationOptions() { + } +} + diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java index c9c740b77..debe28db0 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantIT.java @@ -27,6 +27,8 @@ import com.ibm.cloud.cloudant.v1.model.BulkGetResult; import com.ibm.cloud.cloudant.v1.model.BulkGetResultDocument; import com.ibm.cloud.cloudant.v1.model.BulkGetResultItem; +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformation; +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformationCurrent; import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation; import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformationCurrent; import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformationTarget; @@ -35,11 +37,13 @@ import com.ibm.cloud.cloudant.v1.model.ChangesResultItem; import com.ibm.cloud.cloudant.v1.model.ContentInformationSizes; import com.ibm.cloud.cloudant.v1.model.CorsInformation; +import com.ibm.cloud.cloudant.v1.model.CurrentDatabasesInformation; import com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation; import com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformationThroughput; import com.ibm.cloud.cloudant.v1.model.DatabaseInformation; import com.ibm.cloud.cloudant.v1.model.DatabaseInformationCluster; import com.ibm.cloud.cloudant.v1.model.DatabaseInformationProps; +import com.ibm.cloud.cloudant.v1.model.DatabasesCountInformation; import com.ibm.cloud.cloudant.v1.model.DbEvent; import com.ibm.cloud.cloudant.v1.model.DbUpdates; import com.ibm.cloud.cloudant.v1.model.DbsInfoResult; @@ -70,8 +74,10 @@ import com.ibm.cloud.cloudant.v1.model.GetActivityTrackerEventsOptions; import com.ibm.cloud.cloudant.v1.model.GetAllDbsOptions; import com.ibm.cloud.cloudant.v1.model.GetAttachmentOptions; +import com.ibm.cloud.cloudant.v1.model.GetCapacityDatabasesInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCapacityThroughputInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCorsInformationOptions; +import com.ibm.cloud.cloudant.v1.model.GetCurrentDatabasesInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCurrentThroughputInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetDatabaseInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetDbUpdatesOptions; @@ -3271,6 +3277,46 @@ public void testPostActivityTrackerEvents() throws Exception { } @Test(dependsOnMethods = { "testPostActivityTrackerEvents" }) + public void testGetCapacityDatabasesInformation() throws Exception { + try { + GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptions = new GetCapacityDatabasesInformationOptions(); + + // Invoke operation + Response response = service.getCapacityDatabasesInformation(getCapacityDatabasesInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + CapacityDatabasesInformation capacityDatabasesInformationResult = response.getResult(); + assertNotNull(capacityDatabasesInformationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetCapacityDatabasesInformation" }) + public void testGetCurrentDatabasesInformation() throws Exception { + try { + GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptions = new GetCurrentDatabasesInformationOptions(); + + // Invoke operation + Response response = service.getCurrentDatabasesInformation(getCurrentDatabasesInformationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + CurrentDatabasesInformation currentDatabasesInformationResult = response.getResult(); + assertNotNull(currentDatabasesInformationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetCurrentDatabasesInformation" }) public void testGetCurrentThroughputInformation() throws Exception { try { GetCurrentThroughputInformationOptions getCurrentThroughputInformationOptions = new GetCurrentThroughputInformationOptions(); diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java index 98eedc0bb..707cc49ac 100644 --- a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/CloudantTest.java @@ -28,6 +28,8 @@ import com.ibm.cloud.cloudant.v1.model.BulkGetResult; import com.ibm.cloud.cloudant.v1.model.BulkGetResultDocument; import com.ibm.cloud.cloudant.v1.model.BulkGetResultItem; +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformation; +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformationCurrent; import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformation; import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformationCurrent; import com.ibm.cloud.cloudant.v1.model.CapacityThroughputInformationTarget; @@ -36,11 +38,13 @@ import com.ibm.cloud.cloudant.v1.model.ChangesResultItem; import com.ibm.cloud.cloudant.v1.model.ContentInformationSizes; import com.ibm.cloud.cloudant.v1.model.CorsInformation; +import com.ibm.cloud.cloudant.v1.model.CurrentDatabasesInformation; import com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformation; import com.ibm.cloud.cloudant.v1.model.CurrentThroughputInformationThroughput; import com.ibm.cloud.cloudant.v1.model.DatabaseInformation; import com.ibm.cloud.cloudant.v1.model.DatabaseInformationCluster; import com.ibm.cloud.cloudant.v1.model.DatabaseInformationProps; +import com.ibm.cloud.cloudant.v1.model.DatabasesCountInformation; import com.ibm.cloud.cloudant.v1.model.DbEvent; import com.ibm.cloud.cloudant.v1.model.DbUpdates; import com.ibm.cloud.cloudant.v1.model.DbsInfoResult; @@ -71,8 +75,10 @@ import com.ibm.cloud.cloudant.v1.model.GetActivityTrackerEventsOptions; import com.ibm.cloud.cloudant.v1.model.GetAllDbsOptions; import com.ibm.cloud.cloudant.v1.model.GetAttachmentOptions; +import com.ibm.cloud.cloudant.v1.model.GetCapacityDatabasesInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCapacityThroughputInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCorsInformationOptions; +import com.ibm.cloud.cloudant.v1.model.GetCurrentDatabasesInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetCurrentThroughputInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetDatabaseInformationOptions; import com.ibm.cloud.cloudant.v1.model.GetDbUpdatesOptions; @@ -6336,6 +6342,90 @@ public void testPostActivityTrackerEventsNoOptions() throws Throwable { cloudantService.postActivityTrackerEvents(null).execute(); } + // Test the getCapacityDatabasesInformation operation with a valid options model parameter + @Test + public void testGetCapacityDatabasesInformationWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"current\": {\"databases\": {\"total\": 0}}}"; + String getCapacityDatabasesInformationPath = "/_api/v2/user/capacity/databases"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCapacityDatabasesInformationOptions model + GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptionsModel = new GetCapacityDatabasesInformationOptions(); + + // Invoke getCapacityDatabasesInformation() with a valid options model and verify the result + Response response = cloudantService.getCapacityDatabasesInformation(getCapacityDatabasesInformationOptionsModel).execute(); + assertNotNull(response); + CapacityDatabasesInformation responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCapacityDatabasesInformationPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getCapacityDatabasesInformation operation with and without retries enabled + @Test + public void testGetCapacityDatabasesInformationWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testGetCapacityDatabasesInformationWOptions(); + + cloudantService.disableRetries(); + testGetCapacityDatabasesInformationWOptions(); + } + + // Test the getCurrentDatabasesInformation operation with a valid options model parameter + @Test + public void testGetCurrentDatabasesInformationWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"databases\": {\"total\": 0}}"; + String getCurrentDatabasesInformationPath = "/_api/v2/user/current/databases"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetCurrentDatabasesInformationOptions model + GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptionsModel = new GetCurrentDatabasesInformationOptions(); + + // Invoke getCurrentDatabasesInformation() with a valid options model and verify the result + Response response = cloudantService.getCurrentDatabasesInformation(getCurrentDatabasesInformationOptionsModel).execute(); + assertNotNull(response); + CurrentDatabasesInformation responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCurrentDatabasesInformationPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getCurrentDatabasesInformation operation with and without retries enabled + @Test + public void testGetCurrentDatabasesInformationWRetries() throws Throwable { + cloudantService.enableRetries(4, 30); + testGetCurrentDatabasesInformationWOptions(); + + cloudantService.disableRetries(); + testGetCurrentDatabasesInformationWOptions(); + } + // Test the getCurrentThroughputInformation operation with a valid options model parameter @Test public void testGetCurrentThroughputInformationWOptions() throws Throwable { diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationCurrentTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationCurrentTest.java new file mode 100644 index 000000000..34e2bcb25 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationCurrentTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformationCurrent; +import com.ibm.cloud.cloudant.v1.model.DatabasesCountInformation; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CapacityDatabasesInformationCurrent model. + */ +public class CapacityDatabasesInformationCurrentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCapacityDatabasesInformationCurrent() throws Throwable { + CapacityDatabasesInformationCurrent capacityDatabasesInformationCurrentModel = new CapacityDatabasesInformationCurrent(); + assertNull(capacityDatabasesInformationCurrentModel.getDatabases()); + } +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationTest.java new file mode 100644 index 000000000..945ef76c4 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CapacityDatabasesInformationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformation; +import com.ibm.cloud.cloudant.v1.model.CapacityDatabasesInformationCurrent; +import com.ibm.cloud.cloudant.v1.model.DatabasesCountInformation; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CapacityDatabasesInformation model. + */ +public class CapacityDatabasesInformationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCapacityDatabasesInformation() throws Throwable { + CapacityDatabasesInformation capacityDatabasesInformationModel = new CapacityDatabasesInformation(); + assertNull(capacityDatabasesInformationModel.getCurrent()); + } +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CurrentDatabasesInformationTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CurrentDatabasesInformationTest.java new file mode 100644 index 000000000..c8e6f25e7 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/CurrentDatabasesInformationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.CurrentDatabasesInformation; +import com.ibm.cloud.cloudant.v1.model.DatabasesCountInformation; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CurrentDatabasesInformation model. + */ +public class CurrentDatabasesInformationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCurrentDatabasesInformation() throws Throwable { + CurrentDatabasesInformation currentDatabasesInformationModel = new CurrentDatabasesInformation(); + assertNull(currentDatabasesInformationModel.getDatabases()); + } +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/DatabasesCountInformationTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/DatabasesCountInformationTest.java new file mode 100644 index 000000000..c753ea184 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/DatabasesCountInformationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.DatabasesCountInformation; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the DatabasesCountInformation model. + */ +public class DatabasesCountInformationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDatabasesCountInformation() throws Throwable { + DatabasesCountInformation databasesCountInformationModel = new DatabasesCountInformation(); + assertNull(databasesCountInformationModel.getTotal()); + } +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/GetCapacityDatabasesInformationOptionsTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/GetCapacityDatabasesInformationOptionsTest.java new file mode 100644 index 000000000..d4c1e7113 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/GetCapacityDatabasesInformationOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.GetCapacityDatabasesInformationOptions; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetCapacityDatabasesInformationOptions model. + */ +public class GetCapacityDatabasesInformationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCapacityDatabasesInformationOptions() throws Throwable { + GetCapacityDatabasesInformationOptions getCapacityDatabasesInformationOptionsModel = new GetCapacityDatabasesInformationOptions(); + assertNotNull(getCapacityDatabasesInformationOptionsModel); + } +} \ No newline at end of file diff --git a/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/GetCurrentDatabasesInformationOptionsTest.java b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/GetCurrentDatabasesInformationOptionsTest.java new file mode 100644 index 000000000..5c5676523 --- /dev/null +++ b/modules/cloudant/src/test/java/com/ibm/cloud/cloudant/v1/model/GetCurrentDatabasesInformationOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.cloudant.v1.model; + +import com.ibm.cloud.cloudant.v1.model.GetCurrentDatabasesInformationOptions; +import com.ibm.cloud.cloudant.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetCurrentDatabasesInformationOptions model. + */ +public class GetCurrentDatabasesInformationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCurrentDatabasesInformationOptions() throws Throwable { + GetCurrentDatabasesInformationOptions getCurrentDatabasesInformationOptionsModel = new GetCurrentDatabasesInformationOptions(); + assertNotNull(getCurrentDatabasesInformationOptionsModel); + } +} \ No newline at end of file diff --git a/stubs/gen-its-mappings.json b/stubs/gen-its-mappings.json index 737cf1c65..d39f95f1d 100644 --- a/stubs/gen-its-mappings.json +++ b/stubs/gen-its-mappings.json @@ -445,7 +445,7 @@ "uuid": "a2e4e696-e631-33f8-b168-5015048cdad8" }, { - "id": "8593b1aa-6297-3120-a04e-c199e2808167", + "id": "8593b1aa-6297-3120-a04e-c199e2808168", "request": { "url": "/_api/v2/user/current/databases", "method": "GET" @@ -473,7 +473,7 @@ } } }, - "uuid": "8593b1aa-6297-3120-a04e-c199e2808167" + "uuid": "8593b1aa-6297-3120-a04e-c199e2808168" }, { "id": "8c38b725-a6ac-3f63-a723-9f4925ae23fd",